Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][SQL][PHP]Zmienna w formularzu php, tworzenie tabeli
Nidan23
post
Post #1





Grupa: Zarejestrowani
Postów: 101
Pomógł: 2
Dołączył: 26.04.2019

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


Witam, zapewne kolejny śmieciowy post, jednak mam problem, ponieważ, pracuję nad podstawowym panelem do zarządzania witryną i natrafiłem na problem z tworzeniem tabeli poprzez formularz na stronie, dostaję error:

Error creating table: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''kurde_mac_znowu_nie_dziala' LIKE klan' at line 1

  1. if (isset($_POST['send']))
  2. {
  3. $tabela = $_POST['send2'];
  4.  
  5. // Create connection
  6. $conn = new mysqli($servername, $username, $password, $dbname);
  7. // Check connection
  8. if ($conn->connect_error) {
  9. die("Connection failed: " . $conn->connect_error);
  10. }
  11.  
  12. // sql to create table
  13. $sql = "CREATE TABLE '$tabela' LIKE klan";
  14.  
  15. if ($conn->query($sql) === TRUE) {
  16. echo "Table ".$tabela." created successfully";
  17. } else {
  18. echo "Error creating table: " . $conn->error;
  19. }
  20. }
  21. $conn->close();
  22. ?>


A formularz ma się tak:

  1. <form method="POST" action="stabela.php">
  2. <textarea class="rej" name="send2" maxlength="255">Nazwa Tabeli</textarea>
  3. <br>
  4. <br>
  5. <input class="pz" type="submit" value="Prześlij" name="send">
  6. </form>


Gdy zamiast textarea używam input, także nie działa, z tym samym błędem.

Zauważyliście jakieś błędy? Jakieś pomysły?
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 24.08.2025 - 13:29