Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This question already has an answer here:

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
share|improve this question
 
Look to your right --> –  John Conde Jan 25 at 0:31

marked as duplicate by Jocelyn, Ocramius, PeeHaa, hakre, Madara Uchiha Apr 23 at 19:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 0 down vote accepted

try this

 $result = mysql_query($query, $connection) or die('Error');
share|improve this answer
 
Great Thanks! Somehow I did not see that. –  user1834682 Jan 25 at 0:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.