Following is my insert.php file to which my form post the data
[QUOTE]
<?php
$fname = $_POST[“fname”];
$lname = $
$age = $_POST[“age”];
$con = mysql_connect(“localhost”,”giftme@1″,”mypass”);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}mysql_select_db(“giftme@1-airtime”, $con);
$sql = “SELECT * FROM PERSON WHERE(first_name=’$fname’ AND last_name=’$lname’ AND age=’$age’)”;
$result = MySQL_query($sql, $con);
$already_there = (MySQL_num_rows($result) > 0);
if ($already_there) {
$array = MySQL_fetch_array($result);
$id = $array[‘id’];
$entries = $array[‘entries’] + 1;
$sql = “UPDATE person SET entries=$entries WHERE id=$id”;
}
else {
$sql = “INSERT INTO person VALUES(”, ‘$fname’, ‘$lname’, 1)”;
}
MySQL_query($sql, $con);
MySQL_close($con);
/*redirect – this must be the first output of the script
*/
header(‘location:
?>
I dont know what’s gone wrong with the program not running giving following error:
[QUOTE]
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /data/apache/users/kilu.de/giftme/www/form/insert.php on line 14
Warning: Cannot modify header information – headers already sent by (output started at /data/apache/users/kilu.de/giftme/www/form/insert.php:14) in /data/apache/users/kilu.de/giftme/www/form/insert.php on line 31
?>
[B]Line 14:
[B]Line 31:
Could any1 help ?