cs1h Posted February 1, 2008 Share Posted February 1, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/ Share on other sites More sharing options...
beansandsausages Posted February 1, 2008 Share Posted February 1, 2008 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]'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455150 Share on other sites More sharing options...
pdkv2 Posted February 1, 2008 Share Posted February 1, 2008 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 ! Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455153 Share on other sites More sharing options...
Cep Posted February 1, 2008 Share Posted February 1, 2008 You probably want to interpolate, not concatenate "SELECT * FROM ac_users WHERE username = {$username}"; Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455155 Share on other sites More sharing options...
beansandsausages Posted February 1, 2008 Share Posted February 1, 2008 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 } Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455156 Share on other sites More sharing options...
Cep Posted February 1, 2008 Share Posted February 1, 2008 Gah, time limit seems to be reduced to several seconds so, "SELECT * FROM ac_users WHERE username = '{$username}'"; Forgot to place the single quotes for an obvious string Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455164 Share on other sites More sharing options...
pdkv2 Posted February 1, 2008 Share Posted February 1, 2008 hi cs1h have you tried all these ? Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455167 Share on other sites More sharing options...
cs1h Posted February 1, 2008 Author Share Posted February 1, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455185 Share on other sites More sharing options...
pdkv2 Posted February 1, 2008 Share Posted February 1, 2008 Okey thats good ! Cheers Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455187 Share on other sites More sharing options...
beansandsausages Posted February 1, 2008 Share Posted February 1, 2008 No problem i was right for a change Quote Link to comment https://forums.phpfreaks.com/topic/88868-solved-unexpected-t_variable/#findComment-455190 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.