kate_rose Posted June 16, 2008 Share Posted June 16, 2008 I have found exactly this search but the problem wasn't quite the same in that they were using the variable as the value to test against instead of the variable itself. I just can't seem to figure out how to make this work. Not sure that totally made sense but you will see in my code. It is the query statement that is giving me the error. If I replace the $show_this with actual values contained in the mysql table it works just fine. I have checked to make sure $show_this contains data which is a valid column in my database. The error is: Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\Guana_Plant_Key\browse.php on line 28 <?php foreach ($to_show as $show_this) { // load links or jpeg names from guana_plants db into $picmysql $query = "SELECT "$show_this" FROM guana_plants WHERE "$show_this" <> 'none' AND "$show_this" <> '"$show_this"'"; $result = mysql_query($query); } ?> Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted June 16, 2008 Share Posted June 16, 2008 you need to use the concatenation operator in your $query string... http://www.php.net/language.operators.string Quote Link to comment Share on other sites More sharing options...
kate_rose Posted June 16, 2008 Author Share Posted June 16, 2008 Thanks, This is my first php script so please excuse my ignorance. Kate Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted June 16, 2008 Share Posted June 16, 2008 we all have to start somewhere... : ) 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.