为什么我得到错误:查询是空的


Why am I getting Error: Query was empty?

我正在创建一个登录部分到我的网页。当一个新人注册他们的详细信息时,按下注册按钮将转到register_ok部分,如下所示:

case 'register_ok':

if (!$_POST['client_username'] || !$_POST['client_password'] ||
     !$_POST['client_email']) {
    die('You did not fill in a required field.');
}
// check if username exists in database.
if (!get_magic_quotes_gpc()) {
    $_POST['client_username'] = addslashes($_POST['client_username']);
}
$qry = "SELECT client_username FROM client WHERE client_username = '".$_POST['client_username']."'";
$result = mysql_query($qry);
    if($result) {
        if(mysql_num_rows($result) > 0) {
    die('Sorry, the username: <strong>'.$_POST['client_username'].'</strong>'
      . ' is already taken, please pick another one.');
    }
}

// check e-mail format
if (!preg_match("/.*@.*..*/", $_POST['client_email']) ||
     preg_match("/(<|>)/", $_POST['client_email'])) {
    die('Invalid e-mail address.');
}
// no HTML tags in username, website, location, password
$_POST['client_username'] = strip_tags($_POST['client_username']);
$_POST['client_password'] = strip_tags($_POST['client_password']);

// now we can add them to the database.
// encrypt password
$_POST['client_password'] = md5($_POST['client_password']);
if (!get_magic_quotes_gpc()) {
    $_POST['client_password'] = addslashes($_POST['client_password']);
    $_POST['client_email'] = addslashes($_POST['client_email']);
}

$insert = "INSERT INTO client (
        client_username, 
        client_password, 
        client_name, 
        client_email, 
        client_last_access)
        VALUES (
        '".$_POST['client_username']."', 
        '".$_POST['client_password']."',  
        '".$_POST['client_name']."', 
        '".$_POST['client_email']."',
        'now()'
        )";
        if(!mysql_query($sql,$con)) {
            die('Error: ' . mysql_error());
        }
        else{
$id= mysql_insert_id();
session_start();

            echo '<script>alert("You May Now Login");</script>';
            echo '<meta http-equiv="Refresh" content="0;URL=pv.php">';
        }

break;
}

当我注册一个新的人时,我得到以下错误:

Error: Query was empty

为什么会这样?

if(!mysql_query($sql,$con)) {这行中,您是指$insert而不是$sql吗?

Do:

if(!mysql_query($sql,$con)) { 

if(!mysql_query($insert,$con)) {

变量名不正确