i have to tell you this is based on a very simple php theory but it is not simple as it appears.
this is the scenario
I have 10 tables known as(table_1,table_2,table_3 etc), currently i want get the result set of each of those tables inside a loop. so in order to fullfill my requirement when i use the below code it returns an error
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
The Code
$table_count = mysql_query("SELECT TABLE_NAME FROM information_schema.tables WHERE
table_schema = 'milepostdb' AND table_name LIKE 'table_%' ");
while($row = mysql_fetch_array($table_count)){
$table = $row["TABLE_NAME"];
$excute = mysql_query("CALL Dummy_2('$table')");
$result = mysql_fetch_assoc($excute);//line which triggers the error
var_dump($result);
}
But if i just hard code a table name and put it it works fine
$var = 'table_1';
$excute = mysql_query("CALL Dummy_2('$var')");
$result = mysql_fetch_assoc($excute);
var_dump($result);
or
$excute = mysql_query("CALL Dummy_2('table_1')");
$result = mysql_fetch_assoc($excute);
var_dump($result);
both the above codes works well.
Now can any body tell why does the variable that is passed through $table = $row["TABLE_NAME"]; returns an error when normal variable that is assigned works fine. whats the difference between the two approaches???