0

i have tried every method i could find. But nothing would fix this problem. Here is the code

<?php                   
$sql = "SELECT item_name, item_img, item_price FROM item";
$result = mysql_query($sql) or die (mysql_error());

?>
<ul>
<?php
while($row = mysqli_fetch_array($result));  
    {
    echo '<li>', $row['item_name'],  '</li>';
        echo '<li>', $row['item_img'],  '</li>';
        echo '<li>', $row['item_price'],  '</li>';

?>
</ul>
z33m
  • 5,873
  • 1
  • 30
  • 42

1 Answers1

0

You are mixing mysqli_ and mysql_ functions.

You may try:

$result = mysqli_query($your_connection, $sql);
while($row = mysqli_fetch_array($result));  
{
 ...
}

You are also missing the closing bracket on your while loop.

MillaresRoo
  • 3,717
  • 1
  • 31
  • 36
  • can you please tell me where to add the function because i have tried and got same error – user3060908 Jan 08 '14 at 22:06
  • Change your mysql_query with mysqli_query and close the while loop properly. Look at my edit. – MillaresRoo Jan 08 '14 at 22:09
  • i did everything you say however the number of error increase to 2 Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\21178250.php\index.php on line 37 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\21178250.php\index.php on line 38 – user3060908 Jan 08 '14 at 22:19
  • Could you show your connection code? Also, have you checked your sql directly against the database? – MillaresRoo Jan 08 '14 at 22:23
  • my connection to the database in a different page – user3060908 Jan 08 '14 at 22:27
  • Ouch! You are using mysql_ functions here too! You must use mysqli_connect: http://es1.php.net/mysqli_connect and forget about mysql_select_db – MillaresRoo Jan 08 '14 at 22:30
  • Also, using @ as an error suppressor is not the best for debugging. – MillaresRoo Jan 08 '14 at 22:32
  • And better, don't show your passwords here. – MillaresRoo Jan 08 '14 at 22:33
  • thanks MillaresRoo it is just if i remove the @ it will display more error and it will display cant connect to database. however; when i put it back. same errors is removed – user3060908 Jan 08 '14 at 22:43