Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]Mysqli problem?Składnia?, Szczerze mówiąc jestem zagubiony
nekomata
post
Post #1





Grupa: Zarejestrowani
Postów: 314
Pomógł: 44
Dołączył: 12.11.2010
Skąd: UK

Ostrzeżenie: (0%)
-----


A więc tak.. pisze skrypt rejestracji i ciągle go poprawiam, wczoraj jeszcze działal dzisiaj już nie.Dosłownie patrze na ten kod i nie wiem o co biega. Kod wygląda tak.
  1. <?php
  2. require('connect.php');
  3. include('header.php');
  4. if(isset($_POST['sm'])){
  5. $errorz = ' ';
  6. $allok = ' ';
  7. $err = 0;
  8. if(!empty($_POST['nick'])){
  9. $nick = trim($_POST['nick']);
  10. if(strlen($nick)>10){
  11. $errorz = 'Your nickname is too long(10 characters is max)<br/>';
  12. $err = 1;
  13. }
  14.  
  15. }
  16. else{
  17. $errorz = $errorz.'You forgot to fill the nickname input<br/>';
  18. $err = 1;
  19. }
  20. if(!empty($_POST['nickr'])){
  21. $nickr = trim($_POST['nickr']);
  22. }
  23. else{
  24. $errorz = $errorz.'You forgot to fill the Repeat(nickname) input<br/>';
  25. $err = 1;
  26. }
  27. if(!empty($_POST['pass'])){
  28. $pass= trim($_POST['pass']);
  29. if(strlen($pass)>20){
  30. $errorz = $errorz.'Your password is too long<br/>';
  31. $err = 1;
  32. }
  33. }
  34. else{
  35. $errorz = $errorz.'You forgot to fill the password input<br/>';
  36. $err = 1;
  37. }
  38. if(!empty($_POST['passr'])){
  39. $passr = trim($_POST['passr']);
  40. }
  41. else{
  42. $errorz = $errorz.'You forgot to fill the Repeat(password) input<br/>';
  43. $err = 1;
  44. }
  45. if($err=1){
  46. goto omfg;
  47. }
  48. if($nick!==$nickr){
  49. $errorz = $errorz.'Your nicknames doesnt match each other.<br/>';
  50. $err = 1;
  51. }
  52. if($pass!==$passr){
  53. $errorz = $errorz.'Your passwords doesnt match each other.<br/>';
  54. $err = 1;
  55. }
  56. if(!empty($_POST['ign'])){
  57. $ign = trim($_POST['ign']);
  58. if(strlen($ign)>20){
  59. $errorz = $errorz.'Your nickname is too long<br/>';
  60. $err = 1;
  61. }
  62. }
  63. else{
  64. $errorz = $errorz.'Where is your IGN?!<br/>';
  65. $err = 1;
  66. }
  67. if($err=1){
  68. goto omfg;
  69. }
  70. if($err=0){
  71. $nickname = mysqli_real_escape_string($dbc,$nick);
  72. $password = mysqli_real_escape_string($dbc,$pass);
  73. $ign = mysqli_real_escape_string($dbc,$ign);
  74. $qz = "SELECT name FROM users WHERE name='".$nickname."' LIMIT 1";
  75. $rz = mysqli_query($dbc, $qz) or die('ERROR!:'.mysql_error());
  76. $ec = mysqli_num_rows($rz);
  77. if($ec = 1){
  78. $errorz = $errorz.'Nickname already registered... you\'ve got bad luck<br/>';
  79. $err = 1;
  80. }
  81. $qn = "SELECT IGN FROM users WHERE IGN='".$ign."'";
  82. $rn = mysqli_query($dbc, $qn) or die('Error!:'.mysql_error());
  83. $en = mysqli_num_rows($rn);
  84. if($en !== 0){
  85. $errorz = $errorz.'IGN already registered... you\'ve got bad luck<br/>';
  86. $err = 1;
  87. }
  88. if($err=1){
  89. goto omfg;
  90. }
  91. $q = "INSERT INTO users (name,password,IGN,registertime)
  92. Values ('$nickname','$password','$ign',NOW() )";
  93. $r = mysqli_query($dbc, $q) or trigger_error ("Zapytanie $q\n<br/>Wywalilo blad : " .mysqli_error($dbc));
  94. $to = 'avatars/'.$nick.'.png';
  95. $from = 'avatars/default.png';
  96.  
  97. if (!copy($from, $to)) {
  98. $errorz = $errorz."Couldnt create avatar for ya... wtf?";
  99. }
  100.  
  101. if(mysqli_affected_rows($dbc) == 1 ) {
  102. $allok = '<h3>Thank you for Registering at our site!Welcome in society '.$nickname.'</h3>';
  103. }
  104. }
  105. }
  106. omfg:
  107.  
  108.  
  109. if(!isset($_POST['sm'])){
  110. echo '
  111. <form action="register.php" method="post">
  112. Nickname (up to 20 characters) : <center><input type="text" name="nick" /></center>
  113. Repeat nickname : <center><input type="text" name="nickr" /></center>
  114. Password (up to 20 characters): <center><input type="password" name="pass" /></center>
  115. Repeat password: <center><input type="password" name="passr" /></center>
  116. In game name : <center><input type="text" name="ign" /></center><br/><br/>
  117. <center>By clicking submit I promise that im not gonna trollin here.
  118. <input type="submit" name="sm" value="Submit!" /><input type="reset" value="Reset!"/></center>
  119. </form>';
  120. }
  121. else{
  122. if($allok!=' '){
  123. echo $allok;
  124. }
  125. if($errorz!==' '){
  126. echo $errorz;
  127. echo '<a href="register.php" style="text-decoration:underline">Back to registration form</a> or <a href="index.php" style="text-decoration:underline">Go to home.</a>';
  128. }
  129. print_r($_POST);
  130. }
  131.  
  132. include('footer.html');
  133. ?>

