Skip to content

Instantly share code, notes, and snippets.

@sam452
Last active August 29, 2015 14:20
Show Gist options
  • Save sam452/8c0c9ecd4a2ec1db2557 to your computer and use it in GitHub Desktop.
Save sam452/8c0c9ecd4a2ec1db2557 to your computer and use it in GitHub Desktop.
simple php migration fail
<?php
function convert($string) {
return strtotime($string);
}
$mysqli = mysqli_connect("osx", 'my_user', 'my+p1', 'my_host');
$res = mysqli_query($mysqli, "SELECT donationId, donationDate, donationTime from GeneralDonations where donationTime IS NULL");
// while ($row = mysqli_fetch_assoc($res)) {
// $row['donationTime'] = strtotime($row['donationDate']);
while ($row = mysqli_fetch_assoc($res)) {
printf('%sswft (%s)\n', $row[‘donationId’], $row[‘donationTime’]);
$sql = "UPDATE GeneralDonations SET donationTime=" . strtotime($row['donationDate']) . "WHERE donationId =" . $row['donationId']);
echo $sql;
if (mysqli_query($mysqli, $sql)) {
echo "Record updated successfully";
} else {
echo "Error: " . mysqli_error($mysqli);
}
mysqli_close($mysqli);
}
?>

php -a 5 (1429237428) 6 (1429237651) 7 (1429285394) 8 (1429286366) 9 (1429304741) 10 (1429304887)

php -f migrate.php Parse error: syntax error, unexpected '%', expecting ')' in /home/habitatnashville/habitatnashville.org/me1.php on line 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment