如何在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'];

?

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']}'";

Try this

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

You really want to use prepared statements and mysqi_* PHP Manual

//assume you have $conn made and working
if ($stmt = mysqli_prepare($conn, "SELECT `lastUpdate` FROM `summoner` WHERE `name`=?"){
    mysqli_stmt_bind_param($stmt, "s", $summoner['name']);
    $stmt->execute();
    $result = $stmt->get_result();
}

//use $result to loop or whatever...