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
Login geht nicht mehr Php/Sql?

Hallo,

ich hatte bereits mit Xampp eine login und register seite gemacht welche auch super funktionert hat. Jetzt ist sie online aber es klappt nicht mehr.

Registrier Code:

  <?php

  if(isset($_POST["submit"])){

   require("mysql.php");

   $stmt = $mysql->prepare("SELECT * FROM accounts WHERE USERNAME = :user"); //Username überprüfen

   $stmt->bindParam(":user", $_POST["username"]);

   $stmt->execute();

   $count = $stmt->rowCount();

   if($count == 0){

    //Username ist frei

    if($_POST["pw"] == $_POST["pw2"]){

     //User anlegen

     $stmt = $mysql->prepare("INSERT INTO accounts (USERNAME, PASSWORD) VALUES (:user, :pw)");

     $stmt->bindParam(":user", $_POST["username"]);

     $hash = password_hash($_POST["pw"], PASSWORD_BCRYPT);

     $stmt->bindParam(":pw", $hash);

     $stmt->execute();

     echo '<span style="color:green;text-align:center;">Account got succesfully created !</span>';

    } else {

     echo "Password dont matches";

    }

   } else {

    echo '<span style="color:red;text-align:center;">This Username is already taken....</span>';

   }

  }

   ?>

Anmelde Code:

  <?php

  if(isset($_POST["submit"])){

   require("mysql.php");

   $stmt = $mysql->prepare("SELECT * FROM accounts WHERE USERNAME = :user"); //Username überprüfen

   $stmt->bindParam(":user", $_POST["username"]);

   $stmt->execute();

   $count = $stmt->rowCount();

   if($count == 1){

    //Username ist frei

    $row = $stmt->fetch();

    if(password_verify($_POST["pw"], $row["PASSWORD"])){

     session_start();

     $_SESSION["username"] = $row["USERNAME"];

     header("Location: geheim.php");

    } else {

     echo '<span style="color:red;text-align:center;">Failed to login!</span>';

    }

   } else {

    echo '<span style="color:red;text-align:center;">Failed to login!</span>';

   }

  }

   ?>

SQL, Webseite, Datenbank, MySQL, PHP, 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
Fehlermeldung bei Phpmyadmin?

hallo ich habe ihr bei phphmyadmin diese fehler meldung und jetzt kein ich keine rechte mehr änder .

kann mir jeman helfen?

Warning in .\libraries\classes\Dbal\DbiMysqli.php#209

mysqli::query(): (HY000/1034): Fehlerhafte Index-Datei für Tabelle 'db'; versuche zu reparieren

Backtrace

DbiMysqli.php#209: mysqli->query(

string 'SELECT * FROM `mysql`.`db` WHERE `User` = \'shop\' AND `Host` = \'%\' ORDER BY `Db` ASC',

integer 0,

)

DatabaseInterface.php#219: PhpMyAdmin\Dbal\DbiMysqli->realQuery(

string 'SELECT * FROM `mysql`.`db` WHERE `User` = \'shop\' AND `Host` = \'%\' ORDER BY `Db` ASC',

,

integer 0,

)

DatabaseInterface.php#177: PhpMyAdmin\DatabaseInterface->tryQuery(

string 'SELECT * FROM `mysql`.`db` WHERE `User` = \'shop\' AND `Host` = \'%\' ORDER BY `Db` ASC',

integer 256,

integer 0,

boolean true,

)

Privileges.php#1747: PhpMyAdmin\DatabaseInterface->query(string 'SELECT * FROM `mysql`.`db` WHERE `User` = \'shop\' AND `Host` = \'%\' ORDER BY `Db` ASC')

Privileges.php#1834: PhpMyAdmin\Server\Privileges->getUserSpecificRights(

string 'shop',

string '%',

string 'database',

string '',

)

Privileges.php#3125: PhpMyAdmin\Server\Privileges->getHtmlForAllTableSpecificRights(

