vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Conditional based on strstr() (https://vborg.vbsupport.ru/showthread.php?t=78683)

sabret00the 03-24-2005 08:20 AM

Conditional based on strstr()
 
what's wrong with this conditional i thought i was being quite creative?

PHP Code:

            $og_personal_message "Please Enter A Personal Message The Group Description and Group Title Will Be Automatically Included.";
            
$og_personal_message trim($og_personal_message);
            
$personal_message trim($personal_message);


            if ((
strstr($personal_message$og_personal_message)) AND (strlen($personal_message) != strlen($og_personal_message)))
            {
                
$include_message TRUE;
            } 

it basically checks the default value of a textarea and if it's the same when the form is being processed ignores it, where as if it's been edited whether completely different or just had something added to it it will include it in it's DB actions, the strlen comparison works to perfection, however STRSTR() is a whole over matter :( i'm not sure if it's me trying to use the wrong function or just bad coding?

oh and i read php.net before i came here too :)

Marco van Herwaarden 03-24-2005 10:41 AM

Quote:

Originally Posted by sabret00the
oh and i read php.net before i came here too

Didn't know you could read THAT fast ;)

Back to your problem. I think your approach is not the best. What if the message is different (strstr would be false), it would not include the message.

Why not just a plain and simple:
PHP Code:

if ($personal_message != $og_personal_message 

That would be enough to find a changed message.

noppid 03-24-2005 11:59 AM

I'd have to agree and even submit that if that user passes anything in that var, assume it to be a change and use it. A very simple if($personal_message). Why ask for custom input if you are going to second guess them?

If they just ammend the message with the your above code, the logic would ignore it if I understand it correctly.

Do sanity checks on it if passed in like globalize at least, but not second guess their customization.


All times are GMT. The time now is 08:55 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02731 seconds
  • Memory Usage 1,722KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete