SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Putting a value from MySQL into a url

    ok, everything is working except the printing of the id in the url, which means my users can't verify their account.
    Basically, this is the code for the mail:
    PHP Code:
    $user_id_query "SELECT id from 3dartisan_users WHERE username=$username";
    $result mysql_db_query(jchinn$user_id_query$Link);

    if (
    $result=' '){
        print 
    "ERROR: MySQL database query failed!\n";
        print 
    mysql_error();
        print 
    "<br><br>Please report this error to <a href=\"mailto:info@3dartisan.net\">info@3dartisan.net</a>\n";
    } else {
    $verify_body ="You are receiving this email because someone, probably you, requestied membership at";
    $verify_body.="http://www.3dartisan.net\n\n";
    $verify_body.="You have 1 week to click the link below to verify your account for use.\n";
    $verify_body.="http://www.3dartisan.net/confirm.php?id=$result\n"// Here's where the id is suppose to print
    $verify_body.="After that it will be put back in the pool for others to use.\n";
    $verify_body.="Your login information is below:\n\n";
    $verify_body.="Username: $username\n";
    $verify_body.="Password: $password\n";
    $verify_body.="\n";
    $verify_body.="If you wish to edit your information, you may do so be visiting this link:\n";
    $verify_body.="http://www.3dartisan.net/edit_profile.php\n";
    $verify_body.="Thank you for using 3dartisan.net,\n";
    $verify_body.="3dartisan.net Staff\n";

    mail("$email""3dartisan Verification""$verify_body""From: $from_staff"); 
    Now, it's not printing the id at the end, which means that $result isn't getting passed the id from the query. i'm getting an error from my if to check the $results

    Any ideas on why it's not printing the id?
    Last edited by Defender1; Jul 27, 2001 at 12:16.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are two things that pop out right away:

    One is the if ($result = ' '){ needs to be if (!$result){ or if ($result == ' '){

    Second you need to actually get the id from the query you can't simply print $result that is only a reference to the query. Either use mysql_result() as I did below or mysql_fetch_array()

    PHP Code:
    $user_id_query "SELECT id from 3dartisan_users WHERE username=$username";
    $result mysql_db_query(jchinn$user_id_query$Link);

    if (!
    $result){
        print 
    "ERROR: MySQL database query failed!\n";
        print 
    mysql_error();
        print 
    "<br><br>Please report this error to <a href=\"mailto:info@3dartisan.net\">info@3dartisan.net</a>\n";
    } else {

    $id mysql_result($result00);
    $verify_body ="You are receiving this email because someone, probably you, requestied membership at";
    $verify_body.="http://www.3dartisan.net\n\n";
    $verify_body.="You have 1 week to click the link below to verify your account for use.\n";
    $verify_body.="http://www.3dartisan.net/confirm.php?id=$id\n"// Here's where the id is suppose to print
    $verify_body.="After that it will be put back in the pool for others to use.\n";
    $verify_body.="Your login information is below:\n\n";
    $verify_body.="Username: $username\n";
    $verify_body.="Password: $password\n";
    $verify_body.="\n";
    $verify_body.="If you wish to edit your information, you may do so be visiting this link:\n";
    $verify_body.="http://www.3dartisan.net/edit_profile.php\n";
    $verify_body.="Thank you for using 3dartisan.net,\n";
    $verify_body.="3dartisan.net Staff\n";

    mail("$email""3dartisan Verification""$verify_body""From: $from_staff"); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the if is still producing the error, so it's not sending the mail to verify the account.
    And when i commented out the if, it runs through the rest of the script but i get this error:
    Code:
    Warning: Supplied argument is not a valid MySQL result resource in /usr/local/plesk/apache/vhosts/3dartisan.net/httpdocs/new_user.php on line 102
    that line is this:
    PHP Code:
    $id mysql_result($result00); 
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay so its your query failing as well. I think its because of the missing quotes around $username

    change

    PHP Code:
    $user_id_query "SELECT id from 3dartisan_users WHERE username=$username"
    to

    PHP Code:
    $user_id_query "SELECT id from 3dartisan_users WHERE username='$username'"

    Anytime your variable does not contain only numbers you must put it in single quotes in your query.

    The error message you got is because the query failed.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i realized that after i had posted.
    i fixed it, and
    PHP Code:
    $id mysql_result($result00); 
    is still where it's giving the error.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, here's code as it now stands:
    PHP Code:
    $user_id_query "SELECT id from 3dartisan_users WHERE username='$username'";
    //$result = "mysql_db_query(jchinn, $user_id_query, $Link)";

    if (mysql_db_query(jchinn$user_id_query$Link)){

        
    $id mysql_result($result00);
        
    $verify_body ="You are receiving this email because someone, probably you, requestied membership at http://www.3dartisan.net\n\n";
        
    $verify_body.="You have 1 week to click the link below to verify your account for use.\n";
        
    $verify_body.="http://www.3dartisan.net/confirm.php?id=$id\n";
        
    $verify_body.="After that it will be put back in the pool for others to use.\n";
        
    $verify_body.="Your login information is below:\n\n";
        
    $verify_body.="Username: $username\n";
        
    $verify_body.="Password: $password\n";
        
    $verify_body.="\n";
        
    $verify_body.="If you wish to edit your information, you may do so be visiting this link:\n";
        
    $verify_body.="http://www.3dartisan.net/edit_profile.php\n\n";
        
    $verify_body.="Thank you for using 3dartisan.net,\n";
        
    $verify_body.="3dartisan.net Staff\n";
        
    mail("$email""3dartisan Verification""$verify_body""From: $from_staff");

    } else {
        print 
    "ERROR: MySQL database query failed!\n";
        print 
    mysql_error();
        print 
    "<br><br>Please report this error to <a href=\"mailto:info@3dartisan.net\">info@3dartisan.net</a>\n";
    }
    mysql_close ($Link);
    include (
    'join_footer.php');
    ?> 
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See now you have gotten rid of the $result identifier so mysql_result() is dying because $result does not exist.

    Here this way should most definitely work.

    PHP Code:
    <?
    $user_id_query 
    "SELECT id from 3dartisan_users WHERE username='$username'";
    $result mysql_query($user_id_query);

    if (!
    $result){
        print 
    "ERROR: MySQL database query failed!\n";
        print 
    mysql_error();
        print 
    "<br><br>Please report this error to <a href=\"mailto:info@3dartisan.net\">info@3dartisan.net</a>\n";
        } 
    else {
        if(
    mysql_num_rows($result)) { 
            
    $row mysql_fetch_array($result);
            
    $verify_body ="You are receiving this email because someone, probably you, requestied membership at";
            
    $verify_body.="http://www.3dartisan.net\n\n";
            
    $verify_body.="You have 1 week to click the link below to verify your account for use.\n";
            
    $verify_body.="http://www.3dartisan.net/confirm.php?id=".$row["id"]."\n"// Here's where the id is suppose to print
            
    $verify_body.="After that it will be put back in the pool for others to use.\n";
            
    $verify_body.="Your login information is below:\n\n";
            
    $verify_body.="Username: $username\n";
            
    $verify_body.="Password: $password\n";
            
    $verify_body.="\n";
            
    $verify_body.="If you wish to edit your information, you may do so be visiting this link:\n";
            
    $verify_body.="http://www.3dartisan.net/edit_profile.php\n";
            
    $verify_body.="Thank you for using 3dartisan.net,\n";
            
    $verify_body.="3dartisan.net Staff\n";
            
    mail("$email""3dartisan Verification""$verify_body""From: $from_staff");
            }
        else {
            print 
    "The was an error fetching the id number.";
            }
        }
    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  8. #8
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works! Thanks a lot dude!
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

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