Forum Moderators: coopster

Message Too Old, No Replies

PHP quotes problem

         

webfoo

6:52 pm on Jan 6, 2010 (gmt 0)

10+ Year Member



Hey everyone. Haven't been doing web stuff for a while, getting back into it. Error on line 1 of the following:

echo "<label for=\"srno\">Serial Number: </label><input type=\"text\" name=\"srno\" id=\"srno\" value=\"";
echo $row['srno'];
echo "\" />

This is supposed to create a text input with a value $row['srno'] which was pulled from a database.

webfoo

6:55 pm on Jan 6, 2010 (gmt 0)

10+ Year Member



By the way, the error I'm getting is:

Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\qm10\equip_edit_form.php on line 72

Dijkgraaf

7:40 pm on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is line 72 the following?
echo "\" />
If so you are missing a closing "; and it should read
echo "\" />";

[edited by: Dijkgraaf at 7:41 pm (utc) on Jan. 6, 2010]

Frank_Rizzo

7:41 pm on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is on line 72 ...

Dijkgraaf beat me to that one.

---

One other point. If you don't want to parse variables in a line then just wrap the line with single quotes.

rather than:

echo "<label for=\"srno\">Serial Number: </label><input type=\"text\" name=\"srno\" id=\"srno\" value=\"";

use

echo '<label for="srno">Serial Number: </label><input type="text" name="srno" id="srno" value=""';

You would only need to use " instead of ' if you had something like this:

$abc='srno';

echo "<label for=\"$abc\">Serial Number: </label><input type=\"text\" name=\"$abc\" id=\"$abc\" value=\"";

Frank_Rizzo

7:44 pm on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually this would actually be better:

echo '<label for="srno">Serial Number: </label><input type="text" name="srno" id="srno" value="' . $row['srno'] . '" />';

webfoo

8:07 pm on Jan 6, 2010 (gmt 0)

10+ Year Member



Thank you everyone. The issue was resolved. Line 72 now reads your suggestion, Frank.

I knew it was a stupid problem, I always do that. Thanks once again. I'm sure I'll be back again with more stupid problems over the next few days of development with my new ap.