Here is my code.
$rs = $db->query('UPDATE shorturl SET originalUrl = :originalUrl, status = :status, expiryDate=null, shortUrlFolder=:shortUrlFolder WHERE id = :id', array('originalUrl' => $original_url, 'status' => $status, 'shortUrlFolder' => $shortUrlFolder, 'id' => $urlId));
If i change "status = :status" to "status = active" or "status = 'active'" I get a 500 error from my page when i run it, why is this am i getting the string wrong ? if i change back to "status = :status" it all works.
Two things.
1) string constants in SQL need to be surrounded by single-quote characters. So use status='active'
rather than status=active
.
2) 500 errors often result from error returns from database statements, possibly due to incorrectly formed queries. You should check for errors ... something like this:
$rs = $db->query('...
if (!$rs) {
die "query failed: " . $db->error;
}
It's good practice always to check for these errors.