php mysql_fetch_array() error
Posted
by
user1877823
on Stack Overflow
See other posts from Stack Overflow
or by user1877823
Published on 2012-12-14T10:18:52Z
Indexed on
2012/12/14
11:04 UTC
Read the original article
Hit count: 122
I am getting this error while i am trying to delete a record the query is working but this line remains on the page. i want to echo "Deleted" written in the while should show up but the while loop is not working, i have tried and searched alot nothing helps!
mysql_fetch_array() expects parameter 1 to be resource, boolean given in delete.php on line 27
delete.php
<html>
<body>
<form method="post">
Id : <input type="text" name="id">
Name : <input type="text" name="name">
Description : <input type="text" name="des">
<input type="submit" value="delete" name="delete">
</form>
<?php
include("connect.php");
$id = $_POST['id'];
$name = $_POST['name'];
$des = $_POST['des'];
$result = mysql_query("DELETE FROM fact WHERE id='$id'") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "Deleted";
}
mysql_close($con); ?>
</body>
</html>
connect.php
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Dataentry", $con);
?>
How should i make the while loop work..
© Stack Overflow or respective owner