Hello,
I have got an error when i run this code.My query is updated but when I fetch the query then i got this error mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\html-contact-form-captcha\update.php on line 44

please check the code is given below:-

****

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table border="1">
<tr>
<th> Name</th>
<th> Active</th>

<th> Last Name</th>
</tr>
<?php 
$id=$_POST['id'];   
$name=$_POST['name'];
$active=$_POST['active'];
$lastName=$_POST['lastName'];

$db=mysql_connect("localhost","root","");
mysql_select_db("new",$db);

echo $qry="update records set name='$name', active='$active', LastName='$lastName' where id='$id' ";

$result=mysql_query($qry);

while($row=mysql_fetch_array($result)){
    echo"<tr>
<td>".$row['name']."</td>
<td>".$row['active']."</td>
<td>".$row['LastName']."</td>

</tr>";  
}
echo mysql_error();

?>
</table>
</body>
</html>

****

Please solve this issue asap...thanks in advance..

Hello,
My query is executed and it is working fine but when i want to print that updated records then i got that error(mysql_fetch_result).

You are running an update query, and pass the return value of mysql_query into mysql_fetch_array.
So, as per the manual text below, you pass a boolean into mysql_fetch_array, not a record set. Hence the error message.

http://php.net/manual/en/function.mysql-query.php

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.

Best,
jwer

In adittion to the ans by @jwer, what you need now is a SELECT query which will fetch data from your updated table.

thank you for your reply . I got the point and it is working fine.

use select query to get data set from your corresponding table.

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.