...

View Full Version : Insert into randomly skipping entries



geofftop
05-10-2009, 11:00 AM
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.

timgolding
05-10-2009, 10:05 PM
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.

geofftop
05-14-2009, 08:41 AM
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!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum