Drop-downs and MySQL
Posted: Sat Dec 10, 2005 12:33 pm
Hello, say I have this code...
http://www.aa-25thID.com/ATFCS/test.php is the link if you want to try it
When you do it, it says:
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/recon/public_html/ATFCS/test.php on line 11
There seems to be an issue.
I was just wondering if I am not follwing the syntax for inserting <option> values into mysql....
THanks for any and all help
Code: Select all
<?php
include('includes/connect.php');
if (isset($_POST['submitted'])){
if (isset($_POST['id'])){
if(isset($_POST['name'])){
$id=$_POST['id'];
$name=$_POST['name'];
$sql="INSERT INTO test (id, name) VALUES ('$id','$name')";
$result=mysql_query($sql);
if (mysql_affected_rows($result) == 1){
echo "The script has completed sucessfully!";
mysql_close();
}else{
echo "There seems to be an issue.";
}
}else{
echo "Please select your name";
}
}else{
echo "Please select your id";
}
}else{
echo '<form name="test" method="POST" action="test.php">
ID:<select name="id"><option value="1">1</option><option value="2">2</option></select>
<br>Name: <select name="name"><option value="Tucker">Tucker</option><option name="Haener">Haener</option></select><br>
<input type="submit" name="submit" value="Submit"><input type="hidden" name="submitted" value="TRUE"></form>';
}When you do it, it says:
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/recon/public_html/ATFCS/test.php on line 11
There seems to be an issue.
I was just wondering if I am not follwing the syntax for inserting <option> values into mysql....
THanks for any and all help