473,608 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cant connect to database - please help!

MJ
I am using the following script to connect but keep getting
<?php
$conn = mysql_connect(" ", "mjohn", "");
mysql_select_db ("testDB",$conn );
?>

but keep getting this error
Fatal error: Call to undefined function mysql_connect() in C:\Program
Files\Apache Group\Apache2\h tdocs\test.php on line 2

if i change line 2 to
<?php
$conn = mysqli_connect( "", "mjohn", "");
mysql_select_db ("testDB",$conn );
?>
i get this
Fatal error: Call to undefined function mysql_select_db () in C:\Program
Files\Apache Group\Apache2\h tdocs\test.php on line 3

What am i doing wrong?

Thanks in advance

MJ
Jul 20 '05 #1
4 4946
MJ wrote:
Fatal error: Call to undefined function mysql_connect() in C:\Program
Files\Apache Group\Apache2\h tdocs\test.php on line 2 What am i doing wrong?


You are using a php version where there is no MySQL support. If you for
example compile your php from sources like I do and run it as a cgi,
then you should have done something like this:

../configure --with-mysql
make

Where the "--with-mysql" part seems to be missing from you.

If you are running php as a module instead of cgi, I don't know how you
get the MySQL support for it, but you might get the answer by:
- Checking php website
- Asking from some php newsgroup, because they know lot better how php
should be installed.
- Searching google newsgroups, because I know that you are not the first
person asking that question. Good search phrase might be:

php "Call to undefined function mysql_connect"

Jul 20 '05 #2
MJ wrote:
Fatal error: Call to undefined function mysql_connect() in C:\Program
Files\Apache Group\Apache2\h tdocs\test.php on line 2 What am i doing wrong?


You are using a php version where there is no MySQL support. If you for
example compile your php from sources like I do and run it as a cgi,
then you should have done something like this:

../configure --with-mysql
make

Where the "--with-mysql" part seems to be missing from you.

If you are running php as a module instead of cgi, I don't know how you
get the MySQL support for it, but you might get the answer by:
- Checking php website
- Asking from some php newsgroup, because they know lot better how php
should be installed.
- Searching google newsgroups, because I know that you are not the first
person asking that question. Good search phrase might be:

php "Call to undefined function mysql_connect"

Jul 20 '05 #3
I had this program after reinstalling my OS recently. It would appear that
even if you have Apache, PHP and MySQL configured correctly your still
missing the php-mysql module. This is the 'libary' of mysql functions FOR
php if you will.

On my system (Mandrake Linux) the package is called php-mysql-4.3.4-1mdk
I don't know what the windows version is but it's probalby similar.

At least in my case I was getting 'function undefined' because the functions
quite litteraly didn't exist on my system...

Hope that helps.

Ravenslay3r
MJ wrote:
I am using the following script to connect but keep getting
<?php
$conn = mysql_connect(" ", "mjohn", "");
mysql_select_db ("testDB",$conn );
?>

but keep getting this error
Fatal error: Call to undefined function mysql_connect() in C:\Program
Files\Apache Group\Apache2\h tdocs\test.php on line 2

if i change line 2 to
<?php
$conn = mysqli_connect( "", "mjohn", "");
mysql_select_db ("testDB",$conn );
?>
i get this
Fatal error: Call to undefined function mysql_select_db () in C:\Program
Files\Apache Group\Apache2\h tdocs\test.php on line 3

What am i doing wrong?

Thanks in advance

MJ


Jul 20 '05 #4
I had this program after reinstalling my OS recently. It would appear that
even if you have Apache, PHP and MySQL configured correctly your still
missing the php-mysql module. This is the 'libary' of mysql functions FOR
php if you will.

On my system (Mandrake Linux) the package is called php-mysql-4.3.4-1mdk
I don't know what the windows version is but it's probalby similar.

At least in my case I was getting 'function undefined' because the functions
quite litteraly didn't exist on my system...

Hope that helps.

