dongmiao4733 2016-06-08 15:24
浏览 51
已采纳

如何在MySQL中包含PHP数组变量

I am trying the following:

mysql_query("SELECT `lastUpdate` FROM `summoner` WHERE `name` = '$summoner['name']';");

But it doesn't work. I think its because of the ' in $summoner['name'].

Any way to workaround without:

$summonerName = $summoner['name'];

?

  • 写回答

3条回答 默认 最新

  • duan0708676887 2016-06-08 15:27
    关注

    You can use (no single quotes on the occurance)

    "SELECT `lastUpdate` FROM `summoner` WHERE `name` = '$summoner[name]'";
    

    Or wrap the Whole array with quotes in curly brackets

    "SELECT `lastUpdate` FROM `summoner` WHERE `name` = '{$summoner['name']}'";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?