SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Jul 27, 2001, 12:11 #1
- 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");
Any ideas on why it's not printing the id?Last edited by Defender1; Jul 27, 2001 at 12:16.
-
Jul 27, 2001, 12:23 #2
- 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($result, 0, 0);
$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.
-
Jul 27, 2001, 12:36 #3
- 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
PHP Code:$id = mysql_result($result, 0, 0);
-
Jul 27, 2001, 12:58 #4
- 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";
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.
-
Jul 27, 2001, 13:01 #5
- 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, andPHP Code:$id = mysql_result($result, 0, 0);
-
Jul 27, 2001, 13:03 #6
- 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($result, 0, 0);
$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');
?>
-
Jul 27, 2001, 13:07 #7
- 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.
-
Jul 27, 2001, 13:14 #8
- Join Date
- Apr 2001
- Location
- My Computer
- Posts
- 2,808
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It works! Thanks a lot dude!
Bookmarks