View Full Version : if statement not working

06-22-2006, 11:34 AM
I have been struggeling with this problem all morning and I really can't figure it out. I have used this many times in the past, it's very simple but not working this time.

I have a simple form to search a database:

<form method="post" action="result-list.php">
<input name="search-party" type="hidden" value="y">
<div style="padding:4px; border-style:solid; border-width:1px; border-color:#ccc; background-color:#fff">
<b>Find Parties:</b>&nbsp;
<input type="text" size="8" name="q">
<input type="submit" value="go!">
<br />
<div align="right">
<a href="submit-party1.php">List your party</a>

In the processing file, I check for the presence of the search-party, then include a chunk of code to search the DB:

if ($search-parties == "y")

Strangely, the if statement is ignored, whether or not $search-parties is passed and regardless of its value.

If I print $search-parties, it shows "0".

Any idea?

06-22-2006, 12:09 PM

if ($_POST['search-parties'] == "y")

06-22-2006, 12:14 PM
In your form, you're using the variable name search-party, but your PHP references it as $search-parties.

06-22-2006, 01:43 PM
thanks that works!

06-22-2006, 08:07 PM
I think you shouldn't use variable with the - sign, otherwise php can understand it like a math example

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum