How do I insert this into the database?
I have this file:
[player_id] => 70658
[mobile_number] => 09********
[name] => gorbani
[password] => ******
[verification_code] => KUTY6U
[subscription] => 0
[gold] => 147350
[date_joined] => 2011-04-26 20:02:40
[free_spin] => 0
[player_status] => 1
[scriptedSpin] => PLG
[message_flag] => N
[gold_award] => 0
Thats just 1 entry out of 300,000 or more in one text file. I need to automatically, insert the ff. into a mysql db where only the
mobile_number
name
password
gold
will be taken and inserted.
Thank you.
Regards, Mehihi
That is how the file is being formatted:
[player_id] => 70658
[mobile_number] => 09********
[name] => gorbani
[password] => ******
[verification_code] => KUTY6U
[subscription] => 0
[gold] => 147350
[date_joined] => 2011-04-26 20:02:40
[free_spin] => 0
[player_status] => 1
[scriptedSpin] => PLG
[message_flag] => N
[gold_award] => 0
[player_id] => 70659
[mobile_number] => 09********
[name] => gorbani2
[password] => ******
[verification_code] => 22222
[subscription] => 0
[gold] => 147350
[date_joined] => 2011-04-26 20:02:40
[free_spin] => 0
[player_status] => 1
[scriptedSpin] => PLG
[message_flag] => N
[gold_award] => 0
and so on..
I have tried this but no good:
$sql = array();
foreach( $myarray as $row ) {
$sql[] = '('.$row['ID'].', "'.mysql_real_escape_string($row['NAME']).'","'.$row['PRICE'].'")';}
mysql_real_query('INSERT INTO table (ID, NAME,PRICE) VALUES '.implode(',', $sql));