Re: mysql query not working

  • From: "Niran" <public.niran@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 7 Aug 2008 11:58:46 +0530

Yes I think you are not executing the query.
Change it to:
$sql = "SELECT * FROM members WHERE email_address = '" . $_SESSION["email"] . 
"' AND pass_word = '" . $_SESSION["psswd"] . "'";
$res = mysql_query( $sql , $con);
$row = mysql_fetch_assoc($res);

Here, $con is the database connection which should be opened before calling the 
mysql_query().
And the mysql_fetch_assoc() accepts the result returned by the mysql_query() 
not the sql statement.

Visit php.net it contains the references for all the php functions. You can 
also download a chm file containing the off line version of the documentation.
HTH
Nirandas
Website: http://www.nirandas.com
  ----- Original Message ----- 
  From: BlueScale 
  To: programmingblind@xxxxxxxxxxxxx 
  Sent: Thursday, August 07, 2008 11:33 AM
  Subject: mysql query not working


  Hi,
  I keep not getting what I am expecting.  I enter data I know is in the 
database and still get an error.  Can someone tell me if there is something 
wrong with this bit of code?
  $sql = "SELECT * FROM members WHERE email_address = '" . $_SESSION["email"] . 
"' AND pass_word = '" . $_SESSION["psswd"] . "'";
  $row = mysql_fetch_assoc($sql);
  Thanks
  BlueScale 

Other related posts: