PDA

View Full Version : Stuck on PHP Video Tutorial - unexpected T_VARIABLE


irock
12-11-2007, 10:33 PM
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 ;)

irock
12-11-2007, 10:41 PM
I found the problem, missing the ;

davidj
12-12-2007, 05:38 AM
remember that error

you will see that allot