i don't know what is that error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1
any help please?
<?php
//Connecting to sql db.
if(!($database=mysql_connect("localhost", "root", "") ))
die(mysql_error());
if(!mysql_select_db("Ehab",$database) )
die(mysql_error());
//Sending form data to sql db.
if(isset($_POST["websites"]))
//html klma
$sitesphp=$_POST["websites"];
if(isset($_POST["description"]))
$descriptionphp=$_POST["description"];
$query= "INSERT INTO website (sites, des) VALUES ('$sitesphp','$descriptionphp')";
//take query and then put it down
//in result
if(!($result=mysql_query($query,$database)))
{
print("etla3 bara ya homar");
die(mysql_error());
}?>
<html>
<head>
<meta charset="utf-8">
<title>Database Update</title>
</head>
<body>
<h1>Database successfully updated.</h1>
<table>
<tr>
<th>URL</th><th>description</th>
</tr>
<?php
//error occurs here
if ( !( $result = mysql_query( "SELECT sites,des FROM website", $database ) ) )
{
print( "<p>Could not execute query!</p>" );
die( mysql_error() );
}
mysql_close( $database );
while ( $row = mysql_fetch_row( $result ) )
print( "<tr><td>" . $row[ 0 ] . "</td><td>" . $row[ 1 ] . "</td></tr>" );
?>
</table>
</body>
</html>
I would not place the
mysql_fetch_row()
after
mysql_close()
because I guess the result is empty after closing the connection. Perhaps this is also the origin for the "missing resource" as it is already closed.
Btw as far as I remember the error comes from the SQL not from the php so line 1 is not line 1 of the php file but the line 1 of the SQL statement.