Aido89 Posted July 17, 2013 Share Posted July 17, 2013 Hi I am getting the error below; Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in C:\xampp\htdocs\getuser.php on line 17 See below the code i am using, i also have an ajax file for this but that is working 100% the issue lies in the code below. Any ideas? <?php $q=$_GET["q"]; $con = mysqli_connect('localhost','root','','db'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"db"); $sql="SELECT * FROM db WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['item'] . "</td>"; echo "<td>" . $row['description'] . "</td>"; echo "<td>" . $row['price'] . "</td>"; echo "<td>" . $row['category'] . "</td>"; echo "<td>" . $row['paypal'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> Quote Link to comment Share on other sites More sharing options...
kicken Posted July 17, 2013 Share Posted July 17, 2013 you can't mix mysqli_* functions and mysql_ functions. Since you connect and query with mysqli_ functions, you need to fetch the results using those functions also. Quote Link to comment Share on other sites More sharing options...
Aido89 Posted July 17, 2013 Author Share Posted July 17, 2013 Would you have any suggestions regarding coding examples I can use to rectify this? Quote Link to comment Share on other sites More sharing options...
Solution 0xMatt Posted July 17, 2013 Solution Share Posted July 17, 2013 kicken is saying that you need to change this: while($row = mysql_fetch_array($result)) to this: while($row = mysqli_fetch_array($result)) Quote Link to comment Share on other sites More sharing options...
Aido89 Posted July 17, 2013 Author Share Posted July 17, 2013 kicken is saying that you need to change this: while($row = mysql_fetch_array($result)) to this: while($row = mysqli_fetch_array($result)) Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.