PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
mysql_connect(localhost, -usn- , -pw- ) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db(-db-);
$sql = mysql_query("INSERT INTO `members` (id, shortname, fullname, age, car, location, state, body, engine, brag, future) VALUES ('', '".$_POST['shortname']."','".$_POST['fullname']."','".$_POST['age']."','".$_POST['car']."','".$_POST['location']."','".$_POST['state']."', '".$_POST['body']."','".$_POST['engine']."','".$_POST['brag']."','".$_POST['future']."')") or die(mysql_error());
mysql_query($sql) or die(mysql_error());
$contact = mysql_query("INSERT INTO `contact` (id, fullname, age, location, phone, email) VALUES ('', '".$_POST['fillname']."', '".$_POST['age']."', '".$_POST['location']."', '".$_POST['phone']."', '".$_POST['email']."')") or die(mysql_error());
mysql_query($contact) or die(mysql_error());
echo "Added '".$_POST['fullname']."' to the members list on the website <br><br>";
echo "Added '".$_POST['fullname']."' to the contact list on the Damian Contact site<br><br>";
?>
the error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
You most likely have an apostrophe in one of your variables.
call mysql_real_escape_string on all of your variables before you put them into the query.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
as per usual, echo out the query string you are sending to MySQL. Try running that echoed line in phpMyAdmin. If you are confused about the line output, post it here.
uhm... you have four (count them, four) mysql_query() calls in your code. I was talking about the first pair and second pair as seperate entities. I realize that is/was your intention.