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.

Was stimmt an diesem mysql_query nicht?

Empfohlene Antworten

mysql_query('INSERT INTO chat (text, benutzername) VALUES("'.$_REQUEST['text'].''.$_COOKIE['benutzername'].'")');

es kommt kein fehler, es wird aber auch nichts in die db gespeichert

so funktionierts aber:

mysql_query('INSERT INTO chat (text) VALUES("'.$_REQUEST['text'].'")');

aber dann fehlt mir ja der Benutzername :)

Tante Edith sagt:

Eventuell steht in dem Cookie nichts mehr drin, weil mein Kollege die Zeile wo das Cookie gesetzt wird, einfach gelöscht hat...

Mal abgesehen von dem fehlenden Komma!

Schreibe Werte vom User nie so in die Datenbank!!!

PHP: SQL Injection - Manual

Gruß Jaraz

Hallo :)

hab jetzt ein ganz anderes Problem...

als Resultat bekomme ich immer:

Unknown column 'Hans-Peter' in 'where clause'

$sql = 'SELECT schiffe, benutzername 
FROM spielfeld
WHERE benutzername = '.$_COOKIE['user'].'';

$result = mysql_query($sql) OR die(mysql_error());[/php]

irgendwer ne idee?! :)

edit:

Tabelle = spielfeld

Spalte = schiffe, benutzername

$_COOKIE['user'] = Der Benutzername. Der wird an einer anderen stelle auch so in die DB geschrieben

edi2:

Mal abgesehen von dem fehlenden Komma!

Schreibe Werte vom User nie so in die Datenbank!!!

PHP: SQL Injection - Manual

Gruß Jaraz

Danke für den Tipp :)

aber das ist erstmal sowieso nur ne Behelfslösung um das Cookie zu testen. Später soll da ein Java-Chat kommen...

Unknown column 'Hans-Peter' in 'where clause'

$sql = 'SELECT schiffe, benutzername FROM spielfeld WHERE benutzername = '.$_COOKIE['user'].'';

du musst natürlich schon hochkommata und doppelhochkommata für PHP und SQL getrennt verwenden und darfst sie nicht vermischen. für SQL sind üblicherweise einfache hochkommata zu verwenden, welche du aber vollständig ausgelassen und als stringterminator für PHP verwendet hast.

s'Amstel

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

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.