Page 1 of 1

Unexplainable string parsing error?!!

Posted: Sun May 15, 2011 1:24 am
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

Re: Unexplainable string parsing error?!!

Posted: Sun May 15, 2011 1:28 pm
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 . "";

Re: Unexplainable string parsing error?!!

Posted: Sun May 15, 2011 1:42 pm
by flying_circus
Let me simplify that for you.

correction:

Code: Select all

print "Hi! I want " . $orderQuantity;

Re: Unexplainable string parsing error?!!

Posted: Sun May 15, 2011 2:16 pm
by getmizanur
cheers for that. i wasn't sure if he wanted trailing double quotes so that he can put other text.

Re: Unexplainable string parsing error?!!

Posted: Sun May 15, 2011 6:23 pm
by anoveskey
Thanks guys!

I knew it was something really stupid that lack of sleep was causing me to overlook. :oops:

Re: Unexplainable string parsing error?!!

Posted: Mon May 16, 2011 10:12 am
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.