dsd30433 2017-08-15 00:21
浏览 80
已采纳

在sql语句中包含变量的正确方法是什么[重复]

This question already has an answer here:

I want to include a variable in my sql statement but it's not outputting any data. How do I include a variable correctly?

$vStyles = $wpdb->get_results( 'SELECT slug from vf_venuestyles WHERE vid = "$vid"');

</div>
  • 写回答

3条回答 默认 最新

  • dongzaobei0942 2017-08-15 00:24
    关注

    Change the quote marks around: $vStyles = $wpdb->get_results("SELECT slug from vf_venuestyles WHERE vid = '$vid'");

    But, unless that function / class already does something magic about that, you should look into using something with proper prepared statements.

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

报告相同问题?