Jump to content

[SOLVED] unexpected T_VARIABLE


cs1h

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.