Reputation: 2230
My PHP code is:
$query="select company_name from company_names where cik=".$cik;
Which on printing gives
select company_name from company_names where cik=0001001871
I would like to get the output like
select company_name from company_names where cik='0001001871'
How do I add the single quotes in PHP?
Upvotes: 0
Views: 324
Reputation: 382696
Simply:
$query = "select company_name from company_names where cik = '$cik'";
Or:
$query = "select company_name from company_names where cik = '" . $cik . "'";
Notice that to prevent SQL Injection, see this:
More Info:
Upvotes: 4
Reputation: 742
$query="select company_name from company_names where cik='".$cik."'";
Upvotes: 0