MySQL Forums
Forum List  »  PHP

Query doesn't work on Linux?
Posted by: Mlado Miletins
Date: September 27, 2016 12:23PM

Hey guys, I'm facing a troubling situation with my Slim app. The problem is an MySQL query which works under WAMP local server, however, it doesn't work on a live Linux server. The code follows:

//$tablesAll[] is an array containing the names of several database tables that i need in my query
//some code
foreach ($tablesAll as $tableName)
{
$stmt2 = $this->db->prepare("SELECT col1, col2, col3, col4 FROM {$tableName}");
$stmt2->execute();

$data1 = [];
$data2 = [];
$data3 = [];
$data4 = [];

while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC))
{
$data1[] = $row2['col1'];
$data2[] = $row2['col2'];
$data3[] = $row2['col3'];
$data4[] = $row2['col4'];
}
}
var_dump($data1);
//some code
After investigating i discovered that $data1[] array is empty when i run this on a linux server. var_dump returns NULL. But it works normally on a WAMP server and returns filled array. Also, when i directly hardcode a table name after FROM... it works. So it appears the problem happens to be {$tableName} which somehow doesn't work on a linux server. Does it make any sense?

Thanks!

Options: ReplyQuote


Subject
Written By
Posted
Query doesn't work on Linux?
September 27, 2016 12:23PM
September 27, 2016 02:22PM
September 27, 2016 07:34PM
September 30, 2016 06:03PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.