Unexplainable string parsing error?!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anoveskey
Forum Newbie
Posts: 9
Joined: Sun Sep 26, 2010 7:16 pm

Unexplainable string parsing error?!!

Post by anoveskey »

Hey all, I am working on a form to print up an order for a CD on my site. But I am getting an error message that I cannot for the life of me explain! Here is the code:

Code: Select all

<?php
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$street = $_POST['street'];
$city = $_POST['city'];
$state = $_POST['state'];
$zipCode = $_POST['zipCode'];
$orderQuantity = $_POST['orderQuantity'];
$email = $_POST['email'];
$copyType = 'copy';

print "To: <br />";
print $firstName . " " . $lastName;
print "<br />";
print $street;
print "<br />";
print $city . ", " . $state . " " . $zipCode;
print "<br />";
print $email;
print "<br /><br />";
print "Hi! I want " . $orderQuantity . ";
$castQuantity = (int)$orderQuantity;
if ($castQuantity > 1) { $copyType = 'copies'; };
print $copyType;
print " of The X of Art EP";
print "<br />";
$total = $orderQuantity * 2.00;
print "Enclosed is my check or money order of \$" . number_format($total, 2) . " + \$2.95 for shipping and handling.";
print "<br />";
print "Make your payment out to ####, LLC"; 
?>
The error is on line 25, (print " of the X of Art EP";). I have commented it out, refreshed the page, and done just about everything else I can think of. Any suggestions would be greatly appreciated!

- Adam
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: Unexplainable string parsing error?!!

Post by getmizanur »

the line below is causing the problem, you have single double quote ("). it should be ""

Code: Select all

print "Hi! I want " . $orderQuantity . ";
correction:

Code: Select all

print "Hi! I want " . $orderQuantity . "";
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Unexplainable string parsing error?!!

Post by flying_circus »

Let me simplify that for you.

correction:

Code: Select all

print "Hi! I want " . $orderQuantity;
User avatar
getmizanur
Forum Commoner
Posts: 71
Joined: Sun Sep 06, 2009 12:28 pm

Re: Unexplainable string parsing error?!!

Post by getmizanur »

cheers for that. i wasn't sure if he wanted trailing double quotes so that he can put other text.
anoveskey
Forum Newbie
Posts: 9
Joined: Sun Sep 26, 2010 7:16 pm

Re: Unexplainable string parsing error?!!

Post by anoveskey »

Thanks guys!

I knew it was something really stupid that lack of sleep was causing me to overlook. :oops:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Unexplainable string parsing error?!!

Post by John Cartwright »

It helps to use an IDE that supports syntax highlighting. It was very trivial to determine problematic area by just by the color of your code.
Post Reply