Solved

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

Posted on 2008-06-25
5
677 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 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:Vel Eous
Vel Eous 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
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…

737 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