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.");
}

}
?>

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

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

Is this line 9? $code=$_GET['code'];

yes

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'];

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

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);

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

Try this instead if(mysql_num_rows($cq)== 0)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.