Ravenslay3r
MJ wrote:
I am using the following script to connect but keep getting
<?php
$conn = mysql_connect(" ", "mjohn", "");
mysql_select_db ("testDB",$conn );
?>

but keep getting this error
Fatal error: Call to undefined function mysql_connect() in C:\Program
Files\Apache Group\Apache2\h tdocs\test.php on line 2

if i change line 2 to
<?php
$conn = mysqli_connect( "", "mjohn", "");
mysql_select_db ("testDB",$conn );
?>
i get this
Fatal error: Call to undefined function mysql_select_db () in C:\Program
Files\Apache Group\Apache2\h tdocs\test.php on line 3

What am i doing wrong?

Thanks in advance

MJ


Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2317
by: Tiernan | last post by:
Hey everybody. I'm verry new to PHP and MYSQL and have been working on a form that when it is submitted stores the information into a mysql database. The main problem is that i'm trying to finish up my script for almost a week now and I still cant get it right. here is the code <?php include ("ES_includes/appconst.inc.php") ;
2
2045
by: William Friend | last post by:
Im rather new to Linux and my server has been running great, up until the other day. I was messing around with mysql through webmin in mandrake 9.2 and know I cant do anything, not even create a database. I keep getting this message ( DBI connect failed : Access denied for user: '@localhost' to database 'mysql') and have no clue how to fix it. I have tried to reinstall the rpms that came on the mandrake 9.2 cds and I still get the same...
4
2453
by: gregsands | last post by:
Hi I have read all (ok most) of the posts relating to "Call to undefined function mysql_connect()", read the manual on PHP.net and done eveything thats ive been asked to do but cant get PHP to talk to MySQL, PHP is working fine but I dont get any mysql info when running <? phpinfo() ?> and get the "Call to undefined function mysql_connect()" when trying to connect to mysql through php in browser, please help. 1. I have added C:\php;...
0
2378
by: Aaron | last post by:
Hi Guys, I have a dbase installed on a network where the clints have linked tables to the database on the server. I found that i had to make some minor changes to the tables on the server where the client databases look to for their data after I made the changes I tried to open one of the clients databases and found that I was getting an error 3051 open exclusive where when the client tries to connect to the tables on the server it...
17
2015
by: so many sites so little time | last post by:
all right so the script is pretty simple it goes it retrives what the id of the post is and it lets you edit it well no it doesnt. now if you go to www.kirewire.com/pp2/index/php you will see a number 1 that is the value of collumn home_id which is set to auto increment ect ect but this script which gets the id of home_id of a row and lets you edit it does not work for somereason...
0
1961
by: asad56 | last post by:
I am workin with a superstore managment project. I connect Access database with main form . Then it work properly. But now I connect same database with another table or field in another form which is child of main form not working. Main form stil working but when try to open child a message show as Please select a valid SQL statement as "Select", "Delet" or "Updat" I am working with Access . I connect database in...
4
3018
by: dotnetgal | last post by:
Hi all! I am using MSSQL 2005 and asp.net .I have made a web application that needs to be run in LAN.The authentication used is windows authentication.The problem is that when in LAN I cannot connect to the database The sqlexception error shows that the connection is closed.Is there any thing that i am missing?Any configurations i need to make??Is this the issue of remote connections?? Please help!!I am new and dont knw much abt it .Thanks!!
6
1959
flexsingh
by: flexsingh | last post by:
Hello there, I have constructed a option of choosing a court only available when member no = "0". This works fine and is in the first code: - <html> <head> </head> <body background="main background1.jpg" link="blue" vlink="blue"> <table width="350" border="1" align="center" cellpadding="0" cellspacing="1"> <tr>
0
954
by: un33k | last post by:
Im using vs 2008 and when i try and connect to a database in my local machine it comes up with an error. I have named pipes and TCP/IP enabled in the configuration manager but still something missing maybe. name of my database is "Database". here's the code. SqlConnection Myconn = new SqlConnection("Data Source=(local);Initial Catalog=Database;Integrated Security=SSPI"); Myconn.Open(); An error has occurred while establishing a...
0
8000
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6815
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3960
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1328
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.