www.webdeveloper.com
Results 1 to 11 of 11

Thread: [RESOLVED] Calling an email [NOT RESLOVED]

  1. #1
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    157

    resolved [RESOLVED] Calling an email [NOT RESLOVED]

    Sorry for the double post, but I didnt let me undo the resloved. Anyways I have this:

    PHP Code:
    $dbquery "SELECT email FROM `users` WHERE Random_key='" $confirmid "'";
    $result2 mysql_query($dbquery);
    echo 
    "mysql_result($result2,4)"
    with this error:
    mysql_result(Resource id #4,4)

    Once again sorry for the double post.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,636
    No quotes:
    PHP Code:
    echo mysql_result($result24); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    157
    when I do no quotes I get this:

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 4 in /home2/*****/public_html/confirm.php on line 28

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,636
    If you want the first row from the result, row numbering starts at 0 (as does column numbering):
    PHP Code:
    echo mysql_result($result20); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    157
    I want the 5th one, because that is where the e-mail address is located

    i.e., ID, Fullname, gid, uname, email, birth, pass, Random_key, Active
    That is the 5th one from the left is email 4th if you don't count ID.

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,636
    No, you want the 1st (and only) row returned by the query, don't you? (This is totally distinct from how and where that row is stored in the DB table.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    157
    well if you mean row by horizontal, then yes. I want the first one to be returned with the value of the email address.

  8. #8
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,636
    No, what I mean is that your query is going to return one result row with one field (column). In other words it will match on one row in the specified table where the value for column `Random_key` matches the supplied search value. If you ran the query from the MySQL command line, the output would be something like:
    Code:
    mysql> SELECT email FROM `users` WHERE Random_key='gobbledygook'
    
    email
    ==================
    joe@example.com
    
    (1 row returned)
    mysql> _
    So the query result would be one row with one column. Therefore the email address you are looking for would be in query result row 0 (the only row) and column 0 (the only column).

    For another query, you might request multiple columns and match on several or all rows in the database. It would return something like:
    Code:
    mysql> SELECT name, email FROM `users` ORDER BY email ASC
    
    name      email
    ========= ==================
    Joe Blow  joe@example.com
    John Doe  john@example.net
    
    (2 rows returned)
    mysql> _
    In such a case you'd probably end up using mysql_fetch_assoc() in a while() loop in order to retrieve and process each result row in sequence.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  9. #9
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    157
    Yes, that explains what you mean by the rows. In that case I only want that one row, so how come when I put in a 0 it gives me an error?

  10. #10
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,636
    What error do you get?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  11. #11
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    157
    I figured it out, once you said the whole row thing, I started tweaking it. I will show you what I changed because that will explain better than I will

    This is what I had:
    PHP Code:
    <?php
    //opens a connection to the MYSQUL 
    require ("dbconnect.php");
      
    $confirmId mysql_real_escape_string($_GET['c']); 
      
      
    $errorMessage "";
      
    $validCount 0;
      
      
    $query "SELECT Active FROM `users` WHERE Random_key='$confirmId'";
      
    $result mysql_query($query);
      
    $validCount mysql_num_rows($result);
      
      if(
    $result['Active'] == 1$errorMessage .= "You have already confirmed this account.<br/>";
      if(
    $validCount == 0$errorMessage .= "You are trying to confirm an invalid account.<br/>";
      
      if(empty(
    $errorMessage))
      {    
        
    $query "UPDATE `users` SET Active = 1 WHERE Random_key='$confirmId'"
        
    mysql_query($query) OR die(mysql_error()); 
        echo 
    'Your account has been confirmed! <br/>';
      }
      else
      {
        echo 
    $errorMessage;
      }
    //fetch and show their e-mail address from mysql
    echo mysql_result($result,0); 
    ?>
    In this line:
    PHP Code:
    $query "SELECT Active FROM `users` WHERE Random_key='$confirmId'"
    I changed from SELECT Active to SELECT email and now it selects their e-mail and still confirms their account when they press the link. Once again thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles