Problem bei Datenbankanbindung

Irgendwelche Probleme mit XAMPP für Windows? Dann ist hier genau der richtige Ort um nachzufragen.

Problem bei Datenbankanbindung

Postby miezze » 31. May 2011 17:53

Hallo ihr Lieben :D
Ich mache momentan eine Umschulung zur Mediengestalterin und wir stecken gerade im Ende von PHP / Datenbanken. Ich arbeite am eigenen Laptop, wie ein weiterer aus meinem Kurs mit PHP 5.3.5, der Rest des Kurses arbeitet mit PHP 5.3.1
Nun haben wir heute eine kleine Datenbank angelegt, um die Anbindung zu lernen. Bei meinem Kollegen und mir hat das nur leider nicht so funktioniert, wie beim Rest.

Der Code für das Formular zu Dateneingabe:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<?php
echo ("<form method =\"POST\" action =\"anmelden_daten_speichern.php\">");
echo ("<h4>Anmelden - Formular zur Dateneingabe</h4>");
echo ("<table>");
echo ("<tr>");
echo ("<td><label>Benutzername </label></td>");

echo ("<td><input type =\"text\"
      name =\"benutzername\"
      value =\"".$_REQUEST['benutzername']."\"
      title =\"hier benutzername eingeben\"></td>");

echo ("</tr>");
echo ("<tr>");
echo ("<td><label> Passwort: </label></td>");
echo ("<td><input type =\"password\"
      name =\" passwort \"
      value =\"".$_REQUEST['passwort']."\"
      title =\" geben sie ihr passwort ein \"></td>");
echo ("</tr>");
echo ("<td>&nbsp;</td>");
echo ("<td><input type =\"submit\" value =\"abschicken\" /></td>");

echo ("</tr>");
echo ("</table>");
echo ("</form>");
?>
</body>
</html>


Der Code für das speichern der Daten in der Datenbank:
Code: Select all
<?php
// binde mdb2 mit ein
require_once 'MDB2.php';
//array erstellt mit verbindungsparametern
$dsn = array (
   'phptype' => 'mysql',
   'username' => 'root',
   'password' => '',
   'hostspec' => 'localhost',
   'database' => 'webshop',
);
//array zugewiesen
$options = array ();
// statische methode aufgerufen auf klasse mdb2 durch den ::
$mdb2 = MDB2::singleton($dsn, $options);
if (PEAR::isError($mdb2)){
   die($mdb2->getMessage());
}

$benutzername = $_POST['benutzername'];
$passwort = $_POST['passwort'];

// sql abfrage
$kunden_insert_sql = "insert into anmeldung ( benutzername, passwort) values ( :benutzername, :passwort)";

$sqlParameterTypes = array('text', 'text');

$statement = $mdb2->prepare($kunden_insert_sql, $sqlParameterTypes);

$sqlValues = array ('benutzername' => $benutzername, 'passwort' => $passwort);
$result = $statement->execute($sqlValues);

if(PEAR::isError($result)){
   echo ("der benutzername ist schon vorhanden!");
}
else {
   echo ("benutzername wurde angelegt!");
}

$mdb2->disconnect(); //zur sicherheit


Sobald man dann Daten in das Formular eingibt kommen folgende Fehlermeldungen:
    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 390

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 1885

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 2572

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 2595

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 2940

    Strict Standards: Declaration of MDB2_Driver_Common::raiseError() should be compatible with that of PEAR::raiseError() in C:\xampp\php\PEAR\MDB2.php on line 990

    Strict Standards: Non-static method MDB2::singleton() should not be called statically in C:\xampp\htdocs\web\09_datenbanken\anmelden_daten_speichern.php on line 15

    Strict Standards: Non-static method MDB2::parseDSN() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 484

    Strict Standards: Non-static method MDB2::factory() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 500

    Strict Standards: Non-static method MDB2::parseDSN() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 376

    Strict Standards: Non-static method MDB2::loadClass() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 385

    Strict Standards: Non-static method MDB2::classExists() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 327

    Strict Standards: Non-static method MDB2::fileExists() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 335

    Strict Standards: Non-static method MDB2::raiseError() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 340

    Strict Standards: Non-static method PEAR::raiseError() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 574

    Strict Standards: Non-static method MDB2::errorMessage() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\MDB2.php on line 972

    Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\MDB2.php on line 743

    Strict Standards: Non-static method PEAR::getStaticProperty() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\PEAR.php on line 871

    Strict Standards: Non-static method PEAR::isError() should not be called statically in C:\xampp\php\PEAR\MDB2.php on line 386

    Strict Standards: Non-static method PEAR::isError() should not be called statically in C:\xampp\htdocs\web\09_datenbanken\anmelden_daten_speichern.php on line 16
    MDB2 Error: not found

Selbst unsere Dozentin wusste auf Anhieb nicht, wie man das umgehen kann und aus Google wurden wir auch nicht schlau. Ich wär echt dankbar, wenn jemand vielleicht die Zeit und Lust hätte, sich das mal anzusehen :D
miezze
 
Posts: 2
Joined: 31. May 2011 17:26

Re: Problem bei Datenbankanbindung

Postby miezze » 31. May 2011 19:03

Schonmal vielen Dank für die Hilfe :D
Die Seite hätt ich mir wirklich selber genauer anschauen können und konnte auch die Fehler auf
    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 390

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 1885

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 2572

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 2595

    Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\php\PEAR\MDB2.php on line 2940
    MDB2 Error: not found
reduzieren.
Für diese Fehler fehlen mir allerdings ein paar Englischkenntnisse zum verstehen, was Google sagt :oops:
miezze
 
Posts: 2
Joined: 31. May 2011 17:26


Return to XAMPP für Windows

Who is online

Users browsing this forum: No registered users and 48 guests