PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I’m setting up a conditional statement that ensures that a selection is made so that the word ‘Select’ is not entered into the database rather than a house name from the select list.
if ($_POST['property'] != "\'%\") {
$messageproperty = '<b>Required</b>';}
But it is not fully returning what I want. If I use echo $_POST['property'] ; I can see \'%\' being displayed in the browser and if I make a selection this is also returns the selected text ok. If I physically add House 3 into if ($_POST['property'] != " House 3 ") then I get the desired result so I think I’m close but don’t fully understand how to pass this \'%\' .
Thanks for your reply.
No this doesn’t work either in that I keep seeing ‘Required’ regardless of whether I make a selection or not.
Thanks again for your help
B
if ($_POST['property'] =="'%'") {
$messageproperty = '<b>Required</b>';
if ($_POST['property'] =='%') {
$messageproperty = '<b>Required</b>';
Unfortunately doesn’t return ‘Required’ at all. I wonder (as a beginner I might add) if I can test for \'%\' as in the backslashes too as this is what is echoed in the browser.
Thanks for your help Jari but I still am getting no result. Basically as before the ‘Required’ message is not showing. I have tried everything I can but I’m at a complete loss. I have posted a good bit of the code I’m using but I wonder though that running a conditional statement must be normal enough for select boxes but how it this normally done or what am I doing wrong in my approach?
Thanks again all help is most gratefully received.
B
Are you sure this is he exact code used? It has some obvious syntax errors, for example in line 9 where does that { comes from ? And in any case I really don't see the point of assigning '%' as the value the first option instead of just %, in other words $value='%' and not $value=\"'%'\"
Here is a working examble with % passed. If I were you I'd use just % it's much less trouble with quotation marks. Also you might want to think again all these <?php blocks, code below is quite hard to read and it's easy to make mistakes.