Jump to content

unexpected T_STRING, expecting ']' pls help =)


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:


<form action="insert.php" method="post">
Please select which branch of the Heekin family you are descendant from in the menu below
<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>

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

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" />



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

$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)

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



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




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




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


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.