Hi, I'm new to PHP.If i execute this code. It shows the warning as

"Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in c:\wamp\www\login_action.php on line 15
Name Address Telephone company"

I don't know how to solve this.

<?php
include 'connection.php';
$uname = $_REQUEST['uname'];//extract($_POST); $uname
$pword = $_REQUEST['pword'];
?>
<table cellpadding=0 cellspacing=0 border=0 width='50%' id='table'>
<tr>
<td> Name</td>
<td> Address</td>
<td> Telephone</td>
<td> company</td>
</tr>
<?php
$result = mysql_query("SELECT * FROM admin WHERE name ='shyloo'");
while($rs = mysql_fetch_assoc($result))
{
	echo "<tr>";
	echo "<td>";
	echo $rs['name'];
	echo "</td>";
	echo "<td>".$rs['address']."</td>";
	echo "<td>".$rs['tele']."</td>";
	echo "<td>".$rs['comp']."</td>";
}
?>

Don't know where exactly the issue is, but that while statement scares me.
The error means that there is something wrong with the query result.
you might also try just setting $rs outside the the while and doing a var_dump($rs) just to see what's there. Maybe the problem is all the way back at the connect.
The while statement is not correct, that will be your next problem.
I find them problematic and I try to avoid using them.

It means your query is failing to execute by some means and there's nothing to fetch at line15.
Try to echo the query and post it here. Directly execute it in the mysql, and post if any error, though it seems to be a simple query,there might be issue for column name or table name not matching

You should indeed check if there is a result before the while to catch this, like so:

$result = mysql_query("SELECT * FROM admin WHERE name ='shyloo'");
if ($result) {
  while($rs = mysql_fetch_assoc($result))
  {
	echo "<tr>";
	echo "<td>";
	echo $rs['name'];
	echo "</td>";
	echo "<td>".$rs['address']."</td>";
	echo "<td>".$rs['tele']."</td>";
	echo "<td>".$rs['comp']."</td>";
  }
}
else {
  // query error
  die (mysql_error());
}

If the query returns zero rows, there is still a resource, although empty, and the while will terminate directly.

check

$result = mysql_query("SELECT * FROM admin WHERE name ='shyloo'");
echo $result;exit;

. is it excute correctly . if results is lessthen zero your query is wrong.

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.