Solved

How to place back slashes in PHP echo statement with URL that includes two variables

Posted on 2008-06-25
5
647 Views
Last Modified: 2008-06-26
Hey

Having some problem getting this right...

                  echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"index.php?cellname=pagecells/admin/faq2.php&id='.$row['id'].'\">"

Its gota be the end part but I cant seem to stop this error showing...
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\AppServ\www\WTG2008\httpdocs\pagecells\admin\faq2.php on line 71

I'm sure someone will quickly tell me how lol so thanks in advance

0
Comment
Question by:Ryan Bayne
5 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 200 total points
ID: 21865917
Do it like this

echo "<form id='form1' name='form1' method='post' action='index.php?cellname=pagecells/admin/faq2.php&id=".$row['id']."'>";

Once you start a string with double quotes you can use single quotes within it to delimit HTML elements. It is a lot easier than keeping track of \" everywhere

0
 
LVL 14

Assisted Solution

by:Tchuki
Tchuki earned 150 total points
ID: 21866533
You don't even have to exit the echo if you don't want to:
echo "<form id='form1' name='form1' method='post' action='index.php?cellname=pagecells/admin/faq2.php&id={$row['id']}'>";

Open in new window

0
 
LVL 17

Assisted Solution

by:nplib
nplib earned 150 total points
ID: 21868228

echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"index.php?cellname=pagecells/admin/faq2.php&id=".$row['id']."\">";

Open in new window

0
 
LVL 2

Author Comment

by:Ryan Bayne
ID: 21879804
Gota love this stuff I prob wasted hours over last two months sticking in those slashes lol

Anyway you sorted that line and I applied same method to this line...
echo "<td><input size='15' name='id' type='text' id='id' value='<?php echo ".$row['id']." ?>'></td>";

And this is what appears in the text box...
<?php echo 1 ?>

And all the others on the form, show the php around the data. Tried all sorts things for ages. You would think I would atleast get it accidently!
0
 
LVL 2

Author Comment

by:Ryan Bayne
ID: 21879921
Have the answer managed myself

                  echo "<td><input size='15' name='id' type='text' id='id' value=".$row['id']."></td>";

Thanks I think I'll have no more problems with these again thanks to your advise
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now