Jump to content

[SOLVED] foreach error


masgas

Recommended Posts

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;

}

}

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/56004-solved-foreach-error/
Share on other sites

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.