I screwed up. Need major help.

From: Date: Fri, 21 Jul 2000 22:33:42 +0000
Subject: I screwed up. Need major help.
Groups: php.general 
Request: Send a blank email to php-general+get-7641@lists.php.net to get a copy of this message
HELP!!! I (don't ask how) erased a table from my mysql database. Luckily, I have it email me the data every 1000 records. With that said, I need urgent help getting these records back into the database. The big problem right now is this, for every 6 records I have, I need to increment a counter by 1. ie,,,,,the first 6 records go to ticket 1, next 6, ticket 2, and so on. Right now, I have all the records in a text file in this format. INSERT INTO archivepicks (ticket, pick) VALUES ('$ticket_id','3'); Any idea on how to get 15,000+ lines back into the db while maintaining the ticket numbers? I was going to do an ereg_replace(), but I cannot get it to replace the "$ticket_id" with the actual variable of the ticket id. Below is the quick little program that I wrote. It is sloppy but I am in a hurry. Can anyone help with this urgent need? MANY thank in advance. CDitty <? // open a local file if(!($myfile = fopen("test.txt", "r"))) { print("file could not be opened"); exit; } $i = 1; while(!feof($myfile)){ if($i = 1){ $ticket = 1; } if($i = 2){ $ticket = 2; } if($i = 3){ $ticket = 3; } if($i = 4){ $ticket = 4; } if($i = 5){ $ticket = 5; } if($i = 6){ $ticket = 6; } $numbers = fread($myfile, 66); echo ereg_replace("$ticket_id", "$ticket", $numbers); } // close the file fclose($myfile); ?>

« previous php.general (#7641) next »