Jump to content

Parse error: syntax error, unexpected T_VARIABLE


iRock

Recommended Posts

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

Link to comment
Share on other sites

<?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 ;)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.