Solved

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

Posted on 2008-06-25
5
683 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

729 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