Php HEEEEEELP !!! (Syntax Error)

mydogisthebest

Free Member
Sep 27, 2008
166
9
The sunny south east
Hi, can someone please help with the following php code for a form output that i'm working on.

Below is the following from a php checker, but I cannot see the error.

I get a blank page output when trying to run the code when uploaded!


Parse error: syntax error, unexpected T_STRING in CODE on line 10 Errors parsing CODE
  1. <?php
  2. $length = $_POST['length'];
  3. $width = $_POST['width'];
  4. $height = $_POST['height'];
  5. $weight = $_POST['weight'];
  6. $discountcode = $_POST['discountcode'];
  7. if (!isset($_POST['submit'])) // if page is not submitted to itself echo the form
  8. "<div style="color: #FFFFFF;">Your quote for the following Small Parcel with the dimensions as follows:<br />". $length . " \" . " Length x " . $width . " " . " Width x " . $height . " " . " Height x " . $weight . " " . " Weight . " " . $discountcode . " " . " Discount Code. "</div>";<br />
  9. echo "<div style="color: #FFFFFF;">£12.00 inc vat. Complete the form to Book.</div>"; <br />
  10. ?>
Thanks in advance.
 
There are several issues..
1) Line 8 does not start with echo
2) the Word Weight in line 8 is not correctly enclosed in quotes
3) PHP doesn't like the \ in line 8 .. it's expecting an escape code and isn't getting one
3) You have put <br /> at the end of lines 8 and 9 without including them in the text or ending the PHP. You have to do one or the other.
4) If you use inline style you can't use double quotes to encapsulate your text because the double qoutes in the style directives confuse PHP. Use single quotes for your text.
5) #FFFFFFF is white .. if your page is white you won't see what the output is..


Have a look at this. I have corrected what you wrote although you are making life difficult for yourself by making these lines so complex.. Note that I have left the style colour white..

8. echo '<div style="color: #FFFFFF;">Your quote for the following Small Parcel with the dimensions as follows:<br />'. $length . ' ' . ' Length x ' . $width . ' ' . ' Width x ' . $height . ' ' . ' Height x ' . $weight . ' ' . ' Weight' . ' ' . $discountcode . ' ' . ' Discount Code. '.'</div><br />';
9. echo '<div style="color: #FFFFFF;">£12.00 inc vat. Complete the form to Book.</div><br />';

The revised code worked for me .. Hope that makes sense and helps. Yell if it doesn't.

p.
 
  • Like
Reactions: mydogisthebest
Upvote 0
PieterDyson,

Thank you soooo much.

I accidently left one of the backslashes in on my paste (I was trying that out earlier, to no avail!).

Text would be on a grey tabled background.

"Great!, now I can move on!"

or should I say ...

'Great!, now I can move on!'

lol. Ta again.
 
Upvote 0
If you search on Google for "php form generator free" you get plenty of online tools and free software for producing form code in PHP. It makes life so much easier :)
 
Upvote 0
And most of them are pants.

Building a php form from scratch is a doddle. There are loads of tutorials on how to do it.

Doing it yourself menas you have full control over the layout, valiudation, response and format of the email messages or how it writes to a database.
 
Upvote 0
future reference you can use PHP tags on this forum to make it easier to read:

PHP:
<?php
$like='this';

just use the square brackets php, or there is a little php button 2nd to last on the right in the advanced message editor
 
Last edited:
Upvote 0
I don't know exactly what you are doing with the form input in the greater picture of your application.

But, as a rule of thumb (if you aren't already intending to do so); validate all of your input and make sure to strip out any nasties that could be inputted by the user.
 
Upvote 0
future reference you can use PHP tags on this forum to make it easier to read:

PHP:
<?php
$like='this';
just use the square brackets php, or there is a little php button 2nd to last on the right in the advanced message editor

Just a more indepth answer to this..

By PHP tags, Joseph means
php.gif


Square brackets are
html.gif


You can also write the code in [ code ] code goes here [/ code ] without the spaces :)
 
Upvote 0

Latest Articles