0

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in activation.php on line 11
Invalid Validation Code

what is wrong here?

<?php
session_start();
include "mysql.php";
$c;
if(!$_GET['code'] || !$_GET['act'])
{
die("Invalid Use Of System.");
} else {
$code=$_GET['code'];
$cq=mysql_query("select * from confirm where code=$code",$c);
if(mysql_num_rows($cq)== 0)
{ die("Invalid Validation Code"); }
$r=mysql_fetch_array($cq);
if($_GET['act'] == 'activate')
{
mysql_query("UPDATE users SET confirmed='1' WHERE userid={$r[user]}",$c);
mysql_query("DELETE FROM confirm WHERE code=$code",$c);
print "Account Validated!<br />
<a href='login.php'>Login</a>";
 } else if($_GET[act] == 'cancel')
{
mysql_query("DELETE FROM users WHERE userid={$r[user]}",$c);
mysql_query("DELETE FROM confirm WHERE code=$code",$c);
print "Your account has successfully been cancelled, Were sorry you had to leave.";exit;
} else {
die("Invalid Action.");
}

}
?>
2
Contributors
9
Replies
10
Views
8 Years
Discussion Span
Last Post by CFROG
0

If $code is anything other than a number put single quotes around it in the query. eg. '$code'

0

i did add ' ' but i got a new msg: Parse error: syntax error, unexpected '=' in /home/arash/public_html/activation.php on line 9

0

The single quotes need to go around '$code' within the query, not where you are defining the variables. I'm just taking a stab at what you did but line 9 should NOT look like this '$code'=$_GET['code'];

0

could u please tell me how to fix it?I tried to remove '' and add them ass u sayd...but no results...

0

If $code is a number this won't make a difference. If $code is a string your queries should look like this $cq=mysql_query("select * from confirm where code='$code' ",$c);

0

I changed those some lines to:

$code=$_GET['code'];
$cq=mysql_query("select * from confirm WHERE code='$code' ",$c); 
if(mysql_num_array($cq)== 0)

and the new error is:
Fatal error: Call to undefined function mysql_num_array() in /activation.php on line 11

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.