AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

[php] mysql query mit AND

Ein Thema von XeRo · begonnen am 2. Aug 2006 · letzter Beitrag vom 2. Aug 2006
Antwort Antwort
XeRo

Registriert seit: 23. Okt 2003
Ort: Warth
461 Beiträge
 
Delphi 7 Enterprise
 
#1

[php] mysql query mit AND

  Alt 2. Aug 2006, 15:48
Also ich würd gerne wissen ob es möglich ist einen MYSQL query wie folgt zu machen:
Code:
$result = mysql_query("SELECT * FROM $mail_table WHERE owner='in' AND WHERE to='xero' AND WHERE read=1", $mysql_ce);
Geht das, oder muss ich das irgendwie anders schreiben oder lösen?
  Mit Zitat antworten Zitat
DIET3RIX

Registriert seit: 21. Feb 2006
Ort: Bonn
78 Beiträge
 
Delphi 2007 Professional
 
#2

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 15:51
Code:
$result = mysql_query("SELECT * FROM $mail_table WHERE owner='in' AND to='xero' AND read='1', $mysql_ce);
so sollte es gehn
Dieter
  Mit Zitat antworten Zitat
XeRo

Registriert seit: 23. Okt 2003
Ort: Warth
461 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 15:58
so weit so gut. Das script sieht nurn wie folgt aus:
Code:
 $login_name = $_SESSION['game'];
 $result = mysql_query("SELECT * FROM $mail_table WHERE owner='in' AND to='$login_name' AND read=1", $mysql_ce);

 $gesamt = mysql_num_rows($result);
 echo 'Es sind '.$gesamt.' Mails

';
Und für die Zeile in der sich " $gesamt = mysql_num_rows($result);" befindet bekomme ich dann folgende Fehlermeldung:
Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/export/www/vhosts/funnetwork/hosting/agfan/game/game4/index.php on line 79
oran kann das liegen
  Mit Zitat antworten Zitat
DIET3RIX

Registriert seit: 21. Feb 2006
Ort: Bonn
78 Beiträge
 
Delphi 2007 Professional
 
#4

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 16:00
Code:
AND read=1",
siehst du den fehler evtl. selbst
Dieter
  Mit Zitat antworten Zitat
XeRo

Registriert seit: 23. Okt 2003
Ort: Warth
461 Beiträge
 
Delphi 7 Enterprise
 
#5

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 16:08
Es ändert sich auch nichts daran wenn ich
Code:
(...) read='1'", (...)
schreib.
  Mit Zitat antworten Zitat
Benutzerbild von alcaeus
alcaeus

Registriert seit: 11. Aug 2003
Ort: München
6.537 Beiträge
 
#6

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 16:15
Hol dir evtl. mal mit mysql_error den letzten Fehler. Wenn das Query False zurueckgibt, hats naemlich gekracht.

Greetz
alcaeus
Andreas B.
Die Mutter der Dummen ist immer schwanger.
Ein Portal für Informatik-Studenten: www.infler.de
  Mit Zitat antworten Zitat
noch_ein_hannes

Registriert seit: 18. Sep 2003
130 Beiträge
 
#7

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 16:18
Wenn Du mal wissen willst was da wirklich an mySQL gesendet wird, dann schreib mal folgendes:
Delphi-Quellcode:
$strSQL = "SELECT * FROM $mail_table WHERE owner='inAND to='$login_nameAND read=1";
$result = mysql_query($strSQL, $mysql_ce);
if(!empty(mysql_error())) echo $strSQL;
es kann ja durchaus sein, dass Deine Variablen nicht ganz "sauber" sind ...
- everything is possible -
  Mit Zitat antworten Zitat
XeRo

Registriert seit: 23. Okt 2003
Ort: Warth
461 Beiträge
 
Delphi 7 Enterprise
 
#8

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 16:19
aja.
Was sagt mir
Code:
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 'read='1'' at line 1
genau?
Was passt an dem read nicht?

[edit]
@noch_ein_hannes: Wenn ich das so mache dann bekomm ich:
Code:
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' in /usr/export/www/vhosts/funnetwork/hosting/agfan/game/game4/index.php on line 80
[/edit]
  Mit Zitat antworten Zitat
noch_ein_hannes

Registriert seit: 18. Sep 2003
130 Beiträge
 
#9

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 16:50
dann schau Dir mal die Zeile 80 an:
Entweder fehlt da einer Variable das $
oder in Zeile 79 das abschliessende ;
oder die Anführungsstriche sind nicht korrekt gesetzt ...
- everything is possible -
  Mit Zitat antworten Zitat
XeRo

Registriert seit: 23. Okt 2003
Ort: Warth
461 Beiträge
 
Delphi 7 Enterprise
 
#10

Re: [php] mysql query mit AND

  Alt 2. Aug 2006, 16:58
In Zeile 80 Steht:

Code:
if(!empty(mysql_error()))echo $strSQL;
[edit]
Kanns sein, dass read irgendwie besetzt ist und daher immer der fehler entsteht?
[/edit]
[edit#2]
Anscheinend. Denn jetzt wo ich das read in readed umgenannt habe und "if(!empty(mysql_error()))echo $strSQL;" weglasse funktioniert es. Aber nur wenn ich Z.80 also "if(!empty(mysql_error()))echo $strSQL;" weglasse. Hat das irgendeinen fehler im code?
[/edit#2]
[edit#3]
Vielleicht hätte es auch geklappt wenn ich read so geschrieben hätte:
Code:
(...) AND `read` = '1'";
Aber das versuche ich jetzt nicht mehr. Jetzt funktionierts mit readed auch bestens
[/edit#3]
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:21 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