Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting MySQL to PHP

Status
Not open for further replies.

badley

Technical User
Dec 20, 2002
75
GB
Hi All,

I just been told to learn PHP and MySQL by my boss.

Finding it ok for the moment, how ever when I try to connect the MySQL via PHP like this: this error occurs:

Fatal error: Call to undefined function mysql_connect() in ....

Now, I have tried locating the problem by enabling MySQL to work with PHP in the C:php/BACKUP/php.ini file. This unfortunatly doesn't do anything.

Can anyone suggest anything?

My setup is PHP 5 MySQL 4 and IIS
 
i am a new learner as well, could u tell me how to get the error msg?
 
I just started a new php page and pasted the following in:

<?php
$link = mysql_connect('localhost', 'root', 'emenexphp');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

Ran it through IIS and the error message appeared:

Fatal error: Call to undefined function mysql_connect() in ....

Sites say its to do with MySQL not being enabled in PHP. So I checked this in:

<?php
phpinfo()
?>

and no sign of the MySQL table, thus MySQL not enabled.

I have opened the php.ini file and uncommented the line:

;extension=php_mysql.dll

to

extension=php_mysql.dll

thinking that will enable MySQL. But still nothing. I have also had a tinker with MyODBC which seems to work fine.

 
I think I need to compile it to make it work. How do I do this?
 
i think you need to start up mysql first then run it using php
the code should work
 
Actually no cellpeter, it says undefined function, which means the mysql_ function does not even exist, depending if you are on windows or on linux, you may need to compile mysql support into PHP. On windows its already supported.

Karl Blessing
PHP/MySQL Developer
 
Cheers kb244. On Windows how do I go about compiling?
 
PHP doesn't give you mysql support out of the box.
Edit the php.ini file and take out the leading semi-colon before php_mysql in the ;extension=php_mysql.dll line.
Make sure that the actual dll is on the path as well,
Look intio the dicumentation and all should be clear.
I've not treid this but I recall doing something simiar at work when i download php5
 
Hi badley,

you said you modified C:\php\BACKUP\php.ini
I'd say this is not the php.ini file used by
php...(it should be a BACKUP instead).

With phpinfo() you can find out what php.ini
is used by php and then modify that!

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top