lucy Posted August 5, 2009 Share Posted August 5, 2009 I am trying to get a form to input data to my MYSQL database but im having a little trouble. I have created a php file called custentry.html which holds the form. I have also created another php file called custentry.php which holds the script for connecting to the database and entering the data which has been entered on the html file. Whenever i try to enter the data i get the following message: " Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sites/foo/public_html/test/php/custentry.php on line 14 " I cant figure out what is wrong with my code. Here is the html file: <body> <form action="php/custentry.php" method="post"> <p>Title: <input type="text" name="title" /> </p> <p> <input type="reset" name="clear" id="clear" value="Reset" /> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <p> </p> </form> </body> and here is the php file (with the database name and password and user taken out): <? $user="OMITTED"; //specially created username $password="OMITTED"; $database="OMITTED; //connect to the database $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); //select the database mysql_select_db($database, $con); //insert data into database mysql_query("INSERT INTO customer VALUES ($_POST['title'])") or die('Error: ' . mysql_error()); //close connection mysql_close(); echo "entered data!"; ?> Could someone please suggest why i am getting that message? Thanks, Lucy Link to comment https://forums.phpfreaks.com/topic/168922-error-on-input-of-data-with-form/ Share on other sites More sharing options...
kickstart Posted August 5, 2009 Share Posted August 5, 2009 Hi That error you often get from some dodgy syntax (missing ; or the like). In you script it appears to be caused by a missing closing quote after the database name (line 5). All the best Keith Link to comment https://forums.phpfreaks.com/topic/168922-error-on-input-of-data-with-form/#findComment-891236 Share on other sites More sharing options...
lucy Posted August 5, 2009 Author Share Posted August 5, 2009 Thanks for your help, ive just fixed the problem. the missing " was a typo, sorry, my bad. the original form has the second " in. The problem was '$_POST['title']', i had put extra speech marks in the title part, where it should have only been, '$_POST[title]'. Thanks, Lucy Link to comment https://forums.phpfreaks.com/topic/168922-error-on-input-of-data-with-form/#findComment-891238 Share on other sites More sharing options...
lucy Posted August 15, 2009 Author Share Posted August 15, 2009 Yeah its fully fixed now thanks Lucy Link to comment https://forums.phpfreaks.com/topic/168922-error-on-input-of-data-with-form/#findComment-898806 Share on other sites More sharing options...
lucy Posted August 16, 2009 Author Share Posted August 16, 2009 How can users desired passwords be stored in the database, in an encrypted way? Thanks, Lucy Link to comment https://forums.phpfreaks.com/topic/168922-error-on-input-of-data-with-form/#findComment-899653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.