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
  • 144,005
  • 19
  • 170
  • 281
user1371896
  • 2,192
  • 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
  • 377,238
  • 77
  • 533
  • 578
0
$query="select company_name from company_names where cik='".$cik."'";
Jebin
  • 702
  • 13
  • 33