Jump to content

Recommended Posts

   <?php 
$sqlinsert = mysql_query( "INSERT INTO costumers (firstname,lastname,birthdate,product_name,price,details,category,subcategory,city,state,zipcode,country)
                 VALUES ('$fname','$lname','$birthday','$itemname','$price','$details','$category','$subcategory','$city','$state','$zipcode','$country',)"
); // line 19
$insertCount = mysql_num_rows($sqlinsert); 
if ($insertCount>0 ) {
   
   $newrecord = "$itemname was inserted";
   }
    }
    
    ?>

 

 

Having problems at line 19 mysql_num_rows functions is not working it seems it is not suitable for an insert. What function I could use in there.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /public_html/InsertForm.php on line 19

<?php 
$sqlinsert = mysql_query( "INSERT INTO costumers (firstname,lastname,birthdate,product_name,price,details,category,subcategory,city,state,zipcode,country)              
             VALUES ('$fname','$lname','$birthday','$itemname','$price','$details','$category','$subcategory','$city','$state','$zipcode','$country',)"); // line 19
$insertCount = mysql_num_rows($sqlinsert); if 0($insertCount>0 ) 
       { 
          $newrecord = "$itemname was inserted"; 
       } 


?>

 

 

sorry about that mess in the first post.

mysql_num_rows() expects a result resource because it is used with SELECT/SHOW queries.

 

An INSERT query only returns a true/false value.

 

To find out if an INSERT query actually inserted a row, after you check that the query executed without any errors, you would use mysql_affected_rows

 

Thank you Pikachu.

 

PFM I have set it to true and if set to true it will display "item1 was inserted."

 

Now the code below seems to submit the form, it is set to true and display the "item1 was inserted" message but when I go in the database table costumers I don't find any record of the Insert.

 

<?php 

$sqlinsert = mysql_query( "INSERT INTO costumers (firstname,lastname,birthdate,product_name,price,details,category,subcategory,city,state,zipcode,country)
              VALUES ('$fname','$lname','$birthday','$itemname','$price','$details','$category','$subcategory','$city','$state','$zipcode','$country',)"
); 
$newrecord = '' . $itemname . ' was inserted' ;
if ($sqlinsert=true ) {
 echo $newrecord;

}

 }


 ?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.