Link to home
Start Free TrialLog in
Avatar of sandshakimi
sandshakimiFlag for United States of America

asked on

Resolve a "Warning: mysqli_fetch_array()...

Here's my code. How to resolve this Warning. The page actually works on my local environment, but doesn't parse when uploaded to dev.

User generated image
 
  <?php 
    define('DB_IP', 'localhost');                   // MySQL Server
    define('DB_USERNAME', 'xxx');       	        //database username
    define('DB_PASSWORD', 'xxx');       		//database password
    define('DB_DATABASE', 'navigator_data');        //database
    
    class test_object   // proxy for web service object
    {
        public $contractVehicle = array(
            0=>'ITSchedule70',
            1=>'ITCommodityProgram',
    	2=>'Army CHESS',
    	3=>'NASA SEWP'
        );
    
        function get_contract()
        {
            return $this->contractVehicle;
        }
    }
    
    $var = new test_object(); // the variable get back from webservice
    
    $connection = mysqli_connect(DB_IP,DB_USERNAME,DB_PASSWORD,DB_DATABASE); // connection to navigator_data
    
    $qry_nav_data = "SELECT * FROM contract_vehicle"; // formulate the SQL query
    
    $result = mysqli_query($connection, $qry_nav_data); // execute the query
    
    // display results in HTML table
    echo "<table border='1'>
    <tr>
    <th>contract_vehicle_id</th>
    <th>vehicle_name</th>
    </tr>";
    
    while($row = mysqli_fetch_array($result)) {
      echo "<tr>";
      echo "<td>" . $row['contract_vehicle_id'] . "</td>";
      echo "<td>" . $row['vehicle_name'] . "</td>";
      echo "</tr>";
    }
    echo "</table>";
    
    mysqli_close($connection);
    ?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Radek Baranowski
Radek Baranowski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial