This may be rookieish, but I am a php rookie, waiting to get some books, but I have an error I would like to pose to all.
I have a test .php form (test_form.php) that calls test_sql_isrt.php and I get an error as shown below. However, if I execute this script by embedding test_sql_isrt into the file, rather than executing with the FORM submit button, a record gets added.
Also, I try executing a button to just do a select form and I get a different message, which leads me to believe it has something to do with the form.
//////
Error:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/ebllorg/public_html/newsite/test_sql_isrt.php on line 4
fname joevalue 1… bad query.
//////////////
File: test_form.php
.
.
<form action=”test_sql_isrt.php” method=”POST”>
Enter your name: <input type=”text” name=”fname” />
Enter your id: <input type=”text” name=”age” />
Enter your age: <input type=”text” name=”age” />
<input type=”submit” value=”Add”/>
</form>
.
.
file: test_sql_isrt.php
<?
$query1 = “SELECT MAX(playerid) FROM Registration”;
$result1 = mysql_query($query1);
$value = mysql_result($result1, 0);
$value = $value+1;
$fname = $_POST[“fname”];
echo “fname “;
echo $fname;
echo “value “;
echo $value;
echo “… “;
$sql = “INSERT INTO `Registration`playerid`fname`lname`address`dob`city`state`zip
VALUES ($value, ‘Geogre’, ‘Costanza’, ‘12345 grapple drive’, ‘1999-05-04’, ‘Anytown’, ‘ia’, ‘12345’)”;
if (! $result = mysql_query($sql))
{
die(“bad query.”);
}
?>
///////////////////
Thanks in advance.