Click to See Complete Forum and Search --> : Parse Error


Magikey
06-29-2004, 10:56 PM
I received this wierd message:

Parse error: parse error, expecting `','' or `';'' in /home/iwdtests/public_html/PHPAdvanced/Registration/register.php on line 176

I understand what parse error means, and was doing well finding my mistakes. However, on line 176, this is the code:


<tr>
<td align="right">Email Address:</td>
<td align="left"><input name="email" type="text" size="25" maxlength="60" value="<?=HTTP_POST_VARS[email]?>"></td>
<td align="left"><small>Use whichever email address you want to receive notices, etc.</small></td>
</tr>


Since value="<?=HTTP_POST_VARS[email]?>"> is the only php on that line, I don't understand where the "," should be placed.

I do know that I am subject to finding more small errors, but this one has me stumped.


Thanks in advanced.

BTW, I'm working from PHP Advanced, by Larry Ullman, page 135.

Peggy

MstrBob
06-29-2004, 11:27 PM
<input name="email" type="text" size="25" maxlength="60" value="<?PHP echo($_POST['email']);?>"></td>
<td align="left">


That should work. You need to echo the value, and should use $_POST[] instead, I don't trust superglobals.

ShrineDesigns
06-29-2004, 11:35 PM
MstrBob, <?=$var?> and <?php echo $var; ?> will output the same results, the first method is shorthand, however, it will only work if short_open_tag is enabled

MstrBob
06-29-2004, 11:37 PM
Really? That doesn't work for me. I shall have to look that up in my .ini file...

Anywho, the issue were your missing single quotes in $HTTP_POST_VARS[].

shimon
06-30-2004, 03:56 AM
Magic - ignore 'em all ;) the issue is that you missed the $ sign off of $HTTP_POST_VARS

Bob - $HTTP_POST_VARS is not a superglobal, whereas $_POST actually is. Check it out: http://www.php.net/manual/en/reserved.variables.php

$_POST: This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_POST; to access it within functions or methods, as you do with $HTTP_POST_VARS.

MstrBob
06-30-2004, 07:06 PM
Argh, I'm so confused now x.x

shimon
07-01-2004, 07:31 AM
bonkers isn't it? I had always thought the two were identical - just with one being shorthand for the other. We live and learn eh? :)