Jump to content

Recommended Posts

Hi,

 

I have a short bit of code which keeps coming up with the error,

Parse error: syntax error, unexpected T_VARIABLE in D:\Inetpub\vhosts\mjfdskkoho.com\httpdocs\test_form_check.php on line 10

 

The code is

<?php 
if(isset($_COOKIE['loggedin']))
{
include (config.php);

$username = ($_COOKIE[loggedin]);

mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 

$result = mysql_db_query($database, 'select * from ac_users WHERE username = '$username'') or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
      echo '$qry[name1]'; 
   } 


?>

 

Can anyone help?

 

All help is much appreciated,

 

Cheers

Colin

Link to comment
https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/
Share on other sites

Try :

 


<?php 
if(isset($_COOKIE['loggedin']))
{
include (config.php);

$username = ($_COOKIE[loggedin]);

mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 

$result = mysql_db_query($database, 'select * from ac_users WHERE username = '$username'') or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
      echo '$qry[name1]'; 
   } 

}
?>

You have an error in sql query

 

'select * from ac_users WHERE username = '$username''

 

change this to

 

 

"select * from ac_users WHERE username = '". $username ."'"

 

 

Cheers !

 

the error T_VARIABLE mean missed } some were off the script some were, he started the scrpt with a if statment :

<?php 
if(isset($_COOKIE['loggedin']))
{
include (config.php);

and he never closed the statment with a  }

Hi,

 

Thanks for the replies, its working know,

 

The new code is

<?php 
if(isset($_COOKIE['loggedin']))
{
include ('config.php');

$username = ($_COOKIE[loggedin]);

mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 

$result = mysql_db_query($database, "select * from ac_users WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
   $name = $qry['name1'];
   $horde = $qry['horde'];
      echo $name; 
   } 

}
?>

 

Cheers

Colin

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.