0

I have a dictionary page. when I search something the link showing as index.php?word=(search word here) but when I add ' mark to this link like index.php?word=**name'**

then showing this error Warning:

mysql_fetch_array(): supplied argument is not a valid MySQL result resource in...  

how to stop this. and bypass ' mark

J.K.A.
  • 7,272
  • 25
  • 94
  • 163
user1939816
  • 45
  • 1
  • 1
  • 5

2 Answers2

3

In your case, you would want to use mysql_real_escape_string($_GET['name']).

http://php.net/manual/en/function.mysql-real-escape-string.php

However, I wouldn't recommend using mysql_* functions. I would use prepared statements with PDO or mysqli. You can find more info here (PDO) or here (mysqli).

Supericy
  • 5,866
  • 1
  • 21
  • 25
0

quick fix would be to use mysql_real_escape_string against your query.

However, since mysql_* is deprecated, your best bet for future proof would be to use PDO or mysqli_*

ariefbayu
  • 21,849
  • 12
  • 71
  • 92