3

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);
Andre Chenier
  • 1,166
  • 2
  • 18
  • 37
  • is your connection good? – Daniel A. White Feb 05 '13 at 19:29
  • 1
    Your query is returning false, which means you have an error. Use `mysqli_error` to get more info. – datasage Feb 05 '13 at 19:30
  • Does the account have sufficient privileges? [MySQL Priv](http://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html) – UnholyRanger Feb 05 '13 at 19:33
  • @datasage oh! I applied mysqli_error($dbc) and my error message is:Unknown column 'kolon_sn' in 'order clause'. I noticed that my column name is different in my db table. thank you for mysqli_error advice. Solved ;) Please add your comment as answer so I can tick as solved. regards – Andre Chenier Feb 05 '13 at 19:39

2 Answers2

0

try to use mysqli_error in your code .

procedural example:

$sorgula = mysqli_query($dbc, "SELECT * FROM tb_yazilar ORDER BY kolon_sn")
           or error_log(mysqli_error($dbc));
Martin
  • 22,212
  • 11
  • 70
  • 132
echo_Me
  • 37,078
  • 5
  • 58
  • 78
0

I used this and it worked: without the if, once it extracts, go back and add the if. :)

require 'db.php';
$query = "SELECT * FROM thoughts";
$result = mysqli_query($conn, $query);
while($row=mysqli_fetch_assoc($result)) {
echo "<td>" . "TEXT: ". $row['text'] . "</td>";
}
mysqli_close($conn);