View Full Version : How to add a filter
Hi everyone
I would like to add a filter that will check a name in the database, If name does not exist then it should add [Not Registered] to the name
I tried to write the code in blue but I get an error, can someone help
mysql_numrows($result);
if($num > 0){
$name_exist = "<font size=5>$BloomName is a Registered Cultivar. Please Rename your Cultivar.</font>";
echo $name_exist;
exit;
} else {
$name_ok = "<font size=5>$BloomName is not a Registered Cultivar. You may register as $BloomName.</font>";
$pod_reg = "$PodName";
exit;
} else
$pod_reg = "$PodName+[Not Registered]";
}
Schmoopy
05-01-2009, 10:45 PM
Well, to do what you want to do (I think) edit the code like this:
else
$pod_reg = $PodName . ' [Not Registered]';
The "." concatenates the string so it will out the variable and then the sceond part, i.e:
$PodName = 'Schmoopy';
This will output : Schmoopy [Not Registered]
Hope this helps.
Hi
I get the following error, where is it?
Parse error: syntax error, unexpected $end in /home1/internb7/public_html/icra/form2.php on line 1555
if($num > 0){
$name_exist = "<font size=5>$BloomName is a Registered Cultivar. Please Rename your Cultivar.</font>";
echo $name_exist;
exit;
} else {
$name_ok = "<font size=5>$BloomName is not a Registered Cultivar. You may register as $BloomName.</font>";
if($num > 0){
$pod_exist = "$PodName";
exit;
} else {
$pod_reg = $PodName . ' [Not Registered]';
}
Schmoopy
05-02-2009, 02:59 PM
You didn't end one of your conditional statements:
} else {
$name_ok = "<font size=5>$BloomName is not a Registered Cultivar. You may register as $BloomName.</font>";
}
Change your code to the above, or you can take out the curly braces all together, as you don't need them for a one line command.
Hi
Thanks for your help, now it works, but I realize that $podreg is not in the database therefore I only get [Not Registered] echo without the name, can I add a code that gets the name from the PodName text field in the form? if so how
if($num > 0){
$name_exist = "<font size=5>$BloomName is a Registered Cultivar. Please Rename your Cultivar.</font>";
echo $name_exist;
exit;
} else {
$name_ok = "<font size=5>$BloomName is not a Registered Cultivar. You may register as $BloomName.</font>";}
if($num > 0){
$pod_exist = "$PodName";
} else {
$podreg = $Pod_Name . ' [Not Registered]';}
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.