Connecting Tech Pros Worldwide Help | Site Map

Cant connect to database - please help!

MJ
Guest
 
Posts: n/a
#1: Jul 20 '05
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


Aggro
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Cant connect to database - please help!


MJ wrote:
[color=blue]
> Fatal error: Call to undefined function mysql_connect() in C:\Program
> Files\Apache Group\Apache2\htdocs\test.php on line 2[/color]
[color=blue]
> What am i doing wrong?[/color]

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"

Aggro
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Cant connect to database - please help!


MJ wrote:
[color=blue]
> Fatal error: Call to undefined function mysql_connect() in C:\Program
> Files\Apache Group\Apache2\htdocs\test.php on line 2[/color]
[color=blue]
> What am i doing wrong?[/color]

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"

Ravenslay3r
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Cant connect to database - please help!


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:
[color=blue]
> 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[/color]

Ravenslay3r
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Cant connect to database - please help!


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:
[color=blue]
> 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[/color]

Closed Thread