Thursday, July 30, 2009

I Can't Connect to MySQL through Apache Server?

I am running the latest versions of Apache, PHP and MySQL and PHP and Apache work fine. But when I try to connect to MySQL i get this error: Parse error: syntax error, unexpected T_STRING in C:\ Apache2\ htdocs\ mysqltest.php on line 9. The document i am using is: %26lt;html%26gt;


%26lt;head%26gt;


%26lt;title%26gt;MySQL Test%26lt;/title%26gt;


%26lt;/head%26gt;





%26lt;body%26gt;


%26lt;h2%26gt;


%26lt;?php


$connection = mysql_connect("localhost", "root", "")





or die ("Sorry - Unable to connect to MySQL" );





echo ("Congratulations - Connected to MySQL");





?%26gt;





%26lt;/h2%26gt;


%26lt;/body%26gt;


%26lt;/html%26gt;


I am following PHP in easy steps and I can't figure out the problem.


Can anybody help? Thanks so much.

I Can't Connect to MySQL through Apache Server?
It's been awhile since I've done PHP, so forgive me if I am wrong. But I did notice you are missing a ; in your syntax





$connection = mysql_connect("localhost", "root", "")


should be


$connection = mysql_connect("localhost", "root", "");


??








Edit:





Trying this





or die ("Sorry \- Unable to connect to MySQL" );





echo ("Congratulations \- Connected to MySQL");





I believe the script sees the - an an operator. If I remember right \ will flagg it as text





Edit





Errr.... try / instead of \ perhaps

flower show

No comments:

Post a Comment