User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 392,041 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,290 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1170 | Replies: 24 | Solved
Reply
Join Date: Jan 2008
Posts: 12
Reputation: crzycm16 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
crzycm16 crzycm16 is offline Offline
Newbie Poster

Help Help! Parse error: parse error, unexpected T_STRING

  #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

<?php
$host="p50mysql81.secureserver.net"; 
$username="Vetsform"; 
$password="Amina123"; 
$db_name="Vetsform"; 
$tbl_name="vetform"; 

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$VeteranName=$_REQUEST["VeteranName"];
$Address=$_REQUEST["Address"];
$StateProv=$_REQUEST["StateProv"];
$ZipCode=$_REQUEST["ZipCode"];
$Branch=$_REQUEST["Branch"];
$Dateserved=$_REQUEST["Dateserved"];
$Comments=$_REQUEST["Comments"];
$guestname=$_REQUEST["guestname"];
$Phonenumber=$_REQUEST["Phonenumber"];
$city=$_REQUEST["city"];

$sql="INSERT INTO $tbl_name(VeteranName, Address, StateProv, ZipCode, Branch, Dateserved, Comments, guestname, Phonenumber, city)
VALUES('$VeteranName';
'$Address';
'$StateProv';
'$ZipCode';
'$Branch';
'$Dateserved';
'$Comments';
'$guestname';
'$Phonenumber';
$city')
$result=mysql_query($sql);

if($result){
echo "Successful";
}

else {
echo "ERROR";
}

mysql_close();
?>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 449
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 66
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

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

  #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 7: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 z+*
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

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

  #3  
Jan 17th, 2008
And put commas.

Edit: I didn't see shawnCplus edit his post!
Last edited by nav33n : Jan 17th, 2008 at 7:17 pm.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

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

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

  #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 :-(
<?php
// MySQL connection variables
$host="server"; 
$username="Vetsform"; 
$password="secret:-)"; 
$db_name="Vetsform"; 
$tbl_name="vetform"; 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

//Save data from the HTTP POST values submitted from the PDF
extract($_REQUEST);

// Insert all the data from above into the table in the database
$sql="INSERT INTO $tbl_name(VeteranName, Address, StateProv, ZipCode, Branch, Dateserved, Comments, guestname, Phonenumber, city)
VALUES('$VeteranName',
'$Address',
'$StateProv',
'$ZipCode',
'$Branch',
'$Dateserved',
'$Comments',
'$guestname',
'$Phonenumber',
$city')";
$result=mysql_query($sql);

// If it worked, say so...
// This will change later on so it won't have the like to view all users, obviously...that's just for testing purposes
if($result){
echo "Successful";
}

else {
echo "ERROR";
}

// Close connection to the database
mysql_close();
?>
Last edited by crzycm16 : Jan 17th, 2008 at 7:25 pm.
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 449
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 66
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

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

  #5  
Jan 17th, 2008
Be more descriptive with your error messages
$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 z+*
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

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

  #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 7:22 pm.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

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

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

  #7  
Jan 17th, 2008
Originally Posted by ShawnCplus View Post
Be more descriptive with your error messages
$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

<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 />
</object></layer></span></div></table></body></html>
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

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

  #8  
Jan 17th, 2008
$city')"; This should have been '$city')" ;
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 449
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 66
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

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

  #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 z+*
Reply With Quote  
Join Date: Jan 2008
Posts: 12
Reputation: crzycm16 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
crzycm16 crzycm16 is offline Offline
Newbie Poster

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

  #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.

<?php
// MySQL connection variables
$host="server"; 
$username="Vetsform"; 
$password="secret:-)"; 
$db_name="Vetsform"; 
$tbl_name="vetform"; 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

//Save data from the HTTP POST values submitted from the PDF
extract($_REQUEST);

// Insert all the data from above into the table in the database
$sql="INSERT INTO $tbl_name(VeteranName, Address, StateProv, ZipCode, Branch, Dateserved, Comments, guestname, Phonenumber, city)
VALUES('$VeteranName',
'$Address',
'$StateProv',
'$ZipCode',
'$Branch',
'$Dateserved',
'$Comments',
'$guestname',
'$Phonenumber',
$city')";
$result=mysql_query($sql) or die(mysql_error());
// If it worked, say so...
// This will change later on so it won't have the like to view all users, obviously...that's just for testing purposes
if($result){
echo "Successful";
}

else {
echo "ERROR";
}

// Close connection to the database
mysql_close();
?>

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 7:32 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:11 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC