connecting to MySQL
Posted by: tribippy (---.clvdoh.adelphia.net)
Date: October 14, 2006 07:54AM

I'm a PHP/MySQL noobie. I have been trying to connect with MySQL. I get the following message:

Fatal error: Call to undefined function mysql_connect() in C:\wamp\www\TagProject\mysql_connect.php on line 2

Here is my code (just a simple exercise). I am not using a password--what looks like one double-quote after [ 'root', ] is actually two single quotes with nothing in between:

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

I saw on a different blog where someone had written: "The error you received is because the install script could not make a connection to the MySQL database. "

Is this really the problem, and how do I fix it? MySQL runs fine, by the way.

Thanks

Options: ReplyQuote
Re: connecting to MySQL
Posted by: nateharper (69.91.34.---)
Date: October 19, 2006 04:42AM

you might try adding a password (something you would want to do if it goes live) and then put it into the mysql_connect so it would be:
$link = mysql_connect('localhost','root','password');

also if 'root' isnt your username. it would prob. give you some problems.

to add another user (with a password, and diffrent username) all you need to do is click on the tray icon then phpmyadmin, Privileges, and after the short table, add new user and pick a username and password. it should work then.

Options: ReplyQuote
Re: connecting to MySQL
Posted by: CyberSpatium (71.237.217.---)
Date: October 20, 2006 09:12PM

he is not getting incorrect user name or incorrect password errors, so that is not the problem nateharper. he is getting the call to undefined function error because he has not enabled support for mysql. In php5, mysql is no longer enabled by default in your php.ini file. but this is easy to fix. you need to edit your php.ini file, and find:

;extension=php_mysql.dll

to enable mysql, remove the semicolon at the beginning of the line above. now save the file, and then restart apache for your new setting to take effect.

Options: ReplyQuote
Re: connecting to MySQL
Posted by: tribippy (---.clvdoh.adelphia.net)
Date: October 21, 2006 05:22AM

CyberStatium, you rock.

Finally, I have been scouring blogs and groups, and found that I need to enable MYSQL in my php.ini file, but could never find precisely where, and how. That is easy.

Thanks
tribippy

Options: ReplyQuote


Sorry, only registered users may post in this forum.