Reputation: 73
I feel a little guilty about posting this because I posted a similar but different question before, but I couldn't figure out what the problem with this one is.
I am simply trying to run a SQL query with a PHP variable taking place of an integer value, but it doesn't seem to work; when I replace the variable with a simple number (like 1
) it actually works, so there's nothing wrong with the query itself.
When I put in the variable $email_id
at the end, it does not work.
Can anyone point out what the problem might be?
Code:
$row = Db_DbHelper::query('select subject from system_email_templates where id = '.$email_id);
Upvotes: 0
Views: 184
Reputation: 1542
Try this,
$sql = "select subject from system_email_templates where id = '".$email_id."' ";
$row = Db_DbHelper::query($sql);
Upvotes: 0
Reputation: 23948
You need to add single quotes around your PHP variable, so the updated code:
$row = Db_DbHelper::query("select subject from system_email_templates where id = '".$email_id."'");
Upvotes: 1