-2

have tried all i could on line 17 please i need the write (pdo) code for it because my signup input is not going into the database

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>
silva-web
  • 1
  • 3
  • You can't mix MYSQL API's! – Rizier123 Apr 25 '15 at 20:23
  • `passowrd` is probably a typo error, too. – halfer Apr 25 '15 at 21:31
  • Also, passwords should be hashed with something stronger than MD5. Your salting is a bit better than not having a salt at all, but not as good as a per-user salt. If you use `hash_password` it fixes both of these problems for you. – halfer Apr 25 '15 at 21:32

1 Answers1

1

You can't use PDO and mysql together, so in your example to get row count's try this:

 $count = $query->rowCount();
mcklayin
  • 1,260
  • 10
  • 16
  • 2
    I think an explanation for OP and future SO visitors would be helpful! – Rizier123 Apr 25 '15 at 20:35
  • i tried adding the $count = $query->rowCount(); but am geting this error Fatal error: Call to a member function rowCount() on a non-object in C:\wamp\www\my php\work\register.php on line 17 – silva-web Apr 25 '15 at 21:19
  • update your question with new changes. – mcklayin Apr 25 '15 at 21:23
  • $count = $query->rowCount(); //this is line 17 if($count == 0){ //i get Fatal error: Call to a member function rowCount() on a non-object in C:\wamp\www\my php\work\register.php on line 17 – silva-web Apr 25 '15 at 21:55
  • @silva-web `$qt = $query->execute(array( $username, $email )); $count = $qt->rowCount(); //this is the line 17 ` – mcklayin Apr 25 '15 at 22:16
  • @mcklayin am still geting thesame error message i dont know what to do(.'.) – silva-web Apr 25 '15 at 22:47
  • i dont know what to do again am geting tired of using pdo because the errors are complex to rectify – silva-web Apr 26 '15 at 13:03