0

I have the following mysql request in my php file:

 $command = "SELECT weapon_id, weapon_name, weapon_dammage, weapon_munitions FROM weapon;";
 $result = mysqli_query($connection, $command);
 $rows = array();

 while($r = mysqli_fetch_assoc($result)) {
     $rows[] = array(
         'weapon_id' => $r['weapon_id'],
         'weapon_name' => $r['weapon_name'],
         'weapon_dammage' => $r['weapon_dammage'],
         'weapon_munitions ' => $r['weapon_munitions ']
     );
 }

 echo json_encode($rows);

I don't understand why there is nothing returned (I have a blank page). My request is good (tested), and the same code works with anoter request (for example SELECT * FROM player).

Do you know what is the problem and how to solve it?

Thanks a lot!

iAmoric
  • 1,787
  • 3
  • 31
  • 64

1 Answers1

1

Are you using PHP 5.2.0 or higher ? If not, you will have to install the JSON module.

From http://php.net/manual/en/json.installation.php

As of PHP 5.2.0, the JSON extension is bundled and compiled into PHP by default.

You can check your version using phpinfo()

Keyvan
  • 71
  • 4