PDA

View Full Version : php/mysql form problems


bcbirk100
08-02-2007, 12:50 AM
ok, i can't figure out why it's not working, but i keep getting my error response. I'm guessing it's my php code, since that's what I'm least familiar with. I'm creating an rsvp form for a wedding. I have the following fields in my flash: #of guests (guest_num), names(guest_names), potluck, course recipe name, recipe. For some reason it's just not working.. any help? thanks.

<?
//User, password & database
$send_lv =$_POST['send_lv'];
$user="userhere";
$password="passhere";
$database="datahere";

$date = date("y-m-d H:i:s");
$guest_num=$_POST['guestnumber'];
$guest_names=$_POST['name'];
$potluck=$_POST['potluck'];
if($potluck == 'yes') {
$course=$_POST['course'];
$recipe_name=$_POST['recipe_name'];
$recipe=$_POST['recipe'];
}
if($potluck == 'no') {
$course = 'none';
$recipe_name = 'none';
$recipe = 'none';
}
$db = @mysql_connect(localhost,$user,$password);
mysql_select_db($database);

$query ="INSERT INTO wedding (date, guest_num, guest_names, potluck, course, recipe_name, recipe)";
$query.=" VALUES ('$date','$guest_num', '$guest_names', '$potluck', '$course', '$recipe_name', '$recipe')";
$result=mysql_query($query, $db);
if ($result) {
echo "Successfully Posted!";
}
else {
echo "ERROR: unable to post.";
}

?>



my actionscript is as follows
var postBtnListener:Object = new Object();
postBtnListener.click = function(evt:Object) {
// if the name is blank, display an error message using the Alert component.
if (guest_name1.text.length == 0) {
Selection.setFocus(guest_name1);
Alert.show("Please enter Guests Name.","Error",Alert.OK);
return false;
}
guestname1 = guest_name1.text;
guestnumber = _global.guestnumber;
potluck = potluck_cb.selectedItem.data;
if (potluck == "yes") {
potluck_mc.gotoAndPlay("yes");
} else {
// if all the required fields have been filled in, create a LoadVars object instance and populate it.
var send_lv:LoadVars = new LoadVars();
send_lv.name = guestname1;
send_lv.guestnumber = guestnumber;
send_lv.potluck = potluck;
send_lv.onLoad = function(success:Boolean) {
// if the comments were sent to the server and you received a response, clear the form fields and display an Alert message.
if (success) {
guest_name1.text = "";
Alert.show("Thank you for your RSVP.","Success",Alert.OK);
} else {
// else you encountered an error while submitting to the server.
Alert.show("Unable to process your RSVP at this time.","Server Error",Alert.OK);
}
};
// send the variables from Flash to the remote PHP template.
send_lv.sendAndLoad("rsvp.php",send_lv,"POST");
}//end potluck else
};
this.rsvp_btn.addEventListener("click",postBtnListener);

Cota
08-02-2007, 01:34 AM
change this line to

$query ="INSERT INTO `wedding` (`date`, `guest_num`, `guest_names`, `potluck`, `course`, `recipe_name`, `recipe`)";