Patrick3002 Posted February 19, 2007 Share Posted February 19, 2007 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 More sharing options...
Patrick3002 Posted February 19, 2007 Author Share Posted February 19, 2007 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 More sharing options...
Patrick3002 Posted February 19, 2007 Author Share Posted February 19, 2007 Any help please? Link to comment https://forums.phpfreaks.com/topic/39155-script-trouble/#findComment-188571 Share on other sites More sharing options...
skali Posted February 19, 2007 Share Posted February 19, 2007 Try using if ( $apos || $arpos || $spos){ //whatever } Link to comment https://forums.phpfreaks.com/topic/39155-script-trouble/#findComment-188609 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.