0

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

4
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by thilipdilip
0

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

0

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

0

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

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.