i am writing code and i keep getting the error: mysql_fetch_array: supplied arguement is not a valid mysql resource. here is the code:

<?php
			include"dbconnect.php";
			$item=$_POST['item'];
			$query3="SELECT * FROM selling WHERE name LIKE %item% AND state='$state' LIMIT 0,30";
		    $result3 = mysql_query($query3);
			while($item = mysql_fetch_array($result3)){
              echo "<img src='$item[pic]' alt='pic'><a style='color: white;' href='?goto=viewitem&id=$item[id]>",$item['name'];
			  ?> 
			  </td><td style='width: 20px;'></td><td style='color: white;'><?php echo $item['price']," | ",$item['date']," | ",$item['email']; ?>
			  </td></tr>
			  <?php
			}
			  mysql_close();
			  ?>

i think its something wrong with the query, but im not sure

$query3="SELECT * FROM selling WHERE name LIKE %item% AND state='$state' LIMIT 0,30"

Where does the '$state' come from ?

i have this at the top:

<?php
include "dbconnect.php";
$email = $_COOKIE['user'];
$pass = md5($_COOKIE['pass']);
$query = "SELECT * FROM members WHERE email='$email' AND password='$pass'";
$result = mysql_query($query);
$row=mysql_fetch_array($result);
$id=$row['id'];
$state=$row['state'];
mysql_close();
?>
Member Avatar for brewbuff
$query3="SELECT * FROM selling WHERE name LIKE %item% AND state='$state' LIMIT 0,30";

Suspect name argument should be in quotes as in:

$query3="SELECT * FROM selling WHERE name LIKE '%item%' AND state='$state' LIMIT 0,30";

$row=mysql_fetch_array($result);
$id=$row;
$state=$row

Echo the values ($id, $state) first. It should better with

while($row=mysql_fetch_array($result)){
$id=$row['id'];
$state=$row['state'];
}

Hope this help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.