Forum Moderators: coopster

Message Too Old, No Replies

PHP \'s

         

iainsmith4

4:23 pm on Mar 16, 2010 (gmt 0)

10+ Year Member



Hi all, I am trying to display on my page a name from a MYSQL database where the name is "iain's".

When it stored in the database it is done as "iain\'s" as I have filtered the inputing of the data into the database.

Now I want to display this back on a page as "iain's" without the slash and making sure it is clean data.

How would I go about this is the str_replace the best

ie: <?php echo str_replace("\\", "",$row_rsRecord['name']); ?>

or is there another way?

jatar_k

4:31 pm on Mar 16, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



[php.net...]

Anyango

4:31 pm on Mar 16, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



have you used addslashes() before saving the data ? try using stripslashes() on the data before you output. Best would be to use mysql_real_escape_string() and you wont have to worry about formatting output when you display (apart from other benefits).

iainsmith4

8:21 am on Mar 17, 2010 (gmt 0)

10+ Year Member



Hi Anyango, many thanks for your help! that stripslashes() worked a treat! Cheers

Iain

omoutop

9:37 am on Mar 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



actually it's what jatar_k suggested at first :)

Anyango

10:18 am on Mar 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep he did first, sorry we were both typing the post at same time so i didnt get to see his jatar_k's response before posting my message.

iainsmith4

11:04 am on Mar 17, 2010 (gmt 0)

10+ Year Member



Not a problem guys, thanks for the help anyway from both, much appricated!