Help! Parse error: parse error, unexpected T_STRING

Thread Solved

Join Date: Jan 2008
Posts: 12
Reputation: crzycm16 is an unknown quantity at this point 
Solved Threads: 0
crzycm16 crzycm16 is offline Offline
Newbie Poster

Help! Parse error: parse error, unexpected T_STRING

 
0
  #1
Jan 17th, 2008
help! im pretty new at PHP, and im creating a simple pdf form with an html submit document. however, when i hit submit i get this error.
Parse error: parse error, unexpected T_STRING in home/content/c/r/z/crzycm16/html/insert.php on line 42

my form is at http://www.shsinteract.com/vets.pdf
and i am following this tutorial, http://www.andrewheiss.com/Tutorials...PDFs_and_MySQL

My code is as follows,
Thanks for the Help!
Cameron

  1. <?php
  2. $host="p50mysql81.secureserver.net";
  3. $username="Vetsform";
  4. $password="Amina123";
  5. $db_name="Vetsform";
  6. $tbl_name="vetform";
  7.  
  8. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  9. mysql_select_db("$db_name")or die("cannot select DB");
  10.  
  11. $VeteranName=$_REQUEST["VeteranName"];
  12. $Address=$_REQUEST["Address"];
  13. $StateProv=$_REQUEST["StateProv"];
  14. $ZipCode=$_REQUEST["ZipCode"];
  15. $Branch=$_REQUEST["Branch"];
  16. $Dateserved=$_REQUEST["Dateserved"];
  17. $Comments=$_REQUEST["Comments"];
  18. $guestname=$_REQUEST["guestname"];
  19. $Phonenumber=$_REQUEST["Phonenumber"];
  20. $city=$_REQUEST["city"];
  21.  
  22. $sql="INSERT INTO $tbl_name(VeteranName, Address, StateProv, ZipCode, Branch, Dateserved, Comments, guestname, Phonenumber, city)
  23. VALUES('$VeteranName';
  24. '$Address';
  25. '$StateProv';
  26. '$ZipCode';
  27. '$Branch';
  28. '$Dateserved';
  29. '$Comments';
  30. '$guestname';
  31. '$Phonenumber';
  32. $city')
  33. $result=mysql_query($sql);
  34.  
  35. if($result){
  36. echo "Successful";
  37. }
  38.  
  39. else {
  40. echo "ERROR";
  41. }
  42.  
  43. mysql_close();
  44. ?>
  45.  
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #2
Jan 17th, 2008
Take out the semicolons after the Values ie.,
  1. $sql="INSERT INTO $tbl_name(VeteranName, Address, StateProv, ZipCode, Branch, Dateserved, Comments, guestname, Phonenumber, city)
  2. VALUES('$VeteranName',
  3. '$Address',
  4. '$StateProv',
  5. '$ZipCode',
  6. '$Branch',
  7. '$Dateserved',
  8. '$Comments',
  9. '$guestname',
  10. '$Phonenumber',
  11. $city')";
  12. $result=mysql_query($sql);

Also, don't do $VeteranName = $_GET['VeteranName']; etc.
just do extract($_REQUEST);
Last edited by ShawnCplus; Jan 17th, 2008 at 8:09 pm.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #3
Jan 17th, 2008
And put commas.

Edit: I didn't see shawnCplus edit his post!
Last edited by nav33n; Jan 17th, 2008 at 8:17 pm.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 12
Reputation: crzycm16 is an unknown quantity at this point 
Solved Threads: 0
crzycm16 crzycm16 is offline Offline
Newbie Poster

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #4
Jan 17th, 2008
Originally Posted by nav33n View Post
And put commas.
Where ? lol
Also i took out the ";" and added commas but i now get the 'Error' message :-(
  1. <?php
  2. // MySQL connection variables
  3. $host="server";
  4. $username="Vetsform";
  5. $password="secret:-)";
  6. $db_name="Vetsform";
  7. $tbl_name="vetform";
  8.  
  9. // Connect to server and select database.
  10. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13. //Save data from the HTTP POST values submitted from the PDF
  14. extract($_REQUEST);
  15.  
  16. // Insert all the data from above into the table in the database
  17. $sql="INSERT INTO $tbl_name(VeteranName, Address, StateProv, ZipCode, Branch, Dateserved, Comments, guestname, Phonenumber, city)
  18. VALUES('$VeteranName',
  19. '$Address',
  20. '$StateProv',
  21. '$ZipCode',
  22. '$Branch',
  23. '$Dateserved',
  24. '$Comments',
  25. '$guestname',
  26. '$Phonenumber',
  27. $city')";
  28. $result=mysql_query($sql);
  29.  
  30. // If it worked, say so...
  31. // This will change later on so it won't have the like to view all users, obviously...that's just for testing purposes
  32. if($result){
  33. echo "Successful";
  34. }
  35.  
  36. else {
  37. echo "ERROR";
  38. }
  39.  
  40. // Close connection to the database
  41. mysql_close();
  42. ?>
Last edited by crzycm16; Jan 17th, 2008 at 8:25 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #5
Jan 17th, 2008
Be more descriptive with your error messages
  1. $result=mysql_query($sql) or die(mysql_error());
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #6
Jan 17th, 2008
Ok. What is the error now ? Print out the query. (print $sql; ) . Where are you assigning the tablename ($tbl_name) ? and NEVER display your host, username and password !
Last edited by nav33n; Jan 17th, 2008 at 8:22 pm.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 12
Reputation: crzycm16 is an unknown quantity at this point 
Solved Threads: 0
crzycm16 crzycm16 is offline Offline
Newbie Poster

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #7
Jan 17th, 2008
Originally Posted by ShawnCplus View Post
Be more descriptive with your error messages
  1. $result=mysql_query($sql) or die(mysql_error());

sure, but that is honestly what the page says, "error"
if i look at the source code it shows

  1. <b>Parse error</b>: parse error, unexpected $ in <b>/home/content/c/r/z/crzycm16/html/insert.php</b> on line <b>44</b><br />
  2. </object></layer></span></div></table></body></html>
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #8
Jan 17th, 2008
$city')"; This should have been '$city')" ;
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #9
Jan 17th, 2008
As a side note, you might want to obscure your server, password and username given that you just gave every single google user on earth access to it. If a mod is reading this please take that out for him.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 12
Reputation: crzycm16 is an unknown quantity at this point 
Solved Threads: 0
crzycm16 crzycm16 is offline Offline
Newbie Poster

Re: Help! Parse error: parse error, unexpected T_STRING

 
0
  #10
Jan 17th, 2008
Guys, Thanks for all the help i really appreciate it.
but now i really confused, haha

This is my code as of now.

  1. <?php
  2. // MySQL connection variables
  3. $host="server";
  4. $username="Vetsform";
  5. $password="secret:-)";
  6. $db_name="Vetsform";
  7. $tbl_name="vetform";
  8.  
  9. // Connect to server and select database.
  10. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13. //Save data from the HTTP POST values submitted from the PDF
  14. extract($_REQUEST);
  15.  
  16. // Insert all the data from above into the table in the database
  17. $sql="INSERT INTO $tbl_name(VeteranName, Address, StateProv, ZipCode, Branch, Dateserved, Comments, guestname, Phonenumber, city)
  18. VALUES('$VeteranName',
  19. '$Address',
  20. '$StateProv',
  21. '$ZipCode',
  22. '$Branch',
  23. '$Dateserved',
  24. '$Comments',
  25. '$guestname',
  26. '$Phonenumber',
  27. $city')";
  28. $result=mysql_query($sql) or die(mysql_error());
  29. // If it worked, say so...
  30. // This will change later on so it won't have the like to view all users, obviously...that's just for testing purposes
  31. if($result){
  32. echo "Successful";
  33. }
  34.  
  35. else {
  36. echo "ERROR";
  37. }
  38.  
  39. // Close connection to the database
  40. mysql_close();
  41. ?>

and my error when i hit submit is now
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 11"
Last edited by crzycm16; Jan 17th, 2008 at 8:32 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC