Fatal error: Call to undefined function mysql_connect()

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
applening56
Forum Newbie
Posts: 4
Joined: Wed Dec 10, 2008 4:17 pm

Fatal error: Call to undefined function mysql_connect()

Post by applening56 »

Fatal error: Call to undefined function mysql_connect()

above is the error i got when i tried to run this code:

<?php
mysql_connect("localhost", "root", "root") or die(mysql_error());
echo mysql_error();
echo "Connected to MySQL<br />";
mysql_select_db("test") or die(mysql_error());
echo "Connected to Database";
?>

i'm new to php and just installed php 5.2.8 and apache 2.2 on vista home premium (i had MySQL5.0 installed before)

it seems php cannot talk to MySQL. i don't see any information about MySQL when i run phpinfo()

i copied php_mysql.dll to c:\program files\php\ext and set the extension_dir as the same in php.ini. i also have php_mysql.dll and libmysql.dll in system32 folder.

i've been playing around with php.ini for a while and i'm running out of options now. does anybody have an idea what the problem might be?? help!

thanks in advance!
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: Fatal error: Call to undefined function mysql_connect()

Post by novice4eva »

If it looks like this in php.ini

Code: Select all

 
;extension=php_mysql.dll
 
change it so it looks like

Code: Select all

 
extension=php_mysql.dll
 
and rerun the services, phpinfo must show mysql thing somewhere
applening56
Forum Newbie
Posts: 4
Joined: Wed Dec 10, 2008 4:17 pm

Re: Fatal error: Call to undefined function mysql_connect()

Post by applening56 »

thanks for your reply!

but i had uncommented the line and it wasn't working.

i've given up on php5 and installed php4. it's working fine now.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Fatal error: Call to undefined function mysql_connect()

Post by Eran »

i've given up on php5 and installed php4. it's working fine now.
Following this logic, do you uninstall windows XP and install windows 3.11 every time a program isn't working?
Going back to PHP 4 is a major regression. It is no longer officially supported and misses many advanced features introduced in PHP 5.
applening56
Forum Newbie
Posts: 4
Joined: Wed Dec 10, 2008 4:17 pm

Re: Fatal error: Call to undefined function mysql_connect()

Post by applening56 »

pytrin wrote:
i've given up on php5 and installed php4. it's working fine now.
Following this logic, do you uninstall windows XP and install windows 3.11 every time a program isn't working?
Going back to PHP 4 is a major regression. It is no longer officially supported and misses many advanced features introduced in PHP 5.
I know it's not the best solution. I wouldn't have done that if I had other options. I had read a number of threads related to this topic and tried every possible solution people suggested, but it just didn't work.

I just didn't know what else to do. Since it's a testing machine I'm using, I just got it to work with the application I plan to test and didn't want to waste more time on it. The actual server I'm gonna use already has PHP5 and MySQL so I don't have to worry about that.

But it would be greatly appreciated if you would share your thought on what might be the problem. It kinda bothers me.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Fatal error: Call to undefined function mysql_connect()

Post by John Cartwright »

Did you restart apache after making the changes to your php.ini?

Did you check your error logs?

I agree with the others, reverting back to PHP4 not the best decision 8)
applening56
Forum Newbie
Posts: 4
Joined: Wed Dec 10, 2008 4:17 pm

Re: Fatal error: Call to undefined function mysql_connect()

Post by applening56 »

Jcart wrote:Did you restart apache after making the changes to your php.ini?

Did you check your error logs?

I agree with the others, reverting back to PHP4 not the best decision 8)

I did restart every time made changes. Where do I find the error log?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Fatal error: Call to undefined function mysql_connect()

Post by John Cartwright »

Typically there is a "logs" dir within apache dir. I.e, in my install it would be \apache\logs\error.log

This more than likely will tell you what is happening when trying to load the module.
Post Reply