SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query-dump problem

    I use the following script to dump query result into another table. There was a problem.... records with "'" cannot be inserted into the second table. For example, Men's Tennis. How come? Is there anyway to solve this?


    PHP Code:
    $query mysql_query("select heading,Topic,FileCode,fk from table1");
    while (
    $row mysql_fetch_array($query)) { 
    mysql_query("insert into table2(FileCode,heading,Topic,fk) values ('".$row['FileCode']."','".$row['heading']."','".$row[Topic]."','".$row['fk']."')"); 

    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why use two queries?

    PHP Code:
    $result mysql_query("insert into table2(FileCode,heading,Topic,fk) select FileCode,heading,Topic,fk from table1"); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is amazing! It solves the problem!
    But why?
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by trigger8
    This is amazing! It solves the problem!
    But why?
    why? to get the original to work, you would need to use addslashes() on the data before INSERTing it. so, that's why, but it doesn't matter cuz you should do it like freddy said anyway.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  5. #5
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you need to, here's the manual page about this function


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •