masgas Posted June 18, 2007 Share Posted June 18, 2007 I have this code. I get the message: Parse error: syntax error, unexpected T_STRING in /home/..../test.php on line 7 any ideas why??? $con = mysql_connect ('','','') or die ("no con"); @mysql_select_db ('$db_name') or die ('error DB'); $col = array('1'=>RED, '2'=>GREEN, '3'=>BLUE, '4'=>BROWN); foreach ($col as $key => $value){ $sql= "SELECT $value FROM users WHERE nick = '$_SESSION[nick]'"; $res= mysql_query($sql) or die mysql_errno($sql); while ($row=mysql_fetch_assoc($res)){ if ($row[$valor]!=''){$var= $row[$valor];} echo $var; } } ?> Quote Link to comment Share on other sites More sharing options...
benjaminbeazy Posted June 18, 2007 Share Posted June 18, 2007 your query is messed up, echo $sql and see what it looks like Quote Link to comment Share on other sites More sharing options...
masgas Posted June 18, 2007 Author Share Posted June 18, 2007 Hi this is what it echoes! SELECT RED FROM users WHERE nick = 'LEVC'SELECT GREEN FROM users WHERE nick = 'LEVC'SELECT BLUE FROM users WHERE nick = 'LEVC'SELECT BROWN FROM users WHERE nick = 'LEVC' Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 18, 2007 Share Posted June 18, 2007 Change this line: $res= mysql_query($sql) or die mysql_errno($sql); To This: $res= mysql_query($sql) or die (mysql_errno($sql)); Quote Link to comment Share on other sites More sharing options...
masgas Posted June 18, 2007 Author Share Posted June 18, 2007 ok... that worked just fine! thank you Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 18, 2007 Share Posted June 18, 2007 No problem Don't forget to click the solved button on the bottom left corner. Quote Link to comment 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.