php - Fail With Registation Please fill in all fields -


this error have fill in fields , still pops , warning looks warning: mysql_fetch_assoc() expects parameter 1 resource, string given in c:\xampp\htdocs\site\index.php on line 35 please fill in fields

code:

<?php include ("inc/incfiles/header.inc.php");  ?> <?php $reg = @$_post['reg'];  //decalring variables prevent errors  $fn = $ln = $un = $em = $em2 = $pswd = $pswd2 = $d = $u_check = "";  /**   * alla dessa variablar nedan bör kunna bytas ut mot det ovan för att göra det lite enklare.   * */  /*$fn = ""; //first name  $ln = ""; //last name  $un = ""; //username  $em = ""; //email  $em2 = ""; //email2  $pswd = ""; //password  $pswd2 = ""; // password2  $d = ""; // sign date  $u_check = ""; // check if username exists */  //registration form  $fn = mysql_real_escape_string(@$_post['fname']);  $ln = mysql_real_escape_string(@$_post['lname']);  $un = mysql_real_escape_string(@$_post['username']);  $em = mysql_real_escape_string(@$_post['email']);  $em2 = mysql_real_escape_string(@$_post['email2']);  $pswd = mysql_real_escape_string(@$_post['password']);  $pswd2 = mysql_real_escape_string(@$_post['password2']);  $d = date("y-m-d"); //year - month - day   if ($reg)  {      if ($em == $em2)      {          //check if user alredy exists          $un_check = mysql_query("select count(*) count users username='$un'");           $data=mysql_fetch_assoc("$un_check");          if($data['count'] > 0){              // username alredy in use             }             else{                 // username free             }         {              //check of fields have been filed in              if ($fn && $ln && $un && $em && $em2 && $pswd && $pswd2)              {                  // check passwords match                  if ($pswd == $pswd2)                  {                      // cheack maximum lenght of of username/first name/last name not exceed 25 characters                      if (strlen($un) > 25 || strlen($fn) > 25 || strlen($ln) > 25)                      {                          echo "the maximum limit username/first name/last name 25 characters!";                      } else                      {                          // check maximum lenght of password deoes not exceed 25 characters , not less 5                          if (strlen($pswd) > 30 || strlen($pswd) < 5)                          {                              echo "your password must between 5 , 30 characters long!";                          } else                          {                              //encrypt password , password 2 using md5 berfore sending database                              $pswd = md5($pswd);                              $pswd2 = md5($pswd2);                              $query = mysql_query("insert users values ('','$un','$fn','$ln','$em','$pswd','$d','0')");                              die("<h2>welcome mysite</h2>login account started ...");                          }                      }                  } else                  {                      echo "your passwords don't match!";                  }              } else              {                  echo "please fill in fields";              }          }      }  }  ?> <? //login script if (isset($_post["user_login"]) && isset($_post["password_login"])) {     $user_login = preg_replace('#[^a-za-z0-9]#i', '', $_post["user_login"]); // filter numbers , letters     $password_login = preg_replace('#[^a-za-z0-9]#i', '', $_post["password_login"]); //filter numbers , letters     $sql = mysql_query ("select id users username='$user_login' , password='$password_login' limit 1"); // query person     //cheack existance     $usercount = mysql_num_rows($sql); //count number of rows returned     if ($usercount == 1) }         while($row = mysql_fetch_array($sql)){             $id = $row["id"];     }          $_session["id"] = $id;          $_session["user_login"] = $user_login;          $_session["password_login"] = $password_login;          header("location: index.php");          exit();         } else {         echo 'that information incorrect try again';         exit();     } } ?> <? //login script if (isset($_post["user_login"]) && isset($_post["password_login"])) {     $user_login = preg_replace('#[^a-za-z0-9]#i', '', $_post["user_login"]); // filter numbers , letters     $password_login = preg_replace('#[^a-za-z0-9]#i', '', $_post["password_login"]); //filter numbers , letters     $sql = mysql_query ("select id users username='$user_login' , password='$password_login' limit 1"); // query person     //cheack existance     $usercount = mysql_num_rows($sql); //count number of rows returned     if ($usercount == 1) }         while($row = mysql_fetch_array($sql)){             $id = $row["id"];     }          $_session["id"] = $id;          $_session["user_login"] = $user_login;          $_session["password_login"] = $password_login;          header("location: index.php");          exit();         } else {         echo 'that information incorrect try again';         exit();     } } ?>  <table class="homepagetable">       <tr>          <td width="60%" valign="top">           <h2>already member loign below!</h2></br>           <form action="index.php" method="post" name="form1" id="form1">              <input type="text" size="25" name="user_login" id="user_login" placeholder="username" />              <input type="password" size="25" name="user_password" id="user_password" placeholder="password" /><br />              <input type="submit" name="button" id="button" value="login!">           <form>          </td>          <td width="40%" valign="top">            <h2>sign below</h2>           <form action="#" method="post">           <input type="text" size="25" name="firstname" placeholder="first name" value="<?php echo $fn; ?>">           <input type="text" size="25" name="lastname" placeholder="last name" value="<?php echo $ln; ?>">           <input type="text" size="25" name="username" placeholder="username" value="<?php echo $un; ?>">           <input type="text" size="25" name="email" placeholder="email" value="<?php echo $em; ?>">           <input type="text" size="25" name="email2" placeholder="repeat email" value="<?php echo $em2; ?>">           <input type="password" size="32" name="password" placeholder="password">           <input type="password" size="32" name="password2" placeholder="repeat password"><br />           <input type="submit" name="reg" value="sign up!">           </form>          </td>      </tr> <table> </body> </html> 

you've put in variable string, change

$data=mysql_fetch_assoc("$un_check");  

to

$data=mysql_fetch_assoc($un_check);  

and work ;)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -