Convert a variable to STRING in the mysql query in PHP

Asked

Viewed 778 times

0

In the query below inside my PHP the variable $line[0] is not validating as string, but if I do var_dump($line[0]); before arriving at this query, it shows that it is a string!

$result = $conn->query("SELECT player, ip from gru WHERE ip =".$line[0]);

Is there any way to convert this variable to string? I’ve tried converting before query using conventional method, but it doesn’t work!

  • Is there an error? will see the Dice nor exists.

1 answer

3

The question is confusing. However, just observing the code, it should be only the lack of delimiters:

$result = $conn->query("SELECT player, ip from gru WHERE ip = '".$line[0]."'");
  • Man, it really was JUST THAT! haha was cracking my head, I’m beginner at it! Thank you so much!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.