This is something simple but I am having a really difficult time with it for some reason. Basically, I do a select statement to find results. I loop through that result and update the items I found in result.
This is my code:
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $stmt = $pdo->prepare("select * from licenses where email='empty' limit $quantity"); $stmt->execute(); $row = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($stmt->rowCount() > 0) { $stmt = $pdo->prepare("update licenses set email=:em, exp_date=:exp where 'id'=:id"); foreach ($row as $row) { $expires = date("Y-m-d", strtotime('+365 days')); $license = $row['license_key']; $lid = $row['id']; echo $license . '<br> ID:' . $lid; $stmt->bindValue(':em', $email1, PDO::PARAM_STR); $stmt->bindValue(':exp', $expires, PDO::PARAM_STR); $stmt->bindValue(':id', $lid, PDO::PARAM_INT); $stmt->execute(); } This code WORKS, it updates my database in a working condition. However, the website returns a 504 error and the output of license does not get displayed. Does anyone know what is wrong with this code or how can I complete the task I am aiming for?
** Edit: When I use fiddler, I get this error: [Fiddler] ReadResponse() failed: The server did not return a response for this request.
Note: Some drivers require to close cursor before executing next statement.php.net/manual/en/pdostatement.execute.php . What driver do you use?