Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShon Levi
6,036 PointsCan't prepare with mysqli!
hey you all,
I tried to make some prepare query but it won't working:
$user_id = 1;
$result = $db->prepare("SELECT * FROM users WHERE id = ?");
$result->bind_param('i', $user_id);
$result->execute();
When I var_dump it that's what I get:
object(mysqli_stmt)[2]
public 'affected_rows' => int -1
public 'insert_id' => int 0
public 'num_rows' => int 0
public 'param_count' => int 1
public 'field_count' => int 3
public 'errno' => int 0
public 'error' => string '' (length=0)
public 'error_list' =>
array (size=0)
empty
public 'sqlstate' => string '00000' (length=5)
public 'id' => int 1
What can be the problem?! (When I make it with query and put manually 1 it working...)
1 Answer
jcorum
71,830 PointsCould it have anything to do with the id = ? in your SQL query:
$result = $db->prepare("SELECT * FROM users WHERE id = ?");
I know the DBMS I use would complain.