a tabela mysql wyglada tak

Cytat
`id` int(5) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL,
`IGN` varchar(20) NOT NULL DEFAULT '0',
`posts` int(7) NOT NULL DEFAULT '0',
`warns` int(7) NOT NULL,
`thanks` int(7) NOT NULL DEFAULT '0',
`level` varchar(15) NOT NULL DEFAULT 'member',
`title` varchar(25) NOT NULL,
`signature` varchar(65) DEFAULT '0',
`registertime` varchar(255) NOT NULL,
PRIMARY KEY (`id`,`name`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8


Problem tkwi w tym ze skrypt php nie wykonuje się po linii 72.. przynajmniej tak to dla mnie wygląda , jestem prawie pewien że gdzieś brakuje nawiasu albo czegoś takiego tylko nie mogę tego znaleźć.Z góry dziękuję za pomoc.
Go to the top of the page
+Quote Post
glh
post
Post #2





Grupa: Zarejestrowani
Postów: 97
Pomógł: 20
Dołączył: 18.12.2007
Skąd: Poznań

Ostrzeżenie: (0%)
-----


Tak na pierwszy rzut oka:
  1. if($err=1)

to jest zawsze prawdziwe, bo zamiast porownania masz przypisanie

chyba powinno byc
  1. if($err==1)

Warunek nizej tez ma ten blad.

Ten post edytował glh 26.12.2010, 17:17:04


--------------------
Go to the top of the page
+Quote Post
lord2105
post
Post #3





Grupa: Zarejestrowani
Postów: 380
Pomógł: 59
Dołączył: 24.04.2010
Skąd: London

Ostrzeżenie: (0%)
-----


jakies bledy tekstowe pojawiaja sie po uruchomieniu?


--------------------
40% rozwiązań znajduje się tutaj.
59,9% tutaj.

Jeśli pomogłem rozwiązać Twój problem wciśnij
Go to the top of the page
+Quote Post
nekomata
post
Post #4





Grupa: Zarejestrowani
Postów: 314
Pomógł: 44
Dołączył: 12.11.2010
Skąd: UK

Ostrzeżenie: (0%)
-----


glh.. nawet nie uwierzysz jak mi się głupio zrobiło,ale wielkie dzięki.Teraz wszystko śmiga.

Ten post edytował nekomata 26.12.2010, 17:18:03
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 20:35