Quote:
Originally Posted by astrogeek
Your PHP is not valid code, the "or" cannot follow the closing ";" of the previous line.
Try this...
Code:
<?php
$hostname = "localhost";
$username = "user";
$password = "abc123";
// Create connection to the database
$dbhandle = mysql_connect($hostname, $username, $password);
if(!$dbhandle){die("unable to connect to MySQL");}
echo "connected to MySQL";
?>
|
thanks for the attention to detail, you know in this line of business, you have to have attention to detail and every little symbol counts. your right my code is not valid.
Code:
<?php
$hostname = "127.0.0.1";
$username = "user";
$password = "abc123";
// Create connection to the database
$dbhandle = mysql_connect($hostname, $username, $password); < --- typo error I should look at the code more carefully
or die ("unable to connect to MySQL");
echo "connected to MySQL";
?>
I took the semi-colon out and it works perfectly fine now. But initially, I did get that could get that could not connect error which was fixed by giving permissions to the USER in MySQL.
Code:
<?php
echo "rule #1 in PHP attention to detail, rule#2 attention to detail, rule#3 attention to detail";
?>
Thanks all for the help. I am grateful to you my friend (AstroGeek).
Now next step to learning more about PHP and MySQL
take care.