Re: Not bale to connect to MySQL with PHP [message #169650 is a reply to message #169649] |
Tue, 21 September 2010 15:08 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 21/09/10 15:47, MikeB wrote:
> I tried it and it seems to connect to something. I get this:
>
> telnet localhost 3306 and then:
>
>> B
>> 5.1.49-community-lo6IJyD%*☻L9wl8qR&cA[(
>
> and a few seconds later I get:
>
>> Connection to host lost.
>>
>> C:\Users\Mike>
OK, that's almost what happens on my working system, except that I don't
see any text from the mysql connection.
However, I overlooked this:
> <?php
> Echo "Hello";
> require_once 'login.php';
> echo "got require";
You didn't say whether any of these echoes were sent to the browser?
Also, as you're in the document body, it's a good idea to wrap those
echoes in suitable html element tags, eg:
<?php
Echo "<p>Hello</p>";
require_once 'login.php';
echo "<p>got require</p>";
and see what happens if you comment out the database stuff:
/*
$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);
*/
?>
Just to check the underlying php / html functionality.
You could also add the following after 'echo "<p>got require</p>";'
echo "<p>db info: user = '$db_username', host = '$db_hostname', pw =
'$db_password'</p>";
Rgds
Denis McMahon
|
|
|