Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problem mit INSERT

Empfohlene Antworten

Veröffentlicht

Hallo,

ich versuche gerade einen Wert aus einer Variablen in ein Feld in einer Datenbank zu schreiben.

Es handelt sich um die Variable $DB_TEST und der Wert soll in einer Datenbank in das Feld 'Name' eingetragen werden.

Die Verbindung zur Datenbank steht, ich bekomme die Werte true bei den Connections zurück.

also versuche ich es folgendermaßen:


$sql = "INSERT INTO test ('Name') VALUES ($DB_TEST)";
$result = mysql_query($sql);
if (!$result)
{
echo "Daten wurden nicht eingetragen.\r\n". mysql_error();
}
else
{
echo "Daten wurden in der Datenbank gespeichert.\r\n";
}
[/PHP]

Das Ergebnis ist, dass ich eine Fehlermeldung bekomme:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''Name') VALUES(dsa)' at line 1

Wie muss man das denn richtig formulieren?

Ich bin nach dem PHP Handbuch vorgegangen und kann den Fehler nicht finden.

Danke schonmal

Die Values muessen bei einem Textfeld ebenfalls in Anfuehrungszeichen gesetzt werden... Spaltennamen muessen nicht zwingend ;)

Also das was die Variable da ausspuckt einfach in Anfuehrungszeichen setzen...

Vielen Dank.

Funktioniert nun.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.