Greetings all. I'll admit I'm far more comfortable with asp/sql than php. I know exactly how to acheive the result I'm looking for there.
Anyhow I'm getting a "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /blabla/update_user.php on line 54" error.
I've used a very simular peice of code to loop through results before, but on this one I have to find a particular record based on on field. the main difference is the where statement containing OR.
Here is the code:
$query = "SELECT active,email,username FROM users WHERE (email ='$email' OR username='user_name')";
connectDB();
$r=mysql_query($query);
$num_results=mysql_num_rows($r);
if($num_results > 1){ /*more than one record based on the query, loop for the record with matching username. */
for ($i=0; $i<$num_results;$i++) {
$row = mysql_fetch_array($r);
if($user_name==$row["username"]){
$uname=($row["username"]);
$mail=($row["email"]);
$active=$r=($row["active"]);
}
}
}else{
$uname=$r[username];
$mail=$r;
$active=$r[active];
}
Anyhow I'm getting a "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /blabla/update_user.php on line 54" error.
I've used a very simular peice of code to loop through results before, but on this one I have to find a particular record based on on field. the main difference is the where statement containing OR.
Here is the code:
$query = "SELECT active,email,username FROM users WHERE (email ='$email' OR username='user_name')";
connectDB();
$r=mysql_query($query);
$num_results=mysql_num_rows($r);
if($num_results > 1){ /*more than one record based on the query, loop for the record with matching username. */
for ($i=0; $i<$num_results;$i++) {
$row = mysql_fetch_array($r);
if($user_name==$row["username"]){
$uname=($row["username"]);
$mail=($row["email"]);
$active=$r=($row["active"]);
}
}
}else{
$uname=$r[username];
$mail=$r;
$active=$r[active];
}