Kurse Posted April 20, 2010 Share Posted April 20, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/199098-unexpected-t_string-expecting-pls-help/ Share on other sites More sharing options...
jagdish kothapalle Posted April 20, 2010 Share Posted April 20, 2010 Hi, I tried replicating the issue and the records are getting inserted properly. I believe the issue got fixed. Kindly close the thread. Quote Link to comment https://forums.phpfreaks.com/topic/199098-unexpected-t_string-expecting-pls-help/#findComment-1045047 Share on other sites More sharing options...
Kurse Posted April 20, 2010 Author Share Posted April 20, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/199098-unexpected-t_string-expecting-pls-help/#findComment-1045049 Share on other sites More sharing options...
Kurse Posted April 20, 2010 Author Share Posted April 20, 2010 I just changed the relevant fields to smallint(3) but still no love :-\ Quote Link to comment https://forums.phpfreaks.com/topic/199098-unexpected-t_string-expecting-pls-help/#findComment-1045054 Share on other sites More sharing options...
jagdish kothapalle Posted April 20, 2010 Share Posted April 20, 2010 Debugging is the best way to solve it. Simplest way would be to echo the query and see the output of the query string. Should solve your purpose. Quote Link to comment https://forums.phpfreaks.com/topic/199098-unexpected-t_string-expecting-pls-help/#findComment-1045055 Share on other sites More sharing options...
Kurse Posted April 20, 2010 Author Share Posted April 20, 2010 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/199098-unexpected-t_string-expecting-pls-help/#findComment-1045058 Share on other sites More sharing options...
F1Fan Posted April 20, 2010 Share Posted April 20, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/199098-unexpected-t_string-expecting-pls-help/#findComment-1045174 Share on other sites More sharing options...
Kurse Posted April 21, 2010 Author Share Posted April 21, 2010 Yeah thats all I can assume. At least things are smoov now. Quote Link to comment https://forums.phpfreaks.com/topic/199098-unexpected-t_string-expecting-pls-help/#findComment-1045522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.