TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   mysql_num_rows(): supplied argument is not a valid MySQL result resource (http://www.talkphp.com/absolute-beginners/6315-mysql_num_rows-supplied-argument-not-valid-mysql-result-resource.html)

rios2 06-12-2012 09:42 PM

mysql_num_rows(): supplied argument is not a valid MySQL result resource
 
Hey guys,
I was working through the tutorial on creating registration page. On Activation PHP went through the coding error:
Mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/68/9152261/html/activation.php on line 16.

Tried different variation nothing works... so frustrated. I thought professional opinion would help to find a problem. Please help!!! Here is the code:

<?php
if($_GET['id']!=""){
include_once "connect_to_mysql.php";

$id = $_GET['id'];
$hashpass = $_GET['sequence'];

$id = mysql_real_escape_string($id);
$id = eregi_replace("`", "", $id);

$hashpass = mysql_real_escape_string($hashpass);
$hashpass = eregi_replace("`", "",$hashpass);

$sql = mysql_query("UPDATE members SET email_activated='1' WHERE id='$id' AND password='$hashpass'");
$sql_doublecheck = mysql_query("SELECT * FROM members WHERE id='$id' AND password='$hashpass' AND email_activated='1'");
$doublecheck = mysql_num_rows($sql_doublecheck);

if($doublecheck == 0){
$msgToNewMember = "</br></br><h3><strong><font color=red>Your account could not be activated</font></strong></h3><br/>
Please contact us regarding your activation via email";
include 'msgToNewMember.php';
exit();
} else if($doublecheck>0) {
$msgToNewMember = "<br/><br/><strong><font color=\"#0066CC\">You successfully activated your account!<br/>
Now you can login to your account.</font></strong><h3>";
include 'msgToNewMember.php';
exit();
}
}

print "Essential part from activation link is missing! Please copy full activation link that was supplied in our email to you and paste it in a new browser address bar. Thank you!
</br>
";

?>

Thank you very much!

maeltar 06-13-2012 03:45 AM

You need to be handling errors to get to the bottom of your problem...

PHP Code:

$sql mysql_query("UPDATE members SET email_activated='1' WHERE id='$id' AND password='$hashpass'");
$sql_doublecheck mysql_query("SELECT * FROM members WHERE id='$id' AND password='$hashpass' AND email_activated='1'");
$doublecheck mysql_num_rows($sql_doublecheck); 


PHP Code:

$sql mysql_query("UPDATE members SET email_activated='1' WHERE id='$id' AND password='$hashpass'");

if (!
$sql){
echo 
"Error with update query : " mysql_error();
}

$sql_doublecheck mysql_query("SELECT * FROM members WHERE id='$id' AND password='$hashpass' AND email_activated='1'");

if (!
$sql_doublecheck){
echo 
"Error in double check : " mysql_error();
}else{
$doublecheck mysql_num_rows($sql_doublecheck);



rios2 06-13-2012 06:12 AM

Seems like main problem is solved. Although "Your account could not be activated" message poping up. I guess I need to get through it all over again. Thank you Simon very much!


All times are GMT. The time now is 08:42 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0