php - Warning: mysql_fetch_array() expects parameters 1 to be resource, -


**

this question has answer here:

mysql_fetch_array() expects parameter 1 resource (or mysqli_result), boolean given 31 answers 

hi im trying write data database , code thats meant doing 2 of 'warning: mysql_fetch_array() expects parameter 1 resource, boolean given' , dont know why???? **

     <?php     $connection = mysql_connect("localhost", "root", "");  // establishing connection server     $db = mysql_select_db("burger machine", $connection);  // selecting database      //mysql query read data      $query = mysql_query("select * add", $connection);        while ($row = mysql_fetch_array($query)) {      echo "<tr>";     echo " <td> {$row['addons_id']} </td>";     echo " <td> <a href=\"ao.php?update={$row['addons_id']}\"> {$row['addons_name']} </a> </td> ";     echo " <td> {$row['addons_price']} </td> ";     echo " <td> {$row['addons_description']} </td>";     echo "</tr>";      } 

use mysqli mysql deprecated , prone sql injections.

use mysqli_query($con , $query);

where $query sql query fetch data , $con connection resource variable.

on side note

in mysql_query(); pass query parameter, not connection.

<?php     $connection = mysqli_connect("localhost", "root", "");  // establishing connection server     $db = mysqli_select_db( $connection , "burger machine" );  // selecting database      //mysql query read data      $query = mysqli_query( $connection , "select * add" );        while ($row = mysqli_fetch_array($query)) {      echo "<tr>";     echo " <td> {$row['addons_id']} </td>";     echo " <td> <a href=\"ao.php?update={$row['addons_id']}\"> {$row['addons_name']} </a> </td> ";     echo " <td> {$row['addons_price']} </td> ";     echo " <td> {$row['addons_description']} </td>";     echo "</tr>";     } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -