Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape quotes in a MYSQL query?

Tags:

html

php

mysql

Example: The follwing query give me Quotes error in the field -> GET['email']

    mysql_query(" select * from user_info where user_mail = '$_GET['email']' ")
like image 394
Webroots Avatar asked Dec 13 '25 00:12

Webroots


1 Answers

You might want to escape the string first:

$_GET['email'] = mysql_real_escape_string($_GET['email']);

And then:

mysql_query(" select * from user_info where user_mail = '" . $_GET['email'] . "' ");

The dots put the strings together.

like image 195
MFTSBU Avatar answered Dec 14 '25 14:12

MFTSBU



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!