473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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\htdocs\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\htdocs\test.php on line 3

What am i doing wrong?

Thanks in advance

MJ
Jul 20 '05 #1
4 4931
MJ wrote:
Fatal error: Call to undefined function mysql_connect() in C:\Program
Files\Apache Group\Apache2\htdocs\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\htdocs\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\htdocs\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\htdocs\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\htdocs\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\htdocs\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
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...
2
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...
4
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...
0
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...
17
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...
0
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...
4
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...
6
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.