string 'shop',

string '%',

string 'database',

)

PrivilegesController.php#460: PhpMyAdmin\Server\Privileges->getHtmlForUserProperties(

boolean false,

string '',

string 'shop',

string '%',

string '',

string '',

)

Routing.php#192: PhpMyAdmin\Controllers\Server\PrivilegesController->__invoke(

,

array,

)

index.php#43: PhpMyAdmin\Routing::callControllerForRoute(

,

string '/server/privileges',

,

,

)

Computer, MySQL, PHP, phpMyAdmin
PHP MySql Login / Passwort überprüfung?

Kann mir da jemand sagen wo der Fehler liegt ? Ich bin da am verzweifeln.

Login, Registrierung, Fehlermeldung, SQL Struktur habe ich alles in die Frage gepackt damit ihr einen besseren überblick habt.

login.php:

<?php
   $server = 'localhost';
   $user = 'root';
   $psw = null;
   $dbName = 'TestApp';
try {
   $conn = new PDO('mysql:host='.$server.';dbname='.$dbName.';charset=utf8', $user, $psw);
   $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
   $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

    $username = htmlspecialchars(stripslashes(trim($_POST['username'])));
    $password = htmlspecialchars(stripslashes(trim($_POST['password'])));

    $statement = $pdo->prepare("SELECT * FROM user WHERE username = :username");
    $result = $statement->execute(array('username' => $username
                                    ));
    $user = $statement->fetch();
    //Überprüfung des Passworts
    if ($user !== false && password_verify($username, $password['passwort'])) {
        $_SESSION['userid'] = $user['id'];
        die('Login erfolgreich. Weiter zu <a href="geheim.php">internen Bereich</a>');
    } else {
        $errorMessage = "Nutzername oder Passwort war ungültig<br>";
    }

}catch (PDOException $e) {
    print "Error!: " . $e->getMessage() ;
    exit;
  }

Konsole :

<br />
<b>Warning</b>: Undefined variable $pdo in <b>C:\xampp\htdocs\Test\assets\php\login.php</b> on line <b>14</b><br />
<br />
<b>Fatal error</b>: Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\Test\assets\php\login.php:14
Stack trace:
#0 {main}
 thrown in <b>C:\xampp\htdocs\Test\assets\php\login.php</b> on line <b>14</b><br />

register.php

<?php
   $server = 'localhost';
   $user = 'root';
   $psw = null;
   $dbName = 'TestApp';
try {
   $conn = new PDO('mysql:host='.$server.';dbname='.$dbName.';charset=utf8', $user, $psw);
   $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
   $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

// POST wird mit AJAX gesendet
   $username = htmlspecialchars(stripslashes((trim($_POST["username"])))) ;
   $password =  password_hash(htmlspecialchars(stripslashes((trim($_POST["password"])))) ,PASSWORD_DEFAULT) ;
   $cash =     100;

// Schreibt in die Datenbank

   $sql = "INSERT INTO user (username,password,cash) VALUES (:username,:password,:cash) ";
   $sqlvars = array("username"  => $username,
   "password" => $password,
   "cash" => $cash);
   $Abfrage = $conn->prepare($sql);
   $Abfrage->execute($sqlvars);


}catch (PDOException $e) {
  print "Error!: " . $e->getMessage() . "<br/>";
  exit;
}

SQL STRUKTUR :

Datenbankname : Test

Tabelle : user , 5 Spalten/Rows

  • id | int , (auto increment)
  • username | varchar , (unique)
  • password | varchar, (gehasht mit salt sha512)
  • cash | varchar
  • time | datetime, (mit current time stamp)

und ich mache alles mit AJAX.

-PDO statt mysqli

Computer, Webseite, Programmierer, programmieren, JavaScript, Datenbank, Informatik, MySQL, PHP, Webentwicklung, Backend, phpMyAdmin, PDO

Meistgelesene Fragen zum Thema PhpMyAdmin