validate filter

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!

Moderator: General Moderators

Post Reply
jd57
Forum Newbie
Posts: 13
Joined: Tue Apr 21, 2009 8:04 am

validate filter

Post by jd57 »

Can someone tell me why the filter $PodName does not work, what wrong with this code?

Code: Select all

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]'; 
}  
Last edited by Benjamin on Sat May 02, 2009 4:22 pm, edited 2 times in total.
Reason: Changed code type to php.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: validate filter

Post by JAB Creations »

You seem to have a few things confused so let me help you sort it out...

Code: Select all

$y1 = 'text';
$hello1 = '$y1';
$hello2 = "$y1";
 
echo '<div>'.$hello1.'</div>'."\n";//outputs '$y1'
echo '<div>'.$hello2.'</div>'."\n";//outputs 'text'
Single and double quotes act differently in PHP.

Also never use the font element, it's been long deprecated, you should use the span element instead.

Code: Select all

<span class="size17">example text</span>

Code: Select all

span.class17 {font-size: 17px;}
Look more up about CSS while you're at it. Once you learn that you'll realize how you just can't live without it if you're going to even be half serious about coding. :wink:
jd57
Forum Newbie
Posts: 13
Joined: Tue Apr 21, 2009 8:04 am

Re: validate filter

Post by jd57 »

Hi
I think I made the right corrections to the code, but it does'nt work the way it should. I would like $PodName keeps the same if data is found in the database, or else add [Not Registered] to the name.

Code: Select all

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]"; 
}
Last edited by Benjamin on Sun May 03, 2009 3:22 am, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: validate filter

Post by McInfo »

JAB Creations wrote:

Code: Select all

<span class="size17">example text</span>

Code: Select all

span.class17 {font-size: 17px;}
Correction:

Code: Select all

span.size17 {font-size: 17px;}
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Tue Jun 15, 2010 3:18 pm, edited 1 time in total.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: validate filter

Post by McInfo »

jd57 wrote:I think I made the right corrections to the code, but it does'nt work the way it should.
There is not enough code there to make a conclusive determination about what is wrong. I think you are probably using too many variables, which is confusing you about what any of them hold. Also, on line 9, $pod_exist is assigned a string, but it is never used because the script terminates on the next line.

Edit: This post was recovered from search engine cache.
Post Reply