Thread: SINGLE QOUTES

    #1
  1. No Profile Picture
    mfitzgerald
    Guest
    Devshed Newbie (0 - 499 posts)
    How do i insert a row into mySQl from a form, if the inputs of the form contain a '? Don't single qoutes deliminate the array that is being added to the table?
    for example-
    How do i make this work?
    INSERT INTO my_table VALUES('123', 'Jefferson's house')

    ------------------
  2. #2
  3. No Profile Picture
    chyrag
    Guest
    Devshed Newbie (0 - 499 posts)
    If your values are in stored in variables then you can just say $sql = "insert into table values ('$field1','$field2');" and then do a mysql_db_query($db, $sql).

    chyrag.
  4. #3
  5. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Um, no, you can't. The variables are not passed to mysql. Mysql has no idea what's in your php variables. php must pass the data in the variables to mysql and if there is a single quote it WILL send back an error. To prevent this you need to use addslashes().

    $query="insert into $table values('addslashes($data)','addslashes($moredata)')";


    [This message has been edited by rod k (edited 07-26-99).]

    [This message has been edited by rod k (edited 07-26-99).]

Similar Threads

  1. single qoutes replacement
    By mfitzgerald in forum PHP Development
    Replies: 3
    Last Post: March 19th, 2004, 06:12 AM
  2. Windows 2003 NAT on single interface
    By gearip in forum Windows Help
    Replies: 0
    Last Post: November 15th, 2003, 07:39 AM
  3. xsl - how to escape single quotes
    By hedge in forum XML Programming
    Replies: 1
    Last Post: November 7th, 2003, 07:11 PM
  4. DNS single lable hostname problem
    By rdore in forum DNS
    Replies: 0
    Last Post: September 3rd, 2003, 11:43 AM
  5. Can you make a single php file handle all/most requests
    By md_doc in forum PHP Development
    Replies: 4
    Last Post: May 29th, 2003, 07:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo