anonymous75178 Posted March 9, 2010 Share Posted March 9, 2010 I've written this simple function that is taking array values and searching two tables to see if they exist. The first one is having the issue, "SHOW TABLES LIKE" None of the values exist in the database except apple, yet they are all coming back true. The second query "SELECT * FROM stocknames is working correctly. $symbols = array('apple','joe','steve','adsffds'); function checkStockNames($symbols) { if(is_array($symbols)) { echo "<p>This is an array</p>"; foreach($symbols as $symbol) { if(mysql_query("SHOW TABLES LIKE '".$symbol."'")) { $query = mysql_query("SELECT * FROM stocknames WHERE symbol = '{$symbol}'"); if($data = mysql_fetch_assoc($query)) { echo "<p>{$symbol} is {$data['name']}</p>"; } else { echo "<p>{$symbol} does not have name information.</p>"; } } else { echo "<p>{$symbol} does not have a table in the database.</p>"; } } } else { echo "<p>This is not an array</p>"; } } checkStockNames($symbols); Link to comment https://forums.phpfreaks.com/topic/194573-function-is-finding-a-table-that-isnt-there/ Share on other sites More sharing options...
anonymous75178 Posted March 9, 2010 Author Share Posted March 9, 2010 Fixed it with mysql_query("SELECT * FROM `{$symbol}`") Link to comment https://forums.phpfreaks.com/topic/194573-function-is-finding-a-table-that-isnt-there/#findComment-1023297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.