dongpo8250 2012-06-18 06:49
浏览 40
已采纳

在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?

  • 写回答

2条回答 默认 最新

  • duanqu9292 2012-06-18 06:50
    关注

    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:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?