Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL]Problem z zapytaniem.
Salur
post
Post #1





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 28.12.2014

Ostrzeżenie: (20%)
X----


Witam, mam problem z zapytaniem.

Oto błąd: 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 'AND item.window='EQUIPMENT' AND item.vnum=item_proto.vnum' at line 1
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /var/www/panel/pages/show_eq.php on line 33.

KOD:
  1. $show = false;
  2. mysql_select_db("player");
  3. $eq = mysql_query("SELECT item.*, item_proto.locale_name FROM item, item_proto WHERE item.owner_id=".$a['id']." AND item.window='EQUIPMENT' AND item.vnum=item_proto.vnum");
  4. echo '<h2>Przedmioty założone:</h2>';
  5. $ilist = Array();
  6. while($q = mysql_fetch_array($eq)) {
  7. echo $q['locale_name'].'<br>';
  8. }
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 7)
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


na 99% to:
  1. ".$a['id']."

jest puste lub nie jest liczbą

poza tym można zapisać jako {$a['id']}

Ten post edytował Pyton_000 23.06.2015, 12:53:52
Go to the top of the page
+Quote Post
Turson
post
Post #3





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Zademonstruję ci magiczny sposób sprawdzenia co jest nie tak z zapytaniem.

1) Robisz sobie tak
  1. $query = "SELECT item.*, item_proto.locale_name FROM item, item_proto WHERE item.owner_id=".$a['id']." AND item.window='EQUIPMENT' AND item.vnum=item_proto.vnum";


2) Wyświetlasz zapytanie
  1. echo $query;


3) Patrzysz na nie i szukasz błędu.
4) Nie możesz znaleźć? Wklej do phpMyAdmin i sprawdź
5) Dalej nie wiesz? Idź na forum

Zacznij od kroku 1.
Go to the top of the page
+Quote Post
patwoj98
post
Post #4





Grupa: Zarejestrowani
Postów: 218
Pomógł: 16
Dołączył: 6.06.2014
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


A to nie jest tak, że trzeba dać apostrofy? tongue.gif

  1. item.owner_id='".$a['id']."'
questionmark.gif
Go to the top of the page
+Quote Post
Turson
post
Post #5





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Jeżeli to liczba, to nie trzeba. Dla bezpieczeństwa lepiej na wszelki wypadek rzutować na np. int
Go to the top of the page
+Quote Post
com
post
Post #6





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


Turson sugerowałbym var_dump, print_r

Dla bezpieczeństwa to bym zainteresował się bindowaniem unikniesz takich bzdurnych problemów smile.gif
Go to the top of the page
+Quote Post
Turson
post
Post #7





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


Bałem się zaproponować var_dump bo jeszcze kolega by skopiował
Kod
string(x)".."

closedeyes.gif
Go to the top of the page
+Quote Post
com
post
Post #8





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


to by mu posypało błędem biggrin.gif no to var_export biggrin.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 20:18