-1

I'm trying to get data from a MySQL database and I get:

Fatal error: Call to a member function execute() on a non-object in Line 79...

on this line:

$stmt->execute();

I'm just trying to get this: enter image description here

and more specifically the left data cell (very right of pic) that is an int(5).

Here's what I have:

$query = "SELECT left FROM members WHERE id=$uid";

$stmt = $mysqli->prepare($query); 

    $stmt->execute();
    $stmt->bind_result($left);
    $stmt->fetch();
    echo "Left: $left";
    $stmt->close();

Funny thing is, when I change SELECT left to something like SELECT username, I get the username cell back as expected, but for left I get the error.

George Cummins
  • 28,485
  • 8
  • 71
  • 90
test
  • 17,706
  • 64
  • 171
  • 244

2 Answers2

2

Add quotes:

SELECT `left` FROM `members` WHERE id=$uid
Atber
  • 465
  • 2
  • 5
-1

Try

$query = "SELECT `left` FROM members WHERE id=$uid";

to avoid reserved keyword problem.

Edit:

Including comment from Your Common Sense to link

http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html

wazy
  • 1,065
  • 1
  • 10
  • 23