Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Niepoprawne zapytanie: Unknown column 'artist_id' in 'where clause'
powertee
post
Post #1





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 13.12.2007
Skąd: Katowice/Goleniowy

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


Witam mam problem, wydaje mi sie ze kod jest wporządku ale wyświetla mi coś takiego:

Niepoprawne zapytanie: Unknown column 'artist_id' in 'where clause'

szukałem troche i znalazłem ze dzieje sie tak z przejsciaz mysql4 na mysql 5.
podobno da sie przerobić kod zeby działał a ja nie mamam pojęcia jak...
no i teraz stare dobre hasło: POMOŻECIE?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/rolleyes.gif)

  1. <?
  2. $link = mysql_connect("localhost", "xxx", "xxx")
  3. or die("nie udalo sie poilaczyc: " . mysql_error());
  4. mysql_select_db("baza", $link)
  5. or die("cos jest nie tak!!! " . mysql_error());
  6.  
  7. $convert['artist'] = 'wybranego wykonawce' ; $convert['song'] = 'wybrany utwór';
  8.  
  9. /* USUWANIE */
  10.  
  11. if (!isset($_GET['do']) && $_GET['do'] != 1) {
  12. ?>
  13. <p align="center" style="color:#FF0000">
  14. Czy napewno chcesz usunąć 
  15. <?php
  16. echo $convert[$_GET['type']]; ?>?<br>
  17. <a href="<? echo $_SERVER['REQUEST_URI']; ?>&do=1">tak</a>
  18.  lub <a href="index.php">nie</a>
  19. </p>
  20. <?
  21. } else 
  22. { 
  23. if ($_GET['type'] == "artist") {
  24. $artista = "UPDATE song
  25. SET id_artist_song = '0'
  26. WHERE id_artist_song = '" . $_GET['id'] . "'";
  27. $result = mysql_query($artista)
  28. or die("Niepoprawne zapytanie xxx : " . mysql_error());
  29. }
  30. $sql = "DELETE FROM " . $_GET['type'] . "
  31. WHERE " . $_GET['type'] . "_id = '" . $_GET['id'] . "'
  32. LIMIT 1";
  33. echo "<!--" . $sql . "==>";
  34.  
  35. $result = mysql_query($sql) or die("Niepoprawne zapytanie: " . mysql_error());
  36. ?>
  37. <p align="center" style="color:#FF0000">
  38. Wybrany <? echo $convert[$_GET['type']]; ?> został usuniety.
  39. <a href="index.php"> Powrót do listy</a></p>
  40. <?
  41. }
  42. ?>


Ten post edytował powertee 18.01.2008, 18:27:58
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
Danone
post
Post #2





Grupa: Zarejestrowani
Postów: 169
Pomógł: 16
Dołączył: 18.10.2006
Skąd: Olsztyn/Wrocław

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


moim zdaniem tutaj masz:

  1. WHERE " . $_GET['type'] . "_id = '" . $_GET['id'] . "'


a powinno być
  1. WHERE '" . $_GET['type'] . "'_id = '" . $_GET['id'] . "'




poza tym używaj bbcode (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) , bo tak jak masz teraz, to nawet nie chce się czytać (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował Danone 18.01.2008, 18:18:34
Go to the top of the page
+Quote Post
powertee
post
Post #3





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 13.12.2007
Skąd: Katowice/Goleniowy

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


jak zmienie tak jak ty mówisz tozgłasz :
Niepoprawne zapytanie: 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 '_id = ' 3' LIMIT 1' at line 2
Go to the top of the page
+Quote Post
Danone
post
Post #4





Grupa: Zarejestrowani
Postów: 169
Pomógł: 16
Dołączył: 18.10.2006
Skąd: Olsztyn/Wrocław

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


Troszkę rozpędziłem się z odpowiedzią (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Wychodzi na to, że nie masz takiej kolumny jak artist_id.

Masz ją w ogóle? (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
powertee
post
Post #5





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 13.12.2007
Skąd: Katowice/Goleniowy

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


nie mam mam id_artist nie wiem skąd mysql wzioł wogule artist_id
Go to the top of the page
+Quote Post
Daimos
post
Post #6





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

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


no wlasnie nie wzial, dlatego jest problem
nie ma jej, a probojesz ja wywolac

  1. <?php
  2. $sql = "DELETE FROM " . $_GET['type'] . "
  3. WHERE " . $_GET['type'] . "_id = '" . $_GET['id'] . "'
  4. LIMIT 1";
  5. ?>


w powyzszym kodzie gdy masz $_GET['type']=artists
to logiczne ze odwolujesz sie do kolumny artists_id
Go to the top of the page
+Quote Post
powertee
post
Post #7





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 13.12.2007
Skąd: Katowice/Goleniowy

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


to jak przerobić ten skrypt zeby zamiast kolumny
  1. <?php
  2. artist_id
  3. ?>
wywołać kolumne
  1. <?php
  2. id_artist
  3. ?>
(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
webdice
post
Post #8


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




  1. <?php
  2. $sql = "DELETE FROM " . $_GET['type'] . "
  3. WHERE id_" . $_GET['type'] . " = '" . $_GET['id'] . "'
  4. LIMIT 1";
  5. ?>


Ten post edytował webdicepl 18.01.2008, 19:59:42
Go to the top of the page
+Quote Post
powertee
post
Post #9





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 13.12.2007
Skąd: Katowice/Goleniowy

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


Działa!! Dzieki wszystkim... Jestem początkujący ale sie ucze... pozdro
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 27.09.2025 - 02:00