PHP error mysql_fetch_array(): supplied argument is not a valid MySQL result resource [duplicate]

StackOverflow https://stackoverflow.com/questions/14513331

  •  17-01-2022
  •  | 
  •  

Question

I am stuck in a very basic sql query scrip. Mybe someone can notice what I am unable to see. I have checked that the sql query is working fine when it is executed from mysqladmin:

 <?
 include ('gps_db_connect.php'); 
 $query = "SELECT * from gps WHERE server_time > '20130124'";
 echo $query;
 $result = mysqli_query($connection, $query) or die(' Error getting data'); 
 echo '    After query';
 while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
  {   
   echo $row['server_time'];
  }

 ?>

Here is the screen display/output:

SELECT * from gps WHERE server_time > '20130124' After                      
query
PHP Error Message 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a9440109/public_html/test.php on line 7
Was it helpful?

Solution

try this

 $result = mysql_query($query, $connection) or die('Error');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top