I am getting the following error at the line
mysql_free_resu lt($result);
Warning: Supplied argument is not a valid MySQL result resource in
/var/www/html/php/phoneadd.php on line 27
My code is as follows:
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect(" localhost", "", "")
or die("Could not connect : " . mysql_error());
mysql_select_db ("test",$db) ;
$sql = "INSERT INTO phone (fname,lname,st reet,h_phone) VALUES
('$fname','$lna me','$street',' $h_phone')";
$result = mysql_query($sq l);
echo "Thank you! Information entered.\n";
/* Free resultset */
mysql_free_resu lt($result);
/* Closing connection */
mysql_close($db );
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<table>
<tr>
<td>First name: </td><td><input type="Text" name="fname"></td>
</tr>
<tr>
<td>Last name: </td><td> <input type="Text" name="lname"></td>
</tr>
<tr>
<td>Address: </td><td><input type="Text" name="street"></td>
</tr>
<tr>
<td>Home Phone:</td><td> <input type="Text" name="h_phone"> </td>
</tr>
<tr>
<td></td><td> <input type="Submit" name="submit" value="Enter information">
</td>
</tr>
</table>
</form>
<?php
} // end if
?>
</body>
</html>
mysql_free_resu lt($result);
Warning: Supplied argument is not a valid MySQL result resource in
/var/www/html/php/phoneadd.php on line 27
My code is as follows:
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect(" localhost", "", "")
or die("Could not connect : " . mysql_error());
mysql_select_db ("test",$db) ;
$sql = "INSERT INTO phone (fname,lname,st reet,h_phone) VALUES
('$fname','$lna me','$street',' $h_phone')";
$result = mysql_query($sq l);
echo "Thank you! Information entered.\n";
/* Free resultset */
mysql_free_resu lt($result);
/* Closing connection */
mysql_close($db );
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<table>
<tr>
<td>First name: </td><td><input type="Text" name="fname"></td>
</tr>
<tr>
<td>Last name: </td><td> <input type="Text" name="lname"></td>
</tr>
<tr>
<td>Address: </td><td><input type="Text" name="street"></td>
</tr>
<tr>
<td>Home Phone:</td><td> <input type="Text" name="h_phone"> </td>
</tr>
<tr>
<td></td><td> <input type="Submit" name="submit" value="Enter information">
</td>
</tr>
</table>
</form>
<?php
} // end if
?>
</body>
</html>
Comment