From: MikeB on
I have defined (just for testing) a user in my SQL named "pubuser" and
granted it access to a database "publications." Of course I also created
the database and two tables.

I can access and manipulate the tables via phpMyAdmin and I can log in
to sql using pubuser via the command-line interface.

I have the following php code:

<?php // login.php
$db_hostname = 'localhost';
$db_database = 'publications';
$db_username = 'pubuser';
$db_password = 'abc';
?>


also I have a test web page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Connect to SQL</title>
</head>
<body>
<?php
Echo "Hello";
require_once 'login.php';
echo "got require";
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server)
die("Unable to connect to MySQL: " . mysql_error());
echo "Congrats, it seems you have connected to the server <br />
host: $db_hostname<br />
user: $db_username<br />
password: $db_password <br />
for database: $db_database<br />";
print_r($db_server);
?>
</body>
</html>

If I try to run this, it briefly says "connecting to localhost" and then
indefinitely it says "waiting for localhost..."

If I comment out the connect statement, the rest runs. What should I
look for?

Thanks
MikeB

From: Bastien Koert on
On Mon, Sep 20, 2010 at 3:37 PM, MikeB <mpbrede(a)gmail.com> wrote:
> I have defined (just for testing) a user in my SQL named "pubuser" and
> granted it access to a database "publications." Of course I also created the
> database and two tables.
>
> I can access and manipulate the tables via phpMyAdmin and I can log in to
> sql using pubuser via the command-line interface.
>
> I have the following php code:
>
>    <?php // login.php
>    $db_hostname = 'localhost';
>    $db_database = 'publications';
>    $db_username = 'pubuser';
>    $db_password = 'abc';
>    ?>
>
>
> also I have a test web page:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;  charset=UTF-8">
> <title>Connect to SQL</title>
> </head>
> <body>
> <?php
> Echo "Hello";
> require_once 'login.php';
> echo "got require";
> $db_server = mysql_connect($db_hostname, $db_username, $db_password);
> if (!$db_server)
>  die("Unable to connect to MySQL: " . mysql_error());
>  echo "Congrats, it seems you have connected to the server <br />
>       host: $db_hostname<br />
>       user: $db_username<br />
>       password: $db_password <br  />
>       for database: $db_database<br />";
>  print_r($db_server);
>  ?>
> </body>
> </html>
>
> If I try to run this, it briefly says "connecting to localhost" and then
> indefinitely it says "waiting for localhost..."
>
> If I comment out the connect statement, the rest runs.  What should I look
> for?
>
> Thanks
> MikeB
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

If you gave the priv through phpmyadmin, you might want to try running
FLUSH PRIVILEGES to get those new ones to take effect.

--

Bastien

Cat, the other other white meat
From: MikeB on
Bastien Koert wrote:
> On Mon, Sep 20, 2010 at 3:37 PM, MikeB<mpbrede(a)gmail.com> wrote:
>> I have defined (just for testing) a user in my SQL named "pubuser" and
>> granted it access to a database "publications." Of course I also created the
>> database and two tables.
>>
>> I can access and manipulate the tables via phpMyAdmin and I can log in to
>> sql using pubuser via the command-line interface.
>>
>> I have the following php code:
>>
>> <?php // login.php
>> $db_hostname = 'localhost';
>> $db_database = 'publications';
>> $db_username = 'pubuser';
>> $db_password = 'abc';
>> ?>
>>
>>
>> also I have a test web page:
>>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>> <html>
>> <head>
>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>> <title>Connect to SQL</title>
>> </head>
>> <body>
>> <?php
>> Echo "Hello";
>> require_once 'login.php';
>> echo "got require";
>> $db_server = mysql_connect($db_hostname, $db_username, $db_password);
>> if (!$db_server)
>> die("Unable to connect to MySQL: " . mysql_error());
>> echo "Congrats, it seems you have connected to the server<br />
>> host: $db_hostname<br />
>> user: $db_username<br />
>> password: $db_password<br />
>> for database: $db_database<br />";
>> print_r($db_server);
>> ?>
>> </body>
>> </html>
>>
>> If I try to run this, it briefly says "connecting to localhost" and then
>> indefinitely it says "waiting for localhost..."
>>
>> If I comment out the connect statement, the rest runs. What should I look
>> for?
>>
>> Thanks
>> MikeB
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> If you gave the priv through phpmyadmin, you might want to try running
> FLUSH PRIVILEGES to get those new ones to take effect.
>

I did that - in fact, I shut down apache and mysql and restarted then as
well.

 | 
Pages: 1
Prev: Auto-generating HTML
Next: Database Administration