#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    657
    Rep Power
    38

    Query not returning results


    I have a variable called $email which with grabbed via $email=$POST_email;. I know this variable has a value, because I check it before I run the query.

    My query isn't returning any results, I'm not sure why.
    Here's the
    Code:
     $query = "select * from login where
                  email ='$email'";
    	
    
        $result = mysql_query( $query );
    
        if(!$result)
        {
          echo 'Cannot run query.';
          exit;
        }
    
        $count = mysql_fetch_row($result);
    	$ticker = mysql_num_rows($result);
    
        if ( $count > 0)
        {
        for ($i=0; $i<$ticker; $i++)
        {
         $row = mysql_fetch_array($result);
         $username=$row["username"];
         echo "username=";
         echo htmlspecialchars (stripslashes($row["username"]));
         $password= $row["psswd"];
         echo "<br />password=";
         echo htmlspecialchars (stripslashes($row["psswd"]));
         $email=$row["email"];
         echo "<br />email=";
         echo htmlspecialchars (stripslashes($row["username"]));
         
         }
    The echo statements only return the strings and not the $row["variable'];

    Can anyone see what I'm doing wrong?

    thanks!
    Last edited by lelales; November 10th, 2012 at 12:19 PM. Reason: new info
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2008
    Posts
    1,927
    Rep Power
    378
    This seems to be a PHP problem but anyway, how about something like this...
    PHP Code:
    if(!$result)
        {
          echo 
    'Cannot run query.';
          exit;
        }

     while(
    $row mysql_fetch_assoc($result)){

         
    $username=$row["username"];
         echo 
    "username=";
         echo 
    htmlspecialchars (stripslashes($row["username"]));
         
    $password$row["psswd"];
         echo 
    "<br />password=";
         echo 
    htmlspecialchars (stripslashes($row["psswd"]));
         
    $email=$row["email"];
         echo 
    "<br />email=";
         echo 
    htmlspecialchars (stripslashes($row["email"]));

         } 
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    657
    Rep Power
    38

    thanks cafelatte


    It's working now!!

    thanks so much!

IMN logo majestic logo threadwatch logo seochat tools logo