php/mySQL error: mysql_num_rows(): supplied argument is not a valid MySQL result

Posted by Michael Robinson on Stack Overflow See other posts from Stack Overflow or by Michael Robinson
Published on 2010-06-09T17:16:41Z Indexed on 2010/06/09 17:22 UTC
Read the original article Hit count: 131

Filed under:
|

I'm trying to INSERT INTO a mySQL database and I'm getting this error on:

if (mysql_num_rows($login) == 1){

Here is the php, The php does add the user to the database. I can't figure it out.

<?
session_start();
require("config.php");

$u = $_GET['username'];
$pw = $_GET['password'];
$pwh = $_GET['passwordhint'];
$em = $_GET['email'];
$zc = $_GET['zipcode'];


$check = "INSERT INTO family (loginName, email, password, passwordhint, location) VALUES ('$u', '$pw', '$pwh', '$em', '$zc')";


$login = mysql_query($check, $link) or die(mysql_error());


if (mysql_num_rows($login) == 1) {
$row = mysql_fetch_assoc($login);
echo 'Yes';exit;


} else {
echo 'No';exit;
}

mysql_close($link);
?>

Thanks,

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql