Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Insert into randomly skipping entries

    This Function was intended to copy a whole data base to another
    Both data bases are exactly the same accept for one entry all other fields besides the id feild default to null

    The source streaming db echos all the entries fine
    so I don't think its the source no errors seemed to be thrown
    the target data base shows up in php my admin but random entries are missing

    //so I suspect this is the culprit but I don't get it, its just random
    //mysql_query("INSERT INTO video_db (Title, Link, Description, Type)
    //VALUES ('$title', '$link', '$description', '$type')");

    PLEASE HELP THIS IS JUST SOME QUICK AND DIRTY CODE TO REPLACE SOME FEILDS
    SO I DON'T HAVE TO INPUT THEM
    I DONT GET IT NO ERRORS, EVERYTHING SEEMS FINE ACCEPT LIKE 40 OUT OF 500 ARE MISSING
    ALWAYS THE EXACT SAME ENTRIES BUT I CAN'T FIGURE OUT WHY IT WONT INSERT CERTAIN ENTRIES


    //HERES THE FUNCTION IN QUESTION
    function COPY_DB(){
    //JUST THE STANDARD CONNECTION CODE IN THIS FUNCTION
    $con = sql_connect_select_data_base();

    // Retrieve all the data from the "example" table
    $result = mysql_query("SELECT * FROM stream_cat")
    or die('user Selection Error: ' . mysql_error());

    //insert the first entry manually
    mysql_query("INSERT INTO video_db (Title, Link, Description, Type)
    VALUES ('HOW TO USE THE GEOFFTOP EMBEDDED VIDEO PLAYER', 'HELP.php', 'Overview of how to use the player and a explanation of the icons', '0')");

    while($row = mysql_fetch_array($result)){
    //this echos all the entries in the source file.
    echo $title;
    echo "</br>";

    $title = $row['Title'];
    $link = $row['Link'];
    $description = $row['Description'];
    $type = $row['Type'];
    //I'M ASSUMING THE PROBLEM IS HERE SINCE ALL ENTRIES
    //FROM THE SOURCE ECHO FINE
    mysql_query("INSERT INTO video_db (Title, Link, Description, Type)
    VALUES ('$title', '$link', '$description', '$type')");

    }

    mysql_close($con);
    }


    HERE THE LINK TO THE SITE IF ITS ANY HELP

    http://geofftop.com/gt_graphic.html

    GO TO GEOFFTOP EMBEDED VIDEO PLAYER LINK

    THE VIDEOS THAT YOU MOVE THROUGH ARE THE ENTRIES IN THE NEW DATA
    BASE BUT ITS LOSING ENTRIES ON THE CONVERSION

    BY THE WAY I'M VERY FLUENT IN C IVE WRITTEN COMPILERS FOR IT
    BUT SCRIPTING LANGUAGES ARE SOMEWHAT NEW TO ME SO BLAST MY CODE
    IM TRYING TO LEARN.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Maybe some of the entries have an single quote in them in which case using mysql_real_escape_string would solve the problem

    Oh and if you want a quicker response on this forum then enclose you php codes in [PHP] bbcode and not write in block capitals.
    You can not say you know how to do something, until you can teach it to someone else.

  • Users who have thanked timgolding for this post:

    geofftop (05-14-2009)

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry about the capitals, I don't go on the forums that often so i'm not up on the rules.

    Ha I think that solved the problem, I should have though of that, i got nailed by that echoing php to Java Script before.

    Thanks a lot timegolding you saved me some work now the computer can do it!!!


  •  

    Tags for this Thread

    Posting Permissions

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