Andre Chenier Andre Chenier - 2 months ago 8
MySQL Question

Why can not I fetch data from mysql db table with mysqli_query?

I am at prototype stage so I have

error_reporting(-1);
at my 1st row. Despite this, I have no php error but php prints 'could not get data'.

As I understood from php.net manual and stackoverflow similar cases, my $sorgula returns FALSE.

But why? Can you help, regards

//i am sure that i am connected to db
if ($sorgula = mysqli_query($dbc, "SELECT * FROM tb_yazilar ORDER BY kolon_sn"))
{
while ($satir = mysqli_fetch_array($sorgula, MYSQLI_ASSOC))
{
echo $satir['kolon_yazar'].' - '.$satir['kolon_baslik'].' - '.$satir['kolon_yazi'].' - '.$satir['kolon_etiketler'].' - '.$satir['kolon_ytarihi'].' - - - - ';
}
}
else
{
echo 'could not get data';
}

mysqli_close($dbc);

Answer

try use mysqli_error in your code .