Hi guys,
I was trying a login-member system from a book I bought
but after creating the database and filling in the register form,
I receive this warning all the time:
Warning: mysqli::mysqli() [function.mysqli-mysqli]: (HY000/2003): Can't connect to MySQL server on 'localhost' (10061) in C:\Users\Jan\Desktop\UsbWebserver\UsbWebserver\Root\test\db_fns.php on line 5
Warning: mysqli::query() [function.mysqli-query]: Couldn't fetch mysqli in C:\Users\Jan\Desktop\UsbWebserver\UsbWebserver\Root\test\user_auth_fns.php on line 13
This is db_fns.php:
function db_connect()
{
$result = new mysqli('localhost', 'user', 'pass', 'bookmarks');
if (!$result)
throw new Exception('Could not connect to database server');
else
return $result;
}
And this is the part of user_auth_fns.php:
// connect to db
$conn = db_connect();
// check if username is unique
$result = $conn->query("select * from user where username='$username'");
if (!$result)
throw new Exception('Could not execute query');
if ($result->num_rows>0)
throw new Exception('That username is taken - go back and choose another one.');
// if ok, put in db
$result = $conn->query("insert into user values
('$username', sha1('$password'), '$email')");
if (!$result)
throw new Exception('Could not register you in database - please try again later.');
return true;
}
Now, I also think that the problem could be the book:
Webdevelopment 3th edition by Luke Welling and Laura Thompson,
It dates from more than 6 years ago.
Any help would be appreceided
Thank you,