This question already has an answer here:
I have a problem with my code. It works fine when i use id for example 1000000 but when i use id 1000000_1 it returns me error not when i m trying to insert it into mysql but when i call it to edit the record. id_fakelos=5979&CD_CAND=2015020010_1&kod_prok=2834
The error is "Fatal error: Call to a member function fetch_assoc() on a non-object in" and my code to call it is
$query = "SELECT * FROM fakelos WHERE CD_CAND = {$CD_CAND} LIMIT 1";
$result = $mysqli->query($query);
$row = $result->fetch_assoc();
extract($row);
The code works perfectly when i m not using underscores
</div>
The error occurs because 1000000_1
is not a valid literal outside quotes in MySql.
Putting quotes around it would fix the immediate issue, but there is a much bigger problem with your code: you are not using prepared statements with bound parameters.
Changing the code to use prepared statements will make it robust in the face of SQL injection attacks and will fix your problem "for free".