mysqli::$error

mysqli_error

(PHP 5, PHP 7, PHP 8)

mysqli::$error -- mysqli_errorReturns a string description of the last error

Beschreibung

Objektorientierter Stil

Prozeduraler Stil

mysqli_error(mysqli $mysql): string

Returns the last error message for the most recent MySQLi function call that can succeed or fail.

Parameter-Liste

mysql

Nur bei prozeduralem Aufruf: Ein von mysqli_connect() oder mysqli_init() zurückgegebenes mysqli-Objekt.

Rückgabewerte

A string that describes the error. An empty string if no error occurred.

Beispiele

Beispiel #1 $mysqli->error example

Objektorientierter Stil

<?php
$mysqli 
= new mysqli("localhost""my_user""my_password""world");

/* check connection */
if ($mysqli->connect_errno) {
    
printf("Connect failed: %s\n"$mysqli->connect_error);
    exit();
}

if (!
$mysqli->query("SET a=1")) {
    
printf("Error message: %s\n"$mysqli->error);
}

/* close connection */
$mysqli->close();
?>

Prozeduraler Stil

<?php
$link 
mysqli_connect("localhost""my_user""my_password""world");

/* check connection */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

if (!
mysqli_query($link"SET a=1")) {
    
printf("Error message: %s\n"mysqli_error($link));
}

/* close connection */
mysqli_close($link);
?>

Die obigen Bespiele erzeugen folgende Ausgabe:

Error message: Unknown system variable 'a'

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Grid und Pos geht nicht ...

Sie verwenden sowohl `grid-area` als auch `grid-column` für Ihre Slider-Elemente. Dies kann zu Layoutkonflikten führen, wenn die explizite Spalt ...

Geschrieben von rickluck am 29.05.2026 22:00:10
Forum: PHP Developer Forum
Komisches Problem (bei SQL-Inserts) - keine Fehlermeldung

Komisches Problem (bei SQL-Inserts) – keine Fehlermeldung is an interesting troubleshooting discussion that highlights common database and codin ...

Geschrieben von samueleasley71 am 29.05.2026 20:41:31
Forum: PHP Developer Forum
Problem with Game Script

It sounds frustrating to deal with login issues, especially when you're new to PHP/MySQL. Here are a few things you might want to check: Database ...

Geschrieben von alexandernevis am 29.05.2026 09:20:52
Forum: PHP Developer Forum
FULLLZ.ASIA ⭐️ Sells CLONED CARDS ATM verify Code ATM DUMPS

[FULLLZ.ASIA] ⭐️ Cloned Cards ATM for Sale & Shop DUMPS Pin (Track 1&2)Infofullz UK>SSN>DOB>DL Front Back Paypal Cashapp [FULLLZ.ASIA] ⭐️ ...

Geschrieben von dumpstop10 am 29.05.2026 09:08:15
Forum: User pages