Re: I screwed up. Need major help.
| From: | O. | Date: | Fri, 21 Jul 2000 23:31:42 +0000 |
| Subject: | Re: I screwed up. Need major help. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7647@lists.php.net to get a copy of this message | ||
"CDitty" <mail@redhotsweeps.com> wrote in message
news:4.2.2.20000721172438.00aea370@redhotsweeps.com...
> 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;
> }
Open a file to write to. Write a comma delimited file, then import it into
mySQL.
> $i = 1;
>
> while(!feof($myfile)){
increment $i on every iteration.
The ticket number is then ($i mod 6) + 1, and $i is the number of records.
> if($i = 1){
> $ticket = 1;
> }
<snip>
> $numbers = fread($myfile, 66);
> echo ereg_replace("$ticket_id", "$ticket", $numbers);
> }
I've no clue what your data is, and thus no idea why you're using
ereg_replace.
--
O.