wieso PHP Parse error: syntax error, unexpected token ";" in /home/emmanuel/Downloads/hp.php on line 11?
<link rel="stylesheet" href="style.css">
<?php
$db = unserialize(file_get_contents('data.php'));
if($db == false){
        $db = array();
}
if($_POST['mail'] == ''){
        if($_POST['name'] == ''){
                if($_POST['pass'] == ''){a
                        if(!array_key_exists($_POST['mail'], $db){
                                $db[$_POST['mail']] = [$_POST['name'], []];
                                file_put_contents('data.php', serialize($db));
                        } 
                }
        }
}
?>
<form action="" method="post">
    <center>
        <label for="firma_name" >name:</label><br>
        <input type="text" class="input" name="name" autocomplete="off"><br>
        <label for="produkte">email:</label><br>
        <input type="text"  class="input" name="mail" autocomplete="off"><br>
        <label for="adresse">pass:</label><br>
        <input type="text"  class="input" name="pass" autocomplete="off"><br>
        <input type="submit" class="anmelde_button" value="anmelden">
    </center>
</form>

wieso PHP Parse error: syntax error, unexpected token ";" in /home/emmanuel/Downloads/hp.php on line 11?

HTML, Webseite, CSS, JavaScript, HTML5, Datenbank, JQuery, MySQL, PHP, Programmiersprache, Webdesign, Webentwicklung, phpMyAdmin
Zahl mit Arduino an MySQL Datenbank senden?

Moin,

Vielleicht kann mir jemand helfen. Ich will, dass mein Arduino den Wert einer stinknormalen Variable an eine MySQL-Datenbank schickt. Ich bin mehr oder weniger am Verzweifeln, weil mir niemand helfen kann... Es kann doch nicht so schwer sein, ne blöde Zahl irgendwie in Form einer Variable an die Datenbank zu senden...

Ich benutze einen normales Arduino Uno, und ein W5100 ethernet shield

Mein bisheriger Ansatz war so: (Logindaten der Datenbank entfernt)

#include <Ethernet.h>

#include <MySQL_Connection.h>

#include <MySQL_Cursor.h>

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server_addr('localhost'); 

char user[] = "root";       

char password[] = "secret";    

// Sample query

char INSERT_SQL[] = "INSERT INTO Test (Sensor) VALUES ('3')";

EthernetClient client;

MySQL_Connection conn((Client *)&client);

void setup() {

 Serial.begin(115200);

 while (!Serial);

 Ethernet.begin(mac_addr);

 Serial.println("Connecting...");

 if (conn.connect(server_addr, 3306, user, password)) {

  delay(1000);

 }

 else

  Serial.println("Connection failed.");

}

void loop() {

 delay(2000);

 Serial.println("Recording data.");

 

 MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);

 cur_mem->execute(INSERT_SQL);

 delete cur_mem;

}

SQL, HTML, Webseite, programmieren, Java, Cplusplus, Arduino, Datenbank, MySQL, PHP, Programmiersprache, Python, Softwareentwicklung, Webentwicklung, phpMyAdmin, Raspberry Pi
Warum kann dieser php code keine Verbindung zur Datenbank herstellen?

Ich sitze hier und verzweifle förmlich daran, warum sich die eingegebenen Daten aus:

<!DOCTYPE html>
<html>
  <head>
    <h1>Der Weg ins Paradies</h1>
    <link rel="stylesheet" href="GL.css">
  </head>
    <p>Die Welt dadraußen ist trist, doch <br> sein kein Schaf, sei ein Wolf</p>
    <form method="post" action="Registrierungsseite.php">
      <p><label>Name:<br><input type="text" name="Name"></label></p>
      <p><label>E-Mail:<br><input type="text" name="Mail"></label></p>
      <p><label>Passwort:<br><input type="password" name="Passwort"></label></p>
      <p><label>IBAN:<br><input type="text" name="IBAN"></label></p>
      <p><input type="submit" value="Registrieren"></p>
    </form>
  </body>
</html>

nicht in der MySQL-Datenbank wiederfinden.

Meine PHP-Datei ist diese hier:

<?php
  // Get the form data
  $name = $_POST['name'];
  $email = $_POST['email'];
  $password = $_POST['password'];
  $iban = $_POST['iban'];

  // Connect to the MySQL database
  $db = mysqli_connect("localhost", "root", "", "paradies");

  // Check if the connection was successful
  if (mysqli_connect_errno()) {
    // If the connection failed, display an error message and exit
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    exit;
  }

  // Insert the form data into the MySQL database
  $query = "INSERT INTO paradies (name, email, password,iban) VALUES ('$name', '$email', '$password', '$iban')";

  if (mysqli_query($db, $query)) {
    // If the insert was successful, redirect the user to the login page
    header("Location: GL.php");
    exit;
  }
  else {
    // If the insert failed, display an error message
    echo "Error: " . $query . "<br>" . mysqli_error($db);
  }

  // Close the MySQL connection
  mysqli_close($db);
?>

Ich sehe den Fehler einfach nicht, da sobald man die Daten absendet, es zwar zur PHP-Datei weitergeleitet wird, dann jedoch lediglich der Code zu sehen ist. Die Datenbank hat dann natürlich auch keinen Eintrag.

Danke im Voraus.

HTML, Datenbank, MySQL, PHP, phpMyAdmin

Meistgelesene Beiträge zum Thema PhpMyAdmin