Connect.php whats wrong?

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
nilesa12
Posts: 4
Joined: Tue Feb 21, 2012 11:24 pm

Connect.php whats wrong?

Post 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
Last edited by nilesa12 on Tue Feb 21, 2012 11:39 pm, edited 1 time in total.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Connect.php whats wrong?

Post 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");

?>
Image

Image
nilesa12
Posts: 4
Joined: Tue Feb 21, 2012 11:24 pm

Re: Connect.php whats wrong?

Post by nilesa12 »

wow thanks man


sorry i was being to quick to ask for outside help because im a loser!
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Connect.php whats wrong?

Post by SpiritWebb »

No worries, moving post to correct section.
Image

Image
Post Reply

Return to “Beginner Help and Support”