Page 1 of 1

Connect.php whats wrong?

Posted: Tue Feb 21, 2012 11:32 pm
by nilesa12
my connect.php code looks like this:

<?php

$db = mysql_connect ("localhost,"root","") or die ("could not connect to db");
if (!$db)
die ("no db");
if (!mysql_select_db("tutorial",$db))
die("No database selected");

?>
and for some reason it says there is a parsing error on line three when i try to run my registration.php (yes im following the guide on youtube)




I need help ASAP

( ! ) Parse error: syntax error, unexpected T_STRING in C:\wamp\www\Tutorial\Connect.php on line 3
Call Stack
# Time Memory Function Location
1 0.0007 362768 {main}( ) ..\Register.php:0

This is the error i get

Re: Connect.php whats wrong?

Posted: Tue Feb 21, 2012 11:38 pm
by SpiritWebb

Code: Select all

<?php

$db = mysql_connect ("localhost,"root","") or die ("could not connect to db"); //missing quote after localhost
if (!$db)
die ("no db");
if (!mysql_select_db("tutorial",$db))
die("No database selected");

?>
Your missing a quote:

Try

Code: Select all

<?php

$db = mysql_connect ("localhost","root","") or die ("could not connect to db");
if (!$db)
die ("no db");
if (!mysql_select_db("tutorial",$db))
die("No database selected");

?>

Re: Connect.php whats wrong?

Posted: Tue Feb 21, 2012 11:40 pm
by nilesa12
wow thanks man


sorry i was being to quick to ask for outside help because im a loser!

Re: Connect.php whats wrong?

Posted: Tue Feb 21, 2012 11:41 pm
by SpiritWebb
No worries, moving post to correct section.