View Single Post
Old 12-11-2007, 10:33 PM   #1
Join Date: Dec 2007
Posts: 6
Default Stuck on PHP Video Tutorial - unexpected T_VARIABLE

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"

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" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

My connection file looks like this:

$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.


irock is offline   Reply With Quote