#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    32
    Rep Power
    15
    Hello,

    I've got a problem when using my PHP script with a mySQL database. It's so that I enter a text like for example in a table:

    it's my comments blah blah

    --------
    Then it gives me an error that I can't use the "'" sign, I've looked up pages but I haven't really found a good way to do this.

    I'm using this for displaying different records with the user's personal information so I would like this invaild charater to be replaced before the user's page is viewed.

    I've seen this made on other scripts but i'm not using a form of any kind yet but any suggestions are appreciated.

    Thanks,
    Toby
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    escape it ! with a "" so simon's becomes simon's

    Better still use addslashes() before you pass the data to the db , and stripslashes() when you call it back out.

    if $str contains the contents of a text field with ' & " etc in it

    $str=addslashes($str);//add to db//

    when you get it back from the db
    echo stripslashes($myrow[1]);

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL

Similar Threads

  1. Check MySQL Version thru PHP
    By wolftrap1 in forum PHP Development
    Replies: 2
    Last Post: February 11th, 2004, 08:51 PM
  2. Replies: 5
    Last Post: February 11th, 2004, 02:18 AM
  3. Replies: 0
    Last Post: February 10th, 2004, 11:44 PM
  4. Getting data from different tables in Mysql with PHP
    By Bosw8er in forum PHP Development
    Replies: 3
    Last Post: February 10th, 2004, 04:25 PM
  5. displaying mysql records (10 at a time) ?
    By tim0 in forum Perl Programming
    Replies: 10
    Last Post: January 29th, 2004, 01:48 AM

IMN logo majestic logo threadwatch logo seochat tools logo