user1371896
user1371896

Reputation: 2230

unescaping double quotes in php

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

Answers (2)

Sarfraz
Sarfraz

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

Jebin
Jebin

Reputation: 742

$query="select company_name from company_names where cik='".$cik."'";

Upvotes: 0

Related Questions