Jump to content

unexpected T_STRING, expecting ']' pls help =)


Kurse

Recommended Posts

Okay, so I keep getting this error on html form submission into a mysql database

 

Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/a3384774/public_html/insert.php on line 12

 

Here's the form I'm using:

 

<html>
<body>
<form action="insert.php" method="post">
Please select which branch of the Heekin family you are descendant from in the menu below
<br>
<select name="branch">


<option value="LorettoLeBlond">Loretto LeBlond</option>
<option value="JamesHeekin">James Heekin</option>
<option value="HelenaClarke">Helena Clarke</option>
<option value="AlbertHeekin">Albert Heekin</option>
<option value="NorahMurray">Norah Murray</option>
<option value="RobertHeekin">Robert Heekin</option>
<option value="DanielHeekin">Daniel Heekin</option>
<option value="AileenBering">Aileen Bering</option>
<option value="WalterHeekin">Walter Heekin</option>
<option value="NorahMurray">Norah Murray</option>
<option value="Herbert Heekin">Herbert Heekin</option>
</select>
<br><br>

Your First name: <br> <input type="text" name="firstname" />
<br>
Your Middle name:<br> <input type="text" name="middlename" />
<br>
Your Last Name: <br> <input type="text" name="lastname" />
<br>
<br>
Do you plan to attend?<br>
<select name="attending">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select><br><br>
Number of people who will be attending with you?: <br>
<input type="text" name="numberattending" />
<br>
<br>
How many t-shirts do you wish to order? Only $6.95 each:

<br>
small: <input type="text" size="1" name="smallT" /> <br>
medium: <input type="text" size="1" name="medT" />  <br>
Large: <input type="text" size="1" name="largeT" />  <br>
XL: <input type="text" size="1" name="xlT" />  <br>
2XL: <input type="text" size="1" name="2xT" />  <br><br>
<input type="submit" />
</form>

</body>
</html>

 

and heres the php i'm using to submit to the database

<?php
$con = mysql_connect("host","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("a3384774_users", $con);

$sql="INSERT INTO Persons (Branch, FirstName, MiddleName, LastName, Attending, NumberAttending, SmallT, MediumT, LargeT, XLargeT, TwoXLargeT)
VALUES
('$_POST[branch]','$_POST[firstname]','$_POST[middlename]','$_POST[lastname]','$_POST[attending]','$_POST[numberattending]','$_POST[smallT]','$_POST[medT]','$_POST[largeT]','$_POST[xlT]','$_POST[2xT]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?>

 

any ideas? I'm not missing any ] that I'm aware of

 

this is the site its hosted on if you wish to replicate the error

 

www.heekinreunion.co.cc

 

I am using MySQL ver. 5.0.81-community

 

 

Link to post
Share on other sites

No they weren't being populated, I removed the smallT, medT, largeT, $posts. The problem lies in there somewhere, These values are being passed in to a smallint field in the table and they are in fact small ints. The error persists. Any ideas anyone?

 

So, again the error isn't currently replicated on the site because I removed the

 

,'$_POST[numberattending]','$_POST[smallT]','$_POST[medT]','$_POST[largeT]','$_POST[xlT]','$_POST[2xT]'

 

values from the sql statement in the php. All of these variables hold an int and the fields were set accordingly as tinyint with a maxlength of 3 for each.

Link to post
Share on other sites

really odd but i rewrote the statement from scratch identically as it was before and now things are working properly!? I'm still staring at the original statement and the one i just re-wrote and they are exactly the same.. wo0ho0 solved! Thanks for the advice and help however Jagdish. I'm still staring at this like  :wtf: ?

Link to post
Share on other sites

You probably had a missing ] bracket on your server, but not on your local copy. Then when you re-wrote it identically as before and re-uploaded it to your server, that got the working copy onto the server.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.