提供的在mysql结果寄存器中无效

时间:2016-02-28 12:00:34

标签: php html mysql css

错误:

  

警告:mysql_num_rows():提供的参数不是第12行的C:\ AppServ \ www \ Weboo \ WeboHub \ app \ join \ u_register.php中的有效MySQL结果资源

     

警告:mysql_num_rows():提供的参数不是有效的MySQL   结果资源   第15行的C:\ AppServ \ www \ Weboo \ WeboHub \ app \ join \ u_register.php

的config.php

<?php
$db_conx = new mysqli("localhost", "root", "root", "hub");
// Evaluate the connection
?>

u_register.php:

<?php

// Check Register Code

if (isset($_POST['zr'])) { 
$user = strip_tags(addslashes($_POST['user'])); 
$pass = md5(strip_tags($_POST['pass'])); 
$email = strip_tags(addslashes($_POST['mail'])); 
if(isset($user) && isset($pass)){ 
if (strlen($_POST['user']) > 3) { 
$qu = mysql_query("select * from users where name = '".$user."'"); 
$num = mysql_num_rows($qu); 
if($num != 1){ 
$qu = mysql_query("select * from users where email = '".$email."'"); 
$num = mysql_num_rows($qu); 
if($num != 1){ 
$insert = mysql_query("INSERT INTO `users` (user,pass,emaill) VALUES ('".$user."','".$pass."','".$email.'"'); 
if($insert){

    echo true;

}
 }
  }
   }
    }
     }


?>

register.php

<?
include('reigster_css.php');

?>

<script type="text/javascript">
// Credits to Mohammad Shehbaaz for the design
// https://dribbble.com/shots/1819287-Register-Form?list=shots&sort=popular&timeframe=now&offset=387

$('input').bind('focus', function() {
  $(this).parent('.field').css({ 'background-color' : '#f5f8f9'});
});
$('input').bind('blur', function() {
  $(this).parent('.field').css({ 'background-color' : 'none'});
});
</script>
<div class='container'>
  <header>
    <h2>Sign up, it’s free</h2>
    <p>It is a long established fact that a reader will be distracted</p>
  </header>
  <!-- / START Form -->
  <div class='form'>
    <form action="u_register.php" method="post">
      <div class='field'>
        <label for='username'>Username</label>
        <input id='username' name='user' type='text' value='Andy Tran'>
      </div>
      <div class='field'>
        <label for='email'>Email Address</label>
        <input id='email' name='mail' type='email' value='hello@andytran.me'>
      </div>
      <div class='field'>
        <label for='password'>Password</label>
        <input id='password' name='pass' type='password' value='password'>
      </div>

         <div class='field'>
        <label for='password'>Age</label>
        <input id='password' name='age' placeholder="Age" type='text'>
      </div>

      <div class='checkbox'>
        <input id='checkbox' name='checkbox' type='checkbox'>
        <label for='checkbox'>
          I am respectful

        </label>
      </div>
      <button name="zr">Sign Up</button>
    </form>
  </div>
  <!-- / END Form -->
  <footer>
   CopyRight
    <i class='fa fa-heart animated infinite pulse'></i>
    by
    <a href='http://andytran.me'>WebooHub</a>
  </footer>
</div>

数据库:

SET SQL_MODE =“NO_AUTO_VALUE_ON_ZERO”;

-

- 数据库:hub

-

- 表users

CREATE TABLE users(   id int(11)NOT NULL auto_increment,   user varchar(255)NOT NULL,   pass varchar(255)NOT NULL,   email varchar(255)NOT NULL,   主要关键(id) )ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1;

-

- إرجاعأوإستيرادبياناتالجدولusers

1 个答案:

答案 0 :(得分:1)

您可以使用mysqli_ functions:

$num = mysqli_num_rows($qu);