iRock Posted December 11, 2007 Share Posted December 11, 2007 Anyone able to help me on this. I'm just following a basic video tutorial, I'm new to PHP. I've checked my code and passwords etc over and over again. When I preview I get "Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\Local Root\Test\dwc.php on line 5" <?php require_once("Connections/connection.php") // database connection ////////////////////////////////////////////////////////////// $query = sprintf('SELECT * FROM table1'); $result = @mysql_query($query); $row = mysql_fetch_array($result); ///////////////////////////////////////////////////////////// echo $row['field2']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> My connection file looks like this: <?php ////////////////////////////////////////////// $database = "dwc"; $username = "shane"; $password = "I put my password here"; ///////////////////////////////////////////// $link = @mysql_connect('localhost', $username, $password); $db = @mysql_select_db($database, $link); ?> Any help would be greatly appreciated. I'm guessing that the problem is with the "sprintf" - but I'm not sure. I've messed around for a while now trying to fix it but no luck yet. Thanks iRock Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 11, 2007 Share Posted December 11, 2007 <?php require_once("Connections/connection.php"); just need a semi-colon there... PhREEEk Quote Link to comment Share on other sites More sharing options...
JacobYaYa Posted December 11, 2007 Share Posted December 11, 2007 missing ; at the end of your require_once() first line Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 11, 2007 Share Posted December 11, 2007 Jacob, When you post an answer, you should see a red warning that another post has gone up while you were typing and allow you to review that newer post. It helps prevent identical answers... PhREEEk Quote Link to comment Share on other sites More sharing options...
iRock Posted December 11, 2007 Author Share Posted December 11, 2007 <?php require_once("Connections/connection.php"); just need a semi-colon there... PhREEEk Thanks very much - I'm pretty new to PHP. The thing that worries me is that it never occured to me that I left it out after looking over the code several times. At least I'll know for the future! +1 Quote Link to comment Share on other sites More sharing options...
revraz Posted December 12, 2007 Share Posted December 12, 2007 Two answers is better than none. Jacob, When you post an answer, you should see a red warning that another post has gone up while you were typing and allow you to review that newer post. It helps prevent identical answers... PhREEEk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.