0

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

?

1
  • oh, thanks chris85, next time i'll use that :) Commented Jun 8, 2016 at 16:34

3 Answers 3

2

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']}'";
Sign up to request clarification or add additional context in comments.

1 Comment

Great! Both working. Thanks mate. I'll add your answer as solution in some minutes.
2

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...

Comments

0

Try this

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

1 Comment

Why should the OP "try this"? A good answer will always have an explanation of what was done and why it was done that way, not only for the OP but for future visitors to SO that may find this question and be reading your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.