0

I have an sql query in my php script that has this line in it:

WHERE beerStyle = \"$styleName\" AND rating > 0

The style name that is being looked up is:

Fresh "Wet" Hop Ale

Which is being stored exactly has written above in my database. My problem is I think somehow the quotes are getting mixed up when it looks in the DB, so it thinks there are now styles with that name.

Mike
  • 6,751
  • 23
  • 75
  • 132

2 Answers2

0

Make use of mysqli_real_escape_string()

$styleName=mysqli_real_escape_string($styleName);

and your query goes like.

WHERE beerStyle = $styleName AND rating > 0
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
0

Perhaps you may try

$query = "SELECT * FROM beers WHERE beerStyle = '" .$styleName. "'";