Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db_host = '';
- $db_user = '';
- $db_pass = '';
- $db_name = '';
- $db = new mysqli($db_host, $db_user, $db_pass, $db_name);
- if($db->connect_errno) die "CONNECTION ERROR: " . $db->connect_error;
- $file = fopen("file.txt", "r");
- $file_text = fread($file, filesize("file.txt"));
- fclose($file);
- $id_reg_exp = "/data-item-id=\"(\\d+)\"/";
- $account_reg_exp = "/<td>[\\n\s]*(406048\d+)[\s]*<\/td>/";
- preg_match_all($id_reg_exp, $file_text, $ids, PREG_SET_ORDER);
- preg_match_all($account_reg_exp, $file_text, $accounts, PREG_SET_ORDER);
- if(count($ids) == count($accounts))
- {
- $db->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
- $count = count($ids);
- $sql = "UPDATE special SET id_schet = ? WHERE schet = ?";
- $stmt = $db->prepare($sql);
- if(!$stmt) die "CAN'T PREPARE STATEMENT: " . $db->error;
- $stmt->bind_param('ii', $ids[$i][1], $account[$i][1]);
- for($i = 0; $i < $count; ++$i)
- {
- $stmt->execute();
- }
- $stmt->close();
- $db->commit();
- }
- else {
- echo "count(\$ids) = " . count($ids) . "\n";
- echo "count(\$accounts) = " . count($accounts) . "\n";
- }
- $db->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement