| | |
Help! Parse error: parse error, unexpected T_STRING
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
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 Syntax (Toggle Plain Text)
<?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(); ?>
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 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.
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.
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
Solved Threads: 0
Where ? lol
Also i took out the ";" and added commas but i now get the 'Error' message :-(
Also i took out the ";" and added commas but i now get the 'Error' message :-(
PHP Syntax (Toggle Plain Text)
<?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 8:25 pm.
Be more descriptive with your error messages
PHP Syntax (Toggle Plain Text)
$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.
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.
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
Solved Threads: 0
•
•
•
•
Be more descriptive with your error messages
PHP Syntax (Toggle Plain Text)
$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
PHP Syntax (Toggle Plain Text)
<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>
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.
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.
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
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 Syntax (Toggle Plain Text)
<?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 8:32 pm.
![]() |
Similar Threads
- 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
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube







! 