Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   SQL Update in PHP was stimmt nicht am Befehl? (https://www.delphipraxis.net/41335-sql-update-php-stimmt-nicht-am-befehl.html)

Plague 1. Mär 2005 22:01


SQL Update in PHP was stimmt nicht am Befehl?
 
Hallo,

ich verstehe nicht, warum dieser Code nicht funktioniert...
Kann mir jemand helfen?
SQL-Code:
UPDATE `InfoBox` SET `Prioritaet` = '0' WHERE `ID` = `$_SESSION['UID']`
Gruß
Thomas

kiar 1. Mär 2005 22:13

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
hallo thomas,

bist du sicher, das prioritaet vom typ ein varchar ist?

raik

Plague 1. Mär 2005 22:15

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
Priorität ist ein Varchar, aber die Session ist ein Integer!
Vielleicht liegt da das Problem...
Wie kann ich die Session umwandeln?

Gruß
Thomas

kiar 1. Mär 2005 22:17

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
leider habe ich von php keine ahnung,

sorry

Plague 1. Mär 2005 22:33

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
Schade, vielleicht kann mir ja jemand anderes helfen ;)

Marcel Gascoyne 1. Mär 2005 22:36

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
Zitat:

Zitat von Plague
SQL-Code:
UPDATE `InfoBox` SET `Prioritaet` = '0' WHERE `ID` = `$_SESSION['UID']`

Ich weiss leider nicht wie Du das in Deinem PHP Skript stehen hast, ich denke aber in etwa so:

Code:
mysql_query('UPDATE `InfoBox` SET `Prioritaet` = '0' WHERE `ID` = `$_SESSION['UID']`');
Das wird aber so nicht funktionieren mit Deinen Quote-Strings. PHP-Variablen werden grundsätzlich nur in Double-Quotes aufgelöst. So sollte es funktionieren:

Code:
mysql_query("UPDATE \"InfoBox\" SET \"Prioritaet\" = \"0\" WHERE ID = $_SESSION['UID']");
Gruß,
Marcel

Plague 1. Mär 2005 22:43

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
Danke erstmal!

Aber eine kleine Korrektur war bei deiner Idee noch notwenig ohne, dass es Fehler gibt:
Code:
$sql= ("UPDATE \"InfoBox\" SET \"Prioritaet\" = \"0\" WHERE ID = ".$_SESSION['UID']);
Jetzt kommt zwar kein Fehler, aber es kommt nicht zu einem UPDATE.

Gruß
Thomas

MarcusB 1. Mär 2005 23:55

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
Probier doch mal:

SQL-Code:
$sql = "UPDATE InfoBox SET Prioritaet = '0' WHERE ID = '".$_SESSION['UID']."'";

alcaeus 2. Mär 2005 04:50

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
Hallo Marcus,

nachdem Session ein Integer ist, kannst du die einzelnen Hochkommas getrost weglassen. Die anderen, schraegen Hochkommas macht eigentlich nur phpMyAdmin rein, ich selbst hab sie noch nie gebraucht, und bei mir funktioniert alles wunderbar ;)

Greetz
alcaeus

sECuRE 2. Mär 2005 06:53

Re: SQL Update in PHP was stimmt nicht am Befehl?
 
Hi,

probier mal folgendes:
Code:
$query = "UPDATE `InfoBox` SET `Prioritaet` = '0' WHERE `ID` = '".$_SESSION['UID']."'";
if (!mysql_query($query)) {
  Die("Fehler: ".mysql_error());
} else {
  echo "Query erfolgreich ausgeführt (".$query.")";
}
cu


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:11 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz