Simple coding problem

Hi, I’m trying to create a php script that submits form data. Unfortunately, it’s gotten needlessly complicated thanks to php’s limitations when it comes to inserting multiple checkbox values into one database field.

Anyway, here’s the error I’m getting:

Parse error: syntax error, unexpected ‘[’, expecting ‘]’ in /home/content/08/9100308/html/volunteerRegister.php on line 19

I know it’s probably just a simple syntax error, but I can’t figure it out!

And here’s my code (line 19 is the one inside the while loop):

[php]

<?php if($_GET["regLastName"] && $_GET["regFirstName"] && $_GET["regOrganization"] && $_GET["regEmail"] && $_GET["regPhone"] && $_GET["regMeetingTime"] && $_GET["regAvailableTimesSat[]"] && $_GET["regAreasInterested[]"] && $_GET["regShirtSize"] && $_GET["regRequests"] ) { if($_GET["regAvailableTimesFri[0]"] || $_GET["regAvailableTimesFri[1]"] || $_GET["regAvailableTimesFri[2]"] || $_GET["regAvailableTimesFri[3]"] || $_GET["regAvailableTimesFri[4]"] || $_GET["regAvailableTimesFri[5]"] || $_GET["regAvailableTimesFri[6]"] || $_GET["regAvailableTimesFri[7]"] || $_GET["regAvailableTimesFri[8]"] || $_GET["regAvailableTimesFri[9]"] || $_GET["regAvailableTimesFri[10]"] || $_GET["regAvailableTimesFri[11]"]) { $hostname="*****"; $username="*****"; $password="*****"; $dbname="*****"; $connection = mysql_connect($hostname, $username, $password); mysql_select_db($dbname, $connection); $query = "insert into VOLUNTEER (LASTNAME,FIRSTNAME,ORGANIZATION,EMAIL,PHONE,MEETINGTIME,AVAILABLETIMESFRI,AVAILABLETIMESSAT,AREASINTERESTED,SHIRTSIZE,REQUEST) values ('$_GET[regLastName]','$_GET[regFirstName]','$_GET[regOrganization]','$_GET[regEmail]','$_GET[regPhone]','$_GET[regMeetingTime]'"; $count = 1; while($count <= 12) { if($_GET["regAvailableTimesFri[$count]"]) { $query .= "'$_GET[regAvailableTimesFri[$count]]',"; } } $query .= "'$_GET[regAvailableTimesSat]','$_GET[regAreasInterested]','$_GET[regShirtSize]','$_GET[regRequests]')"; mysql_query($query); print "

You have registered for volunteering successfully! The SAACURH Volunteer Chair will be contacting you soon via e-mail, so keep an eye out!

"; print "Back to Volunteer page"; } } else print "Invalid data. All fields are required. Please try again"; ?>

[/php]

Thanks so much!

Insead of if($_GET[“regAvailableTimesFri[$count]”]) use

if($_GET[‘regAvailableTimesFri’.$count])

Okay, thanks! I fixed that, but now I’m getting this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/08/9100308/html/volunteerRegister.php on line 19

Not really sure what it means. :confused:

[php]<?php
if($_GET[“regLastName”] && $_GET[“regFirstName”] && $_GET[“regOrganization”] && $_GET[“regEmail”] && $_GET[“regPhone”] && $_GET[“regMeetingTime”] && $_GET[“regAvailableTimesSat[]”] && $_GET[“regAreasInterested[]”] && $_GET[“regShirtSize”] && $_GET[“regRequests”] )
{
if($_GET[“regAvailableTimesFri[0]”] || $_GET[“regAvailableTimesFri[1]”] || $_GET[“regAvailableTimesFri[2]”] || $_GET[“regAvailableTimesFri[3]”] || $_GET[“regAvailableTimesFri[4]”] || $_GET[“regAvailableTimesFri[5]”] || $_GET[“regAvailableTimesFri[6]”] || $_GET[“regAvailableTimesFri[7]”] || $_GET[“regAvailableTimesFri[8]”] || $_GET[“regAvailableTimesFri[9]”] || $_GET[“regAvailableTimesFri[10]”] || $_GET[“regAvailableTimesFri[11]”])
{
$hostname=“saacurh2012.db.9100308.hostedresource.com”;
$username=“saacurh2012”;
$password=“StayGold976”;
$dbname=“saacurh2012”;
$connection = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname, $connection);
$query = “insert into VOLUNTEER (LASTNAME,FIRSTNAME,ORGANIZATION,EMAIL,PHONE,MEETINGTIME,AVAILABLETIMESFRI,AVAILABLETIMESSAT,AREASINTERESTED,SHIRTSIZE,REQUEST) values (’$_GET[regLastName]’,’$_GET[regFirstName]’,’$_GET[regOrganization]’,’$_GET[regEmail]’,’$_GET[regPhone]’,’$_GET[regMeetingTime]’”;

	$count = 1;
	while($count <= 12)
	{
		if($_GET['regAvailableTimesFri'.$count])
		{
			$query .= "'$_GET['regAvailableTimesFri'.$count]',";
		}
	}
	
	$query .= "'$_GET[regAvailableTimesSat]','$_GET[regAreasInterested]','$_GET[regShirtSize]','$_GET[regRequests]')";
	
	mysql_query($query);
	print "<h1>You have registered for volunteering successfully! The SAACURH Volunteer Chair will be contacting you soon via e-mail, so keep an eye out!</h1>";
	
	print "<a href='volunteer3.php'>Back to Volunteer page</a>";
}

}
else print “Invalid data. All fields are required. Please try again”;
?>[/php]

last closing bracket is missing at :
[php]
$query = “insert into VOLUNTEER (LASTNAME,FIRSTNAME,ORGANIZATION,EMAIL,PHONE,MEETINGTIME,AVAILABLETIMESFRI,AVAILABLETIMESSAT,AREASINTERESTED,SHIRTSIZE,REQUEST) values (’$_GET[regLastName]’,’$_GET[regFirstName]’,’$_GET[regOrganization]’,’$_GET[regEmail]’,’$_GET[regPhone]’,’$_GET[regMeetingTime]’)”;[/php]

Do you mean the closeing parenthesis? It looks like the brackets are all there to me.

I added the closing parenthesis, but I’m still getting the same error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/08/9100308/html/volunteerRegister.php on line 19

Use 8)
[php]
$query .=" ’ “.$_GET[‘regAvailableTimesFri’.$count].” ’ , ";
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service