Page 1 of 1

Fatal error: Call to undefined function mysql_connect()

Posted: Wed Dec 10, 2008 7:13 pm
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!

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

Posted: Wed Dec 10, 2008 9:05 pm
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

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

Posted: Thu Dec 11, 2008 10:19 am
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.

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

Posted: Thu Dec 11, 2008 11:06 am
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.

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

Posted: Wed Dec 17, 2008 11:58 am
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.

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

Posted: Wed Dec 17, 2008 2:21 pm
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)

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

Posted: Wed Dec 17, 2008 8:35 pm
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?

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

Posted: Wed Dec 17, 2008 9:01 pm
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.