#1
  1. No Profile Picture
    dhiraj
    Guest
    Devshed Newbie (0 - 499 posts)
    I'm trying to insert a value into a table thru a varible which ia a string type.
    If the string is a simple text without any quotes (' or ") embeded, it's inserting but if there is any quotes embeded in the string it does not inserts, the reason being I'm writing the following code :
    $query = "INSERT INTO (table) VALUES('$country','$description')";
    $result = MYSQL_QUERY($query);

    Now the variable '$description' contains a string which can have quotes embeded like (I'm a hard working guy). Now since there is a (') in the string it causes problem and does not execute the insert statement.
    How can I overcome this problem.

    Pl. help.

    Dhiraj

  2. #2
  3. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Look in the manual under addslashes()

    Try:

    $description=addslashes($description);

    before the query.

Similar Threads

  1. Replies: 13
    Last Post: June 4th, 2004, 04:49 PM
  2. walking through database values
    By beemee_freeserv in forum PHP Development
    Replies: 1
    Last Post: February 11th, 2004, 09:48 AM
  3. variable variables problem
    By gbow in forum PHP Development
    Replies: 5
    Last Post: February 10th, 2004, 10:04 AM
  4. Wierd problem inserting data with VB6
    By gregquinn in forum MySQL Help
    Replies: 5
    Last Post: February 2nd, 2004, 07:37 AM
  5. Replies: 2
    Last Post: February 2nd, 2004, 12:24 AM

IMN logo majestic logo threadwatch logo seochat tools logo