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); ?> Link to comment https://forums.phpfreaks.com/topic/280232-php-expect-parameter/ 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. Link to comment https://forums.phpfreaks.com/topic/280232-php-expect-parameter/#findComment-1441032 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? Link to comment https://forums.phpfreaks.com/topic/280232-php-expect-parameter/#findComment-1441034 Share on other sites More sharing options...
0xMatt Posted July 17, 2013 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)) Link to comment https://forums.phpfreaks.com/topic/280232-php-expect-parameter/#findComment-1441035 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 Link to comment https://forums.phpfreaks.com/topic/280232-php-expect-parameter/#findComment-1441036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.