Jump to content

Script trouble...


Patrick3002

Recommended Posts

OK, i have a script where i use the strpos function on a var to check and see if there is a certain character within the var, in my situation i need to check for an occurances of a '. If any are found then a messages is displayed.

 

Now... I also want to check another var for an occurance of a ". I tried using the same method i used to check for any ' but it doesn't want to work for ". If anyone could possibly help me with what im doing wrong it would be greatly appreciated.

 

Heres my code:

 


$first="'";
$second='"';
$first = addslashes($first);

$apos = strpos($artist, $first);
$arpos = strpos($artist, $second);
$spos = strpos($song, $second);

if ( $apos || $arpos || $spos === true ) {

       echo "$apos";
       echo "$spos";
       echo "<font color=red>[sTATUS]</font>: The artist cannot contain a ' or \"";

 

 

The script runs fine with the $apos and $arpos vars but not with the $spos var... i don't understand.

 

I've tried setting the $second var to $second="\""; aswell it still works with $apos and $arpos though just doesn't want to go through with $spos.

 

Thanks for the help.

Link to comment
https://forums.phpfreaks.com/topic/39155-script-trouble/
Share on other sites

I've found the problem, it doens't read anything after the last or ( || ) operators so it seems to only be seeing:

 

if ( $apos || $arpos  === true ) {

       echo "$apos";
       echo "$spos";
       echo "<font color=red>[sTATUS]</font>: The artist cannot contain a ' or \"";

 

 

I have no idea why in the world it would be doing that...

 

Does anyone else?

Link to comment
https://forums.phpfreaks.com/topic/39155-script-trouble/#findComment-188557
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.