I am following Kevin Yank’s online version of “Build your own Database Driven Website using PHP & MySQL”. So far, I have been able to connect to MySQL and create the joke database. PHP also seems to be working fine.
The problem comes when I try to publish MySQL data on the web. I am using the code suggested at
This is the first part of the code:
<?php
// Connect to the database server
$dbcnx = @mysql_connect('localhost', 'root', 'mypasswd');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
// Select the jokes database
if (!@mysql_select_db('ijdb')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}
?>
When I try to connect as root, using the password I’ve been using to connect to MySQL, this error message comes up: “unable to connect to the database server at this time”.
However, when I try to connect as another user, which I’ve created on MySQL, the error message I get is: “unable to locate the joke database at this time”.
Sorry, not sure what you mean. The results were two columns: host and case when password …etc.
Under the first column; localhost and 127.0.0.1. Under the second column; 1 and 1.
When I initially typed in the results, then previewed the post, it deleted all the “multiple spaces” - making the columns look out of line. So, yes, there was a space after host, but that was deleted. Is that what you mean?
no, i was talking about “local host”, which should be “localhost”.
try this, log in to mysql and issue this command: GRANT ALL ON . TO ‘root’@‘localhost’, ‘root’@‘127.0.0.1’ WITH GRANT OPTION
caution: if this isn’t your server, you administrator will be very mad if they set it up specifically to not give these types of privilege to the root user.