需要帮助这个PHP代码行17

时间:2015-04-25 20:22:29

标签: php mysql pdo

已经尝试了所有我能在第17行请求我需要写(pdo)代码,因为我的注册输入不会进入数据库



Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\my php\work\register.php on line 17
//please i need the code to make it right have tried all i know

<?php
include "scripts/connection.php";
    //error_reporting(0);
	$email = $_POST['email'];
	$username = $_POST['username'];
	$password = md5($_POST['password']. "AL552KAO09");
	 $confPassword = md5($_POST['confPassword']. "AL552KAO09");
     echo"text";
  if (isset($email, $username, $password, $confPassword)){
    if (strstr($email, "@")){
    	if ($password == $confPassword){
    		$query = $dbc->prepare('SELECT * FROM users WHERE username = ? OR email = ?');
    		$query = $query->execute(array(
    			$username,
    			$email
    			));
    		$count = mysql_num_rows($query); //this is the line 17 
    		if($count == 0){
                
    			$query = $dbc->prepare('INSERT INTO users SET username= ? , email= ?, passowrd= ?');
    			$query = $query->execute(array(
    				$username,
    				$email,
    				$password
    				));
    			if($query){
    				echo "you have been registered succesfully plese click here to login";
    			}
            }else{
    		echo "user already exist with that username";
    		}
    	}else{
    		echo "password is not matching";
    	}
    }else{
    	echo "invalid email address";
    	}
    }
?>
<html>
	<head>
		<form action="" method="POST">
		<table border="0" width="500" align="center" cellpadding="5px">

    <tr> 
     <Td colspan="2" style="background:#993300;color:#FFF">
       Login
    </td>
     </tr>
   
<tr>
     <td>
       email
    </td>
     <td>
        <input type="text" name="email"/>
     </td>
    </tr>



<tr>
     <td>
      username
    </td>
     <td>
        <input type="text" name="username"/>
     </td>
    </tr>


 <tr>
	
	<tr>
     <td>
      password
    </td>
     <td>
        <input type="password" name="password"/>
     </td>
    </tr>
    <tr>
     <td>
      confirm_password
    </td>
     <td>
        <input type="password" name="confPassword"/>
     </td>
    </tr>


 <tr>


 <tr>
<td colspan="2">
  <center>
   <input type="submit" name="submit" value="Register"/>
</center>
 </td>
  </tr>

 <tr>
  <td colspan="2">
		<form>

	</head>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

你不能一起使用PDO和mysql,所以在你的例子中获取行数的尝试:

 $count = $query->rowCount();