trying to write a form processing script
Moderator: General Moderators
trying to write a form processing script
I'm trying to write a php script to process a form, so I tried to edit a guestbook script that a friend gave me, but I received this error message:
Parse error: parse error in /usr2/hsphere/home/thirdchu/thirdunitarianchurch.org/survey.php on line 8
I tried to keep the script as simple as possibel. I have the info a the beginning:
<?php
$hostname = "";
$username = "";
$password = "";
$databasename = "";
$link = mysql connect ($hostname, $username, $password);
mysql select db ($ReligionSurvey, $link);
And I set the insert statement up like this:
$stmt = "insert into "my tabel name" (the names of the fileds separated by commas) value (the names of the values preceeded by '$'s)
Question: I noticed that the script that I'm editing has x's after each $fieldname, would that work with a mix of text fields and numeric fields?
Is leaving out the x's my problem?
The rest of the script goes:
mysql bd query ($databasename, $stmt);
unset ($avail);
header ("Location: survey.php");
exit();
?>
Did I leave something out?
Parse error: parse error in /usr2/hsphere/home/thirdchu/thirdunitarianchurch.org/survey.php on line 8
I tried to keep the script as simple as possibel. I have the info a the beginning:
<?php
$hostname = "";
$username = "";
$password = "";
$databasename = "";
$link = mysql connect ($hostname, $username, $password);
mysql select db ($ReligionSurvey, $link);
And I set the insert statement up like this:
$stmt = "insert into "my tabel name" (the names of the fileds separated by commas) value (the names of the values preceeded by '$'s)
Question: I noticed that the script that I'm editing has x's after each $fieldname, would that work with a mix of text fields and numeric fields?
Is leaving out the x's my problem?
The rest of the script goes:
mysql bd query ($databasename, $stmt);
unset ($avail);
header ("Location: survey.php");
exit();
?>
Did I leave something out?
It should be a bit more like this:
Code: Select all
<?php
if ( $submit = "submit" ) { // assuming the value of your submit button is "submit".
$hostname = "";
$username = "";
$password = "";
$databasename = "";
$link = mysql_connect ($hostname, $username, $password);
mysql_select_db ($ReligionSurvey, $link);
$stmt = "insert into "my tabel name" (the names of the fileds separated by commas) value (the names of the values preceeded by '$'s)
mysql_db_query ($databasename, $stmt);
unset ($avail);
header ("Location: survey.php");
exit();
} else {
echo "It seems you were brought to this page on accident, please return to "; ?>
<A HREF="http://url.to.your/form">the form</A> and try submitting properly.error messages for the script
I tried to create a script using the format that Elmseeker provided, but I still get error messages. There are a lot of fields in my form, so I thought it would be best to just list the entire script as is. The message that I get when I submit the form is: Parse error: parse error in /usr2/hsphere/home/thirdchu/thirdunitarianchurch.org/survey.php on line 79
Here's the script, any iseas?
<?php
if ($submit="submit") {//"submit"
$hostname = "";
$username = "";
$password = "";
$databasename = "";
$link = mysql_connect ($hostname, $username, $password);
mysql_select_db ($ReligionSurvey, $link);
$stmt = "insert_into_Results2003 (country, citizen, state, resident, community, age, gender, ethnicity, other_ethnicity)";
$stmt = "insert_into_Results2003 (religious_orientation, other_religious_orientation, student, student_status, employed)";
$stmt = "insert_into_Results2003 (occupation, faith_events, faith_events_attendance, other_faith_events_attendance)";
$stmt = "insert_into_Results2003 (faith_events_occurrence, faith_events_occurrence_dates)";
$stmt = "insert_into_Results2003 (place_of_worship, place_of_worship_name, live_near_place_of_worship, religious_holiday)";
$stmt = "insert_into_Results2003 (religious_symbols, religious_symbols_name, mothers_faith, fathers_faith, mother_same_faith)";
$stmt = "insert_into_Results2003 (father_same_faith, same_religion_as_growing_up, attended_religious_institution)";
$stmt = "insert_into_Results2003 (religious_institution_level, religious_institution_type, grandparents_faith)";
$stmt = "insert_into_Results2003 (religion_dictates_appearance, appearance_dictated_by_doctrine)";
$stmt = "insert_into_Results2003 (forbid_specific_clothing_women, forbid_specific_clothing_men, forbidden_appearance)";
$stmt = "insert_into_Results2003 (specific_consumption_forbidden, consumption_forbidden, community_religious_orientation)";
$stmt = "insert_into_Results2003 (other_community_religious_orientation, community_places_of_worship)";
$stmt = "insert_into_Results2003 (community_pow_affiliation, religious_symbols_in_community)";
$stmt = "insert_into_Results2003 (community_religious_symbol_affiliation, are_your_religious_holidays_observed_public_schools)";
$stmt = "insert_into_Results2003 (are_your_religious_holidays_observed_businesses)";
$stmt = "insert_into_Results2003 (are_your_religious_holidays_observed_local_government, local_officials_same_religion)";
$stmt = "insert_into_Results2003 (state_officials_same_religion, national_officials_same_religion, community_attitude_beliefs)";
$stmt = "insert_into_Results2003 (community_attitude_pow, community_attitude_symbols, attitude_holidays_publicschools)";
$stmt = "insert_into_Results2003 (attituder_holidays_businesses, attitude_religious_holidays_localgovernment)";
$stmt = "insert_into_Results2003 (community_attitude_electedofficials, attitude_toward_religion_dominant_in_your_community)";
$stmt = "insert_into_Results2003 (publicschools_consider_dietary_needs, restaurants_cater_dietary_needs)";
$stmt = "insert_into_Results2003 (familiar_other_religions, familiar_other_religion_name, interested_other_religions)";
$stmt = "insert_into_Results2003 (interested_other_religion_name, attended_events_affiliated_religion)";
$stmt = "insert_into_Results2003 (attended_eventr_religion_name, consider_religion_political_candidates, broadcasts_religion)";
$stmt = "insert_into_Results2003 (reflect_ideals, offend_you_religious_reasons, broadcasts_religious_issues)";
$stmt = "insert_into_Results2003 (interest_religious_beliefs, community_pow_variety_religions)";
$stmt = "insert_into_Results2003 (community_recognition_religios_holidays, broadcasts_sensitive_variety_religions)";
$stmt = "insert_into_Results2003 (respondent_email, respondent_comments)";
$stmt = "insert_into_Results2003 values ('$country', '$citizen', '$state', '$resident', '$community', '$age', '$gender', '$ethnicity')";
$stmt = "insert_into_Results2003 values ('$other_ethnicity', '$religious_orientation', '$other_religious_orientation', '$student')";
$stmt = "insert_into_Results2003 values ('$student_status', '$employed', '$occupation', '$faith_events', '$faith_events_attendance')";
$stmt = "insert_into_Results2003 values ('$other_faith_events_attendance', '$faith_events_occurrence')";
$stmt = "insert_into_Results2003 values ('$faith_events_occurrence_dates', '$place_of_worship', '$place_of_worship_name')";
$stmt = "insert_into_Results2003 values ('$live_near_place_of_worship', '$religious_holiday', '$religious_symbols')";
$stmt = "insert_into_Results2003 values ('$religious_symbols_name', '$mothers_faith', '$fathers_faith', '$mother_same_faith')";
$stmt = "insert_into_Results2003 values ('$father_same_faith', '$same_religion_as_growing_up', '$attended_religious_institution')";
$stmt = "insert_into_Results2003 values ('$religious_institution_level', '$religious_institution_type', '$grandparents_faith')";
$stmt = "insert_into_Results2003 values ('$religion_dictates_appearance', '$appearance_dictated_by_doctrine')";
$stmt = "insert_into_Results2003 values ('$forbid_specific_clothing_women', '$forbid_specific_clothing_men')";
$stmt = "insert_into_Results2003 values ('$forbidden_appearance', '$specific_consumption_forbidden', '$consumption_forbidden')";
$stmt = "insert_into_Results2003 values ('$community_religious_orientation', '$other_community_religious_orientation')";
$stmt = "insert_into_Results2003 values ('$community_places_of_worship', '$community_pow_affiliation')";
$stmt = "insert_into_Results2003 values ('$religious_symbols_in_community', '$community_religious_symbol_affiliation')";
$stmt = "insert_into_Results2003 values ('$are_your_religious_holidays_observed_public_schools')";
$stmt = "insert_into_Results2003 values ('$are_your_religious_holidays_observed_businesses')";
$stmt = "insert_into_Results2003 values ('$are_your_religious_holidays_observed_local_government')";
$stmt = "insert_into_Results2003 values ('$local_officials_same_religion', '$state_officials_same_religion')";
$stmt = "insert_into_Results2003 values ('$national_officials_same_religion', '$community_attitude_beliefs')";
$stmt = "insert_into_Results2003 values ('$community_attitude_pow', '$community_attitude_symbols')";
$stmt = "insert_into_Results2003 values ('$attitude_holidays_publicschools', '$attituder_holidays_businesses')";
$stmt = "insert_into_Results2003 values ('$attitude_religious_holidays_localgovernment', '$community_attitude_electedofficials')";
$stmt = "insert_into_Results2003 values ('$attitude_toward_religion_dominant_in_your_community')";
$stmt = "insert_into_Results2003 values ('$publicschools_consider_dietary_needs', '$restaurants_cater_dietary_needs')";
$stmt = "insert_into_Results2003 values ('$familiar_other_religions', '$familiar_other_religion_name', '$interested_other_religions')";
$stmt = "insert_into_Results2003 values ('$interested_other_religion_name', '$attended_events_affiliated_religion')";
$stmt = "insert_into_Results2003 values ('$attended_eventr_religion_name', '$consider_religion_political_candidates')";
$stmt = "insert_into_Results2003 values ('$broadcasts_religion', '$reflect_ideals, offend_you_religious_reasons')";
$stmt = "insert_into_Results2003 values ('$broadcasts_religious_issues, interest_religious_beliefs')";
$stmt = "insert_into_Results2003 values ('$community_pow_variety_religions', '$community_recognition_religios_holidays')";
$stmt = "insert_into_Results2003 values ('$broadcasts_sensitive_variety_religions, $respondent_email', '$respondent_comments')";
mysql_bd_query ($ReligionSurvey, $stmt);
unset ($avail);
header ("location: survey.php");
exit();
} else {
echo "It seems that you were brought to this page by accident, please return to"; ?>
<A HREF="http://thirdunitarianchurch.org/Communi ... >Religious Climate Survey</A> and try submitting properly.
Here's the script, any iseas?
<?php
if ($submit="submit") {//"submit"
$hostname = "";
$username = "";
$password = "";
$databasename = "";
$link = mysql_connect ($hostname, $username, $password);
mysql_select_db ($ReligionSurvey, $link);
$stmt = "insert_into_Results2003 (country, citizen, state, resident, community, age, gender, ethnicity, other_ethnicity)";
$stmt = "insert_into_Results2003 (religious_orientation, other_religious_orientation, student, student_status, employed)";
$stmt = "insert_into_Results2003 (occupation, faith_events, faith_events_attendance, other_faith_events_attendance)";
$stmt = "insert_into_Results2003 (faith_events_occurrence, faith_events_occurrence_dates)";
$stmt = "insert_into_Results2003 (place_of_worship, place_of_worship_name, live_near_place_of_worship, religious_holiday)";
$stmt = "insert_into_Results2003 (religious_symbols, religious_symbols_name, mothers_faith, fathers_faith, mother_same_faith)";
$stmt = "insert_into_Results2003 (father_same_faith, same_religion_as_growing_up, attended_religious_institution)";
$stmt = "insert_into_Results2003 (religious_institution_level, religious_institution_type, grandparents_faith)";
$stmt = "insert_into_Results2003 (religion_dictates_appearance, appearance_dictated_by_doctrine)";
$stmt = "insert_into_Results2003 (forbid_specific_clothing_women, forbid_specific_clothing_men, forbidden_appearance)";
$stmt = "insert_into_Results2003 (specific_consumption_forbidden, consumption_forbidden, community_religious_orientation)";
$stmt = "insert_into_Results2003 (other_community_religious_orientation, community_places_of_worship)";
$stmt = "insert_into_Results2003 (community_pow_affiliation, religious_symbols_in_community)";
$stmt = "insert_into_Results2003 (community_religious_symbol_affiliation, are_your_religious_holidays_observed_public_schools)";
$stmt = "insert_into_Results2003 (are_your_religious_holidays_observed_businesses)";
$stmt = "insert_into_Results2003 (are_your_religious_holidays_observed_local_government, local_officials_same_religion)";
$stmt = "insert_into_Results2003 (state_officials_same_religion, national_officials_same_religion, community_attitude_beliefs)";
$stmt = "insert_into_Results2003 (community_attitude_pow, community_attitude_symbols, attitude_holidays_publicschools)";
$stmt = "insert_into_Results2003 (attituder_holidays_businesses, attitude_religious_holidays_localgovernment)";
$stmt = "insert_into_Results2003 (community_attitude_electedofficials, attitude_toward_religion_dominant_in_your_community)";
$stmt = "insert_into_Results2003 (publicschools_consider_dietary_needs, restaurants_cater_dietary_needs)";
$stmt = "insert_into_Results2003 (familiar_other_religions, familiar_other_religion_name, interested_other_religions)";
$stmt = "insert_into_Results2003 (interested_other_religion_name, attended_events_affiliated_religion)";
$stmt = "insert_into_Results2003 (attended_eventr_religion_name, consider_religion_political_candidates, broadcasts_religion)";
$stmt = "insert_into_Results2003 (reflect_ideals, offend_you_religious_reasons, broadcasts_religious_issues)";
$stmt = "insert_into_Results2003 (interest_religious_beliefs, community_pow_variety_religions)";
$stmt = "insert_into_Results2003 (community_recognition_religios_holidays, broadcasts_sensitive_variety_religions)";
$stmt = "insert_into_Results2003 (respondent_email, respondent_comments)";
$stmt = "insert_into_Results2003 values ('$country', '$citizen', '$state', '$resident', '$community', '$age', '$gender', '$ethnicity')";
$stmt = "insert_into_Results2003 values ('$other_ethnicity', '$religious_orientation', '$other_religious_orientation', '$student')";
$stmt = "insert_into_Results2003 values ('$student_status', '$employed', '$occupation', '$faith_events', '$faith_events_attendance')";
$stmt = "insert_into_Results2003 values ('$other_faith_events_attendance', '$faith_events_occurrence')";
$stmt = "insert_into_Results2003 values ('$faith_events_occurrence_dates', '$place_of_worship', '$place_of_worship_name')";
$stmt = "insert_into_Results2003 values ('$live_near_place_of_worship', '$religious_holiday', '$religious_symbols')";
$stmt = "insert_into_Results2003 values ('$religious_symbols_name', '$mothers_faith', '$fathers_faith', '$mother_same_faith')";
$stmt = "insert_into_Results2003 values ('$father_same_faith', '$same_religion_as_growing_up', '$attended_religious_institution')";
$stmt = "insert_into_Results2003 values ('$religious_institution_level', '$religious_institution_type', '$grandparents_faith')";
$stmt = "insert_into_Results2003 values ('$religion_dictates_appearance', '$appearance_dictated_by_doctrine')";
$stmt = "insert_into_Results2003 values ('$forbid_specific_clothing_women', '$forbid_specific_clothing_men')";
$stmt = "insert_into_Results2003 values ('$forbidden_appearance', '$specific_consumption_forbidden', '$consumption_forbidden')";
$stmt = "insert_into_Results2003 values ('$community_religious_orientation', '$other_community_religious_orientation')";
$stmt = "insert_into_Results2003 values ('$community_places_of_worship', '$community_pow_affiliation')";
$stmt = "insert_into_Results2003 values ('$religious_symbols_in_community', '$community_religious_symbol_affiliation')";
$stmt = "insert_into_Results2003 values ('$are_your_religious_holidays_observed_public_schools')";
$stmt = "insert_into_Results2003 values ('$are_your_religious_holidays_observed_businesses')";
$stmt = "insert_into_Results2003 values ('$are_your_religious_holidays_observed_local_government')";
$stmt = "insert_into_Results2003 values ('$local_officials_same_religion', '$state_officials_same_religion')";
$stmt = "insert_into_Results2003 values ('$national_officials_same_religion', '$community_attitude_beliefs')";
$stmt = "insert_into_Results2003 values ('$community_attitude_pow', '$community_attitude_symbols')";
$stmt = "insert_into_Results2003 values ('$attitude_holidays_publicschools', '$attituder_holidays_businesses')";
$stmt = "insert_into_Results2003 values ('$attitude_religious_holidays_localgovernment', '$community_attitude_electedofficials')";
$stmt = "insert_into_Results2003 values ('$attitude_toward_religion_dominant_in_your_community')";
$stmt = "insert_into_Results2003 values ('$publicschools_consider_dietary_needs', '$restaurants_cater_dietary_needs')";
$stmt = "insert_into_Results2003 values ('$familiar_other_religions', '$familiar_other_religion_name', '$interested_other_religions')";
$stmt = "insert_into_Results2003 values ('$interested_other_religion_name', '$attended_events_affiliated_religion')";
$stmt = "insert_into_Results2003 values ('$attended_eventr_religion_name', '$consider_religion_political_candidates')";
$stmt = "insert_into_Results2003 values ('$broadcasts_religion', '$reflect_ideals, offend_you_religious_reasons')";
$stmt = "insert_into_Results2003 values ('$broadcasts_religious_issues, interest_religious_beliefs')";
$stmt = "insert_into_Results2003 values ('$community_pow_variety_religions', '$community_recognition_religios_holidays')";
$stmt = "insert_into_Results2003 values ('$broadcasts_sensitive_variety_religions, $respondent_email', '$respondent_comments')";
mysql_bd_query ($ReligionSurvey, $stmt);
unset ($avail);
header ("location: survey.php");
exit();
} else {
echo "It seems that you were brought to this page by accident, please return to"; ?>
<A HREF="http://thirdunitarianchurch.org/Communi ... >Religious Climate Survey</A> and try submitting properly.
no underscores, still errors
I took out the underscores, but still get the same message.
Is it possible that the server expects all of the fields to be filled? Would empty fields produce a parse error? If this is the case, what would I add to the script to let the server know that all of the fields do not have to be filled?
Is it possible that the server expects all of the fields to be filled? Would empty fields produce a parse error? If this is the case, what would I add to the script to let the server know that all of the fields do not have to be filled?
no underscores, still errors
If you stiil got an error on line 79, check you code from:
else {
echo "It seems that you were brought to this page by accident, please return to"; ?>
********
try this:
you may need to insert a "}" before the end of your code, like:
please return to";
}
?>
Hope this may help.
A Novic
else {
echo "It seems that you were brought to this page by accident, please return to"; ?>
********
try this:
you may need to insert a "}" before the end of your code, like:
please return to";
}
?>
Hope this may help.
A Novic