Forum Moderators: coopster

Message Too Old, No Replies

Echoes variable name not value...help

Just when I think I'm beginning to understand...

         

meganp

7:37 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



Hello,

I'm trying to pass a variable, but for some reason it's not grabbing it. I'm sure it's something obvious, but I'm not able to track it down.

Here's the relevant code. What I'm trying to do is get the affiliate ID (affilID) in order to narrow the results of the query to the database. I've echoed out the variable but all it prints the variable name, not value. Thanks (as always) for any help with this.

<form name="form1" method="POST" action="<?php echo $_SERVER ['PHP_SELF'];?>">
<p>Please enter your Affiliate ID: <input name="affilID" type="text" id="affilID"></p>
<p>Select Date Range:</p>
<p><input type="radio" name="whichrange" value="1" checked> From
<select name="from1">
<option value="Select Date" selected>--Select Date</option>
<option value="2004-12-01 00:00:00">2004-12-01</option>
<option value="2005-01-01 00:00:00">2005-01-01</option>
<option value="2005-02-01 00:00:00">2005-02-01</option>
<option value="2005-03-01 00:00:00">2005-03-01</option>
<option value="2005-04-01 00:00:00">2005-04-01</option>
<option value="2005-05-01 00:00:00">2005-05-01</option>
<option value="2005-06-01 00:00:00">2005-06-01</option>
</select>&nbsp;
to
<select name="to1">
<option value="Select Date" selected>--Select Date</option>
<option value="2004-12-31 23:59:59">2004-12-31</option>
<option value="2005-01-31 23:59:59">2005-01-31</option>
<option value="2005-02-28 23:59:59">2005-02-28</option>
<option value="2005-03-31 23:59:59">2005-03-31</option>
<option value="2005-04-30 23:59:59">2005-04-30</option>
<option value="2005-05-31 23:59:59">2005-05-31</option>
<option value="2005-06-30 23:59:59">2005-06-30</option>
</select>&nbsp;</p>
<p>or enter dates in the format of yyyy-mm-dd:</p>
<p><input type="radio" name="whichrange" value="2"> From:
<input name="from2" type="text" id="from2">
to
<input name="to2" type="text" id="to2">
</p>
<p>
<input type="submit" name="Submit" value="View Sales">
<input type="reset" name="Submit2" value="Reset">
</p>
</form>
<?php
} else {
// form has been submitted
// create short variable names
$affilID = $_POST['affilID'];
echo '$affilID';

Here's what it prints:

$affilID

Smad

7:46 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



instead of echo '$affilID';

try echo $affilID;

mincklerstraat

7:47 pm on Jan 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



echo '$affilID';

will output the string which reads: $affilID
Putting something inside single quotes, you tell PHP that this is a string, just a row of characters and such, and not anything it should try to do something with.
Double quotes are somewhat different; stick for the moment to single quotes and your life will be easier.

You want:

echo $affilID;

or maybe:
echo '$affilID is '.$affilID;

<edit>Smad: Jinx!</edit>

meganp

8:21 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



Many thanks to you both!

I think my permanent motto should be, "The farther I go the behinder I get"... I should have remembered that difference.

Thanks again!