Hello, it is strange if I make a withdrawal with restriction on id then output, but for some reason with no email. Here is the code:

$gig = 'sadas@mail.ru'; $history = mysql_query("SELECT * FROM orders WHERE email = ".$gig); $userH=mysql_fetch_array($history); echo $userH['name']; echo $gig; 
  • 2
    because email='sadas@mail.ru' should be, in apostrophes - vp_arth
  • @vp_arth and if I need to take sadas@mail.ru with a variable? - Merlin

2 answers 2

Lines in queries must be in apostrophes.

 $gig = 'sadas@mail.ru'; $gig = mysql_real_escape_string($gig); $history = mysql_query("SELECT * FROM orders WHERE email = '$gig'"); $userH=mysql_fetch_array($history); echo $userH['name']; echo $gig; 

mysql_

Warning: This extension is deprecated since PHP 5.5.0 and removed in PHP 7.0.0. Use MySQLi or PDO_MySQL instead . See also the MySQL instruction : API selection and the corresponding FAQ for more details.

    Because lines should be framed with apostrophes:

     $history = mysql_query("SELECT * FROM orders WHERE email = '". $gig ."'");