0
I made a class for connection to the database using PDO and at the time I will get the data from my table it gives this error.
This is the code:
require_once('../class/connection.class.php');
$db = conection::getInstancia();
$query = $db->query("SELECT * FROM". conection::getTabela('TB_ARQUIVOS'));
foreach($query->fetchAll(\PDO::FETCH_ASSOC) as $arquivo){
echo $arquivo['Codigo'];
}
He of the error in the foreach line
This error happens when there is some error in sql, what I noticed was that the
from
is pasted with the table name. Try to print the query and test directly in the database.– rray
I used the 'var_dump' function to find out the error, I had forgotten to put information, in the PDO object.
– Meeeefiu
Can you add the solution in more detail in response form in the field below? So content can help future visitors to the site. Thank you!
– bfavaretto
The error may be a wrong syntax in sql
– Rafael Buçard