•
•
•
•
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
![]() |
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
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
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();
?>•
•
Join Date: Apr 2005
Location: New York state
Posts: 449
Reputation:
Rep Power: 5
Solved Threads: 66
Take out the semicolons after the Values ie.,
Also, don't do
just do
php Syntax (Toggle Plain Text)
$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);
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+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
And put commas. 
Edit: I didn't see shawnCplus edit his post!

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*
*PM asking for help will be ignored*
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
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.
•
•
Join Date: Apr 2005
Location: New York state
Posts: 449
Reputation:
Rep Power: 5
Solved Threads: 66
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+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
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*
*PM asking for help will be ignored*
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
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>
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 238
•
•
Join Date: Apr 2005
Location: New York state
Posts: 449
Reputation:
Rep Power: 5
Solved Threads: 66
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+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
Guys, Thanks for all the help i really appreciate it.
but now i really confused, haha
This is my code as of now.
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"
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
- Parse error, unexpected T_STRING, expecting T_CASE (PHP)
- Parse error: syntax error, unexpected T_STRING in c:/.......... (PHP)
- parse error, unexpected T_STRING in (PHP)
- Parse error: parse error, unexpected T_STRING on line 12 (PHP)
- Please Help! parse error, unexpected T_STRING (PHP)
- Parse error: parse error, unexpected T_STRING (PHP)
- PHP Parse error: parse error, unexpected T_STRING (PHP)
- Parse error: parse error, unexpected T_STRING in /home/thei2k9/public_html/includes/f (PHP)
Other Threads in the PHP Forum
- Previous Thread: Alter many files, all with same variable in them
- Next Thread: doc to html



Linear Mode