?
Solved

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

Posted on 2008-06-25
5
Medium Priority
?
688 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 800 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:Vel Eous
Vel Eous earned 600 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 600 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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 look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 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