Jump to content

Function is finding a table that isn't there.


anonymous75178

Recommended Posts

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);

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.