Search code examples
loopsmysqlivarchar

Mysqli column shortening


I just uploaded my game and it was working great in Wamp. Now, when I run it on the main website it shortens "names" of rows in tables to just be the first letter?

The code is simple to do it

$id = 0;
$stmt->prepare("SELECT name,id FROM `users` WHERE id > ?");
$stmt->bind_param('i',$id);
$stmt->execute();
$stmt->bind_result($name,$id);
while($r = $stmt->fetch()) {
echo $id." : ".$name."<br>";
}

It outputs
1 : A
2 : A
3 : n
4 : T
5 : R
6 : M
7 : R

EDIT

I figured it out!

$stmt->store_result();

Needs to go after

$stmt->execute();

If you plan to fetch the row. Hope this helps someone.

EDIT

Thank you.


Solution

  • I figured it out!

    stmt->store_result();
    

    Needs to go after

    $stmt->execute();
    

    If you plan to fetch the row. Hope this helps someone.