I have seen a couple solutions to this problem but none have worked so far.

here is the error.
Fatal error: Call to undefined function mysql_connect() in C:\wamp\www\login.php on line 12

and the code

// connect to the mysql server
$link = mysql_connect(localhost, root, admin)
or die ("Could not connect to mysql because ".mysql_error());

// select the database
or die ("Could not select database because ".mysql_error());

$match = "select id from members where username = '".$_POST['username']."'
and password = '".$_POST['password']."';"; 

$qry = mysql_query($match)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry); 

if ($num_rows > 0) {
setcookie("loggedin", "TRUE", time()+(3600 * 24));
setcookie("mysite_username", "$username");
echo "You are now logged in!<br>";
echo "Continue to the <a href=members.php>members</a> section.";
else {
echo "Sorry, there is no username: $username with the specified password.<br>";
echo "<a href=login.html>Try again</a>";

now does it make a difference that I am using WAMP server instead of having just configured the php and mysql by hand. It worked yesterday now today nothing.

12 Years
Discussion Span
Last Post by ashishanand

Not sure this is the solution, but you do not quote the value for your variables.

// connect to the mysql server
$link = mysql_connect('localhost', 'root', 'admin')
or die ("Could not connect to mysql because ".mysql_error());

// select the database
or die ("Could not select database because ".mysql_error());

yea it had something to do with my php setup so i reinstalled WAMP and just added in my backup files so pretty much i just replaced php and its extensions.



I have been struggling with this for two days now !!!

And here is what the problem on my machine was:

In httpd.conf (in the conf folder of my Apache installation), the path to php.ini was incomplete, so i corrected it like so:

PHPIniDir "C:\Program Files (x86)\PHP\"

AND it miraculously worked !! (it is NOT to be believed :D had started thinkin this thing AINT made to be workin at all!!)



tanya_ivanova, your posting helped me solve the problem. The path in the PHPIniDir was not correct. I change it and it worked. Thanks a lot


tanya_ivanova thank you so much I have been searching for this solution for over a day now

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.