realjumper Posted May 7, 2008 Share Posted May 7, 2008 So you're saying that... echo "$num"; ....returnd 0? Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 7, 2008 Author Share Posted May 7, 2008 /\ correct... i added echo $email; and it returns nothing... i also erased all entries in the db just to make sure that it should work...i have a feeling that there is a problem with the formatting of the email. i am very unsure as to how that is to be done...is the email portion posted above formatted correctly? Quote Link to comment Share on other sites More sharing options...
realjumper Posted May 7, 2008 Share Posted May 7, 2008 As far as I'm aware, if the field you are querying num_rows of has data (of any kind, irrespective of formatting), num_rows will return something. So, either there is nothing in the filed you are quering, or the query is wrong. Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 7, 2008 Author Share Posted May 7, 2008 but the query is going to be "SELECT * FROM ForumUsers WHERE email=" because email echoes nothing. so, since there are no entries where email is nothing, the script is technically working right...my main question is why is $email not getting filled by the emailed link? i think that if that were to work, then everything would fall into place. Quote Link to comment Share on other sites More sharing options...
realjumper Posted May 7, 2008 Share Posted May 7, 2008 One thing at a time......lets get this num_rows issue sorted first, then tackle the email format. Insert something...anything, into 'email' and run this query $sql="SELECT * FROM ForumUsers WHERE email !=''"; $result=mysql_query($sql) or die ("Error in query" . mysql_error());// this will throw an error if there is one in the sql $num = mysql_num_rows($result); if ($num != 0) { echo '$num rows found'; } else { echo 'no rows'; } Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 7, 2008 Author Share Posted May 7, 2008 with that code, i get the output: $num rows found. i had the script echo $num before the if statement and it showed 1. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 Dude, put it in double quotes and tell us the output...*grumble* if ($num != 0) { echo "$num rows found"; } Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 7, 2008 Author Share Posted May 7, 2008 sorry...didnt realize that single quotes and double quotes made a diff...just copied and pasted the code supplied. sorry. also, it shows 1 row. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 Okay, so now your query is correct and it's getting the rows. Now try an email and tell us what happens. Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 7, 2008 Author Share Posted May 7, 2008 this is the query: SELECT * FROM ForumUsers WHERE email !='' all that it is looking for is anything that has an email that is not blank... edit--- sorry...me stoopid...just realized what you meant... still finds one row...my email Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 13, 2008 Author Share Posted May 13, 2008 bump... Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 13, 2008 Share Posted May 13, 2008 SELECT * FROM ForumUsers WHERE email!=NULL Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 16, 2008 Author Share Posted May 16, 2008 comes up "no rows" Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 16, 2008 Author Share Posted May 16, 2008 ok...bit the bullet and am not md5ing the random number in the email. works...sort of. here is my code: (located here:http://www.everkleen.biz/testforum/forum/verify.php <?php include ('includes/dbconnect.php'); $email=(stripslashes(htmlentities(mysql_real_escape_string($_GET['email'])))); $rand=(stripslashes(htmlentities(mysql_real_escape_string($_GET['key'])))); $sql="SELECT random FROM ForumUsers WHERE email='$email' AND random='$rand'"; $result=mysql_query($sql) or die ("Error in query" . mysql_error());// this will throw an error if there is one in the sql $num = mysql_num_rows($result); echo "$email<br>$rand<br>$num"; if ($num != 0) { $finresult=(mysql_result($result)); echo "$finresult"; if ($key == $finresult) { $query ="UPDATE ForumUsers SET valid='1' WHERE email='$email'"; $result = mysql_query($query) or die(mysql_error()); echo "Thank you for validating your email, have a nice day!"; } else { echo "Something went horribly, horribly wrong. Please <a href='mailto:admin@example.com'>CLICK HERE</a> to email the administrator."; } } else { echo "Something went horribly, horribly wrong. Please <a href='mailto:admin@example.com'>CLICK HERE</a> to email the administrator."; } ?> now, when i click on the link in the email it returns: <<<myemail>>> 9218158<-just an echo that shows the $rand in the email. 1<-the number of rows returned from the mysql query Warning: Wrong parameter count for mysql_result() in /home/.../validate.php on line 19 Thank you for validating your email, have a nice day! in the db it comes up validated...wondering if it is ok to just shut off error reporting on the page and not worry about it. tried changing mysql_result($result) to mysql_result($result, 0) but it gets this error message: <<<my email again>>> 9218158<-again the echo $rand 1 <-again number of rows 9218158<-this is the Something went horribly, horribly wrong. Please CLICK HERE to email the administrator. it doesn't change the validity... also tried to have mysql_result($result, 1). throws this: <<<email>>> 9218158 1 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 3 in /home/.../validate.php on line 19 Thank you for validating your email, have a nice day! but still validates the address...kinda confused. Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 17, 2008 Author Share Posted May 17, 2008 bump Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 17, 2008 Share Posted May 17, 2008 wondering if it is ok to just shut off error reporting on the page and not worry about it. no. it's not working properly, so turning off error reporting will leave you with a script that isn't working properly AND isn't displaying any errors. this means just what it says, and that means mysq_result() is failing and not doing anything: Warning: Wrong parameter count for mysql_result() in /home/.../validate.php on line 19 Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 17, 2008 Author Share Posted May 17, 2008 ok, but why does it mark the valid field as 1? i assumed that it wasn't doing what it was supposed to, but in doing so it was doing what it was supposed to, which is validate the email... also, if mysql_result is not doing anything, then why do i have $finresult (the mysql_result() portion of the code) echo the correct number when i have mysql_result($result, 0), but it doesn't mark the email as valid? what am i doing wrong in my code here to have it not work? Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 17, 2008 Author Share Posted May 17, 2008 changed a few things and now it works...by the way, im an idiot...had $key instead of $rand and that was throwing the error...also am using msql_fetch_array now...seems to work very well and, ummm, i dunno, just tried using it and it worked (even though i had fixed the prob with the $key and whatnot. i was using it when i fixed the prob, so i am not gonna change it now.) also, added a piece of code to the login section that checks to make sure that a user has validated his/her email. Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted May 17, 2008 Author Share Posted May 17, 2008 more changes: 1. usrsignup.php now checks for duplicate email addresses, usernames 2. added a 2nd box to make sure passwords match if anyone wants to try it out, go ahead. any ideas/critiques are accepted, just remember: this is a work in progress. after the login page is nothing... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.