Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL] Błąd podczas wprowadzania danych
Rysiol
post 10.03.2008, 00:17:31
Post #1





Grupa: Zarejestrowani
Postów: 30
Pomógł: 0
Dołączył: 6.03.2008
Skąd: Babimost

Ostrzeżenie: (10%)
X----


Podczas wykonywania skryptu mającego za zadanie wprowadzanie wpisanych danych do formularza wrzucić je do bazy danych MySQL na serwerze. Po wpisaniu danych otrzymuję komunikat...

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='Robert'' at line 1

Proszę o pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Rysiol
post 10.03.2008, 00:22:32
Post #2





Grupa: Zarejestrowani
Postów: 30
Pomógł: 0
Dołączył: 6.03.2008
Skąd: Babimost

Ostrzeżenie: (10%)
X----


Skrypt chyba działa poprawnie... łączy się z bazą...

  1. <?php
  2.  include "conn.inc.php";
  3.  ?>
  4.  <html>
  5.  <head>
  6.  <title>Witaj w Stronie</title>
  7.  </head>
  8.  <body>
  9.  <?php
  10.  if (isset($_POST['submit']) && $_POST['submit'] == "Zarejestruj") {
  11.  if ($_POST['username'] !="" &&
  12. $_POST['password'] !="" &&
  13. $_POST['first_name'] !="" &&
  14. $_POST['last_name'] !="" &&
  15. $_POST['email'] !="") {
  16.  $query = "SELECT username FROM user_info".
  17.  "WHERE username='" . $_POST['username']. "';";
  18.  $result = mysql_query($query)
  19.  or die(mysql_error());
  20.  if (mysql_num_rows($result) != 0) {
  21.  ?>
  22.  <p>
  23.  <font color="#FF0000">
  24.  <b>Nazwa użytkownika <?php echo $_POST['username'];
  25.  ?> jest już używana. Wybierz inną !
  26.  </b>
  27.  </font>
  28.  <form action="register.php" method="post">
  29.  Login: <input type="text" name="username"><br>
  30.  Hasło: <input type="password" name="password"><br>
  31.  E-mail: <input type="text" name="email"
  32.  value="<?php echo $_POST['email']; ?>"><br>
  33.  Imię: <input type="text" name="first_name"
  34.  value="<?php echo $_POST['first_name']; ?>"><br>
  35.  Nazwisko: <input type="test" name="last_name"
  36.  value="<?php echo $_POST['last_name']; ?>"><br>
  37.  <input type="submit" name="submit" value="Zarejestruj"> &nbsp;
  38.  <input type="reset" value="Wyczyść">
  39.  </form>
  40.  </p>
  41.  <?php
  42.  } else {
  43.  $query = "INSERT INTO user_info (username, password, email, first_name, last_name) 
  44. VALUES ('" . $_POST['username'] . "',
  45. (PASSWORD('" . $_POST['password'] . "')),
  46. '" . $_POST['email'] . "',
  47. '" . $_POST['first_name'] . "',
  48. '" . $_POST['last_name']. "')";
  49. $result = mysql_query($query)
  50. or die(mysql_error());
  51. $_SESSION['user_logged'] = $_POST['username'];
  52. $_SESSION['user_password'] = $_POST['password'];
  53.  ?>
  54.  <p>
  55.  
  56.  Dziękujemy, <?php echo $_POST['first_name'] . " " .
  57.  $_POST['last_name']; ?>, za zarejestrowanie się!<br>;
  58.  <?php
  59.  header("Refresh: 5; URL=index.php");
  60.  echo "Zakończono proces rejestracji ! ";
  61.  die();
  62.  }
  63. } else {
  64.  ?>
  65.  <p>
  66.  <font color="#FF000"><b>Pola wymagane: Login, hasło, e-mail, Imię i Nazwisko</b></font>
  67.  <form action="register.php" method="post">
  68.  <form action="register.php" method="post">
  69.  Login:  &nbsp;<input type="text" name="username"><br>
  70.  Hasło:  &nbsp;<input type="password" name="password"><br>
  71.  E-mail: <input type="text" name="email"<br>
  72.  Imię: <input type="text" name="first_name"<br>
  73.  Nazwisko: <input type="test" name="last_name"<br>
  74.  <input type="submit" name="submit" value="Zarejestruj"> &nbsp;
  75.  <input type="reset" value="Wyczyść">
  76.  </form>
  77.  </p>
  78.  <?php
  79.  }
  80.  } else {
  81.  ?>
  82.  <p>
  83.  Witamy na stronie rejestracji!<br>
  84.  Pola wymagane: Login, hasło, e-mail, Imię i Nazwisko
  85.  <form action="register.php" method="post">
  86.  Login:  &nbsp;<input type="text" name="username"><br>
  87.  Hasło:  &nbsp;<input type="password" name="password"><br>
  88.  E-mail: <input type="text" name="email"<br>
  89.  Imię: <input type="text" name="first_name"<br>
  90.  Nazwisko: <input type="test" name="last_name"<br>
  91.  <input type="submit" name="submit" value="Zarejestruj"> &nbsp;
  92.  <input type="reset" value="Wyczyść">
  93.  </form>
  94.  </p>
  95.  <?php
  96.  }
  97.  ?>
  98.  </body>
  99.  </html>


Ten post edytował Rysiol 10.03.2008, 00:22:52
Go to the top of the page
+Quote Post

Posty w temacie


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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 21:46