已經嘗試了所有我能在第17行請我需要爲它寫(PDO)的代碼,因爲我的註冊輸入未進入數據庫需要幫助這個PHP代碼行17
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);
\t $email = $_POST['email'];
\t $username = $_POST['username'];
\t $password = md5($_POST['password']. "AL552KAO09");
\t $confPassword = md5($_POST['confPassword']. "AL552KAO09");
echo"text";
if (isset($email, $username, $password, $confPassword)){
if (strstr($email, "@")){
\t if ($password == $confPassword){
\t \t $query = $dbc->prepare('SELECT * FROM users WHERE username = ? OR email = ?');
\t \t $query = $query->execute(array(
\t \t \t $username,
\t \t \t $email
\t \t \t));
\t \t $count = mysql_num_rows($query); //this is the line 17
\t \t if($count == 0){
\t \t \t $query = $dbc->prepare('INSERT INTO users SET username= ? , email= ?, passowrd= ?');
\t \t \t $query = $query->execute(array(
\t \t \t \t $username,
\t \t \t \t $email,
\t \t \t \t $password
\t \t \t \t));
\t \t \t if($query){
\t \t \t \t echo "you have been registered succesfully plese click here to login";
\t \t \t }
}else{
\t \t echo "user already exist with that username";
\t \t }
\t }else{
\t \t echo "password is not matching";
\t }
}else{
\t echo "invalid email address";
\t }
}
?>
<html>
\t <head>
\t \t <form action="" method="POST">
\t \t <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>
\t
\t <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">
\t \t <form>
\t </head>
</html>
不能混合MYSQL API的! – Rizier123
'passowrd'也可能是一個錯字錯誤。 – halfer
此外,密碼應該散列比MD5更強的東西。你的醃製比沒有加鹽要好一點,但不如每用戶鹽好。如果您使用'hash_password',它會爲您解決這兩個問題。 – halfer