0

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?

APC
  • 141,155
  • 19
  • 165
  • 275
user1371896
  • 2,014
  • 7
  • 23
  • 32

2 Answers2

5

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:

Community
  • 1
  • 1
Sarfraz
  • 367,681
  • 72
  • 526
  • 573
0
$query="select company_name from company_names where cik='".$cik."'";
Jebin
  • 692
  • 11
  • 29