Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
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…

911 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

24 Experts available now in Live!

Get 1:1 Help Now