SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 1999
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After posting a few times on this board, I realised I didn't grab the essential parts from my PHP book, so I went back and re-read it. And though I'mm much better off now, I am still having this one annoying problem:

    My goal was to move a record from one table, to another table, which happens to have the exact same field settings. I did a msql_fetch_row on the record I wanted, and received the record information.

    I then planned on creating the new record in the new table, inserting the information, and deleting the old record afterwards, and the move would be completed. Unfortunetly, as I move the record data, all the fields transfer except for two. Both of these were set as TEXT not unique, and both were orginally aquired through a textarea box.

    Can anyone tell me what the problem is, and how I may fix it? Thanks in advance for your troubles.

  2. #2
    SitePoint Enthusiast Jujubee's Avatar
    Join Date
    Mar 2001
    Location
    Canada
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would help if you'd post your code - I'm sure someone will figure it out. My guess right now is quotes or commas in the textarea but I'm new at this too so...

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 1999
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure thing, whatever helps.


    The coding I am using. Keep in mind that all the text fields are text based, so they all have quotes.

    $result = mysql_query ("select * from $table_old_name where game_title = '$old_name'");
    $info = mysql_fetch_row ($result);
    $info[0] = $new_name;

    I changed the first field which is also the primary key, so I was wrong in saying that I am simply moving the fields; I actually change the first field, THEN move everything.

    $result2 = mysql_query ("insert into $table_new_name (game_title, alt_title, guide1, guide2, guide3, guide4, guide1_type, guide2_type, guide3_type, guide4_type, link) values ('$info[0]', '$info[1]', '$info[2]', '$info[3]', '$info[4]', '$info[5]', '$info[6]', '$info[7]', '$info[8]', '$info[9]', '$info[12]')");


    This first query works. The new table is made, and everything is operational inside of it. I made it so that it places NULL into the two text fields I am having trouble with, so that way, when this record is created, I can rest the blame on the two remaining fields. Then I try to fill in one of the two fields:

    $result3 = mysql_query ("update $table_new_name set cheatcodes = '$info[10]' where game_title = '$info[0]'");

    This last request does not work for either of the two text fields. Even though I posted only one change, I tried both out. Also, I know the contents of the field exist for I do an echo command after nl2br() the field and the content appears as it should.

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just going by the clue that the troublesome table fields are data from textarea form fields - did you use addslashes() before inserting the text into the table at the very beginning, when you are processing the form input? if not this may be biting you now. Just a guess.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 1999
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good guess.

    I did not use this, though I read about it. I didn't see how it would effect me. Could you please tell me how it IS effecting me?

  6. #6
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Canuk
    Could you please tell me how it IS effecting me?
    Not really!

    Did the strings contain any single or double quotes?
    Also, with textareas, your carridge returns "\r" and newlines "\n" will be effected if you don't use addslashes(). Check the documentation at www.php.net

    Don't forget to use stripslashes() before outputing the string to the browser.


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
  •