0

I have a problem with retrieving my data back from msql database when I passed my where condition value by javascript to a php side code. here is my code:

$sql="SELECT ItemPrice FROM wp_my_Items WHERE ItemName = '".$q."'";

if ($result=mysqli_query($con,$sql))
{
    while ($row=mysqli_fetch_row($result))
    {
      echo $row[0];
    }
    mysqli_free_result($result);
}
else
     echo "not found";
Jeff
  • 6,895
  • 1
  • 15
  • 33
  • _"I have a problem"_ - can you please specify _what_ your problem exactly is? – Jeff Sep 22 '18 at 07:36
  • also note, that your query is vulnerable to SQL-Injection. Switch to [prepared statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)! – Jeff Sep 22 '18 at 07:37
  • Possible duplicate of [MySQL + PHP: How to handle Umlauts in Stored Procedure Params?](https://stackoverflow.com/questions/52144770/mysql-php-how-to-handle-umlauts-in-stored-procedure-params) – Guy Louzon Sep 22 '18 at 08:36
  • ItemName is an string in Persian format and I got it by $_GET from another form. The result that the query give to me is nothing but it is not. – ehsan amiri Sep 22 '18 at 09:00
  • I added this code and is solved. mysqli_set_charset($con,"utf8"); – ehsan amiri Sep 22 '18 at 09:06

0 Answers0