Newbi

From: mickey (meshulamtemp_at_yahoo.com)
Date: 07/29/04


Date: Thu, 29 Jul 2004 21:03:32 GMT

I am getting the following error at the line
 mysql_free_result($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,street,h_phone) VALUES
('$fname','$lname','$street','$h_phone')";

  $result = mysql_query($sql);

  echo "Thank you! Information entered.\n";

    /* Free resultset */
  mysql_free_result($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>



Relevant Pages

  • Re: PHP cannot connecto MySQL
    ... Warning: mysql_num_rows: supplied argument is not a valid MySQL ... result resource ... which leads me to believe that it is just not ...
    (php.general)
  • Re: error on sql in php code
    ... but the warning comes ... result resource in C:\Program Files\Apache Software Foundation ... php done right;) http://code.google.com/p/pihipi ...
    (comp.lang.php)
  • Repeat Region Error
    ... I am getting the following error - Warning: mysql_fetch_assoc: 3 is not a valid MySQL result resource in .... ... I think it has something to do with my Dreamweaver created code for a repeat region. ...
    (php.general)
  • Re: Redirect
    ... Well, I'm tired, PHP is against me ... Warning: mysql_fetch_array: supplied argument is not a valid MySQL ... result resource ...
    (comp.lang.php)
  • mysql_fetch_array
    ... This gives me a Warning that mysql_fetch_array isn't getting a valid MySQL ... resource, but it has the right value in $name and doesn't have an obvious ...
    (comp.lang.php)