0

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

Edited by tcollins412: n/a

3
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by ko ko
0
$query3="SELECT * FROM selling WHERE name LIKE %item% AND state='$state' LIMIT 0,30"

Where does the '$state' come from ?

0

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();
?>
0
$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";
0

$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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.