Convert a variable to STRING in the mysql query in PHP

0

In the query below within my PHP the variable $ line [0] is not validating as a string, however if I give a 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 the query using the conventional method, but it does not work!

    
asked by anonymous 02.03.2016 / 21:03

1 answer

3

The question is confusing. However, just looking at the code should be only the missing delimiters:

$result = $conn->query("SELECT player, ip from gru WHERE ip = '".$line[0]."'");
    
02.03.2016 / 21:05