Solarpitch Posted July 4, 2008 Share Posted July 4, 2008 Whats up guys, Here.. This is right isnt it? I'm basically trying to see if the sting has a " ' " in it and replace it with noting but doesnt seem to be working. Just wanted to run the syntax bu you. <?php $p = str_replace("'", "", $player); ?> Quote Link to comment Share on other sites More sharing options...
teynon Posted July 4, 2008 Share Posted July 4, 2008 Try using this: $p = str_replace("\'", "", $player); If not, its fine, just make sure your not confusing yourself somewhere else. Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 4, 2008 Author Share Posted July 4, 2008 No, I must be confusing myself somewhere. I'll have another look through the code and see whats going on. Cheers Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 4, 2008 Share Posted July 4, 2008 The OP's code should work. How do you know it's not working? Try this: <?php $player = "This string has single quotes (' ' ' ' ') in it"; $p = str_replace("'", "", $player); echo 'Original string: ' . htmlentities($player,ENT_QUOTES) . "<br>\n"; echo 'New string: ' . htmlentities($p, ENT_QUOTES); ?> Ken Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 4, 2008 Author Share Posted July 4, 2008 The reason I need to replace the " ' " is because the result will not show up in a pop up if it has this character. So if a players name is John O' Reilly, he wont display in the popup. Here I'm getting the persons name from the database, I just check to see if its a numeric value and if it is it goes to a different function to get there name. Then once I have the value in $player, if its John O' Reilly I want to replace the " ' " with noting so that it will show up when the mouse rolls over this javascript popup I have <?php $p1 = $row[3]; if(is_numeric($p1)){$player1 = get_name2($p1, "member");}else{$player1 = $p1;} if($p1 == ""){$player1 = "Available";} $p2 = $row[5]; if(is_numeric($p2)){$player2 = get_name2($p2, "member");}else{$player2 = $p2;} if($p2 == ""){$player2 = "Available";} $p3 = $row[7]; if(is_numeric($p3)){$player3 = get_name2($p3, "member");}else{$player3 = $p3;} if($p3 == ""){$player3 = "Available";} $p4 = $row[9]; if(is_numeric($p4)){$player4 = get_name2($p4, "member");}else{$player4 = $p4;} if($p4 == ""){$player4 = "Available";} $player1 = str_replace("'", "", $player1); $player2 = str_replace("'", "", $player2); $player3 = str_replace("'", "", $player3); $player4 = str_replace("'", "", $player4); ?> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 4, 2008 Share Posted July 4, 2008 Just use htmlentities($var, ENT_QUOTES); Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 4, 2008 Author Share Posted July 4, 2008 That doesnt work either Dark Water. Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 4, 2008 Author Share Posted July 4, 2008 Actually... There might be a chance I'm uploading the wrong file to the server, if I am... I'll personally ban myself from the site! :-\ Quote Link to comment Share on other sites More sharing options...
br0ken Posted July 4, 2008 Share Posted July 4, 2008 What data is actually in $player? If you could show us that it might help. Also, try running stripslashes() on $player before passing it to str_replace(). It's a long shot but it might just work! Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted July 4, 2008 Author Share Posted July 4, 2008 Yup.. I was uploading the file to the wrong directory. What I had first just works fine. Sorry for wasting your time... now where's that self ban button.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.