Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zapytanie do SQL
Cold15
post 28.02.2014, 19:52:48
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 28.02.2014

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


Witam.
Mam problem.

Mam szablon na strone, wszystko dobrze zrobiłem, ale żeby layout poprawnie działał to trzeba wykonać zapytanie do SQL, ale nie chce załapać ohno-smiley.gif

Zgodnie z instrukcją robie zapytanie:
  1. <?php
  2. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");
  3. $result = dbquery("CREATE TABLE ".$db_prefix."site_links2 (
  4. link_id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  5. link_name VARCHAR(100) NOT NULL DEFAULT '',
  6. link_url VARCHAR(200) NOT NULL DEFAULT '',
  7. link_visibility TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
  8. link_position TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
  9. link_window TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
  10. link_order SMALLINT(2) UNSIGNED NOT NULL DEFAULT '0',
  11. PRIMARY KEY (link_id)
  12. ) TYPE=MyISAM;");
  13. IF ($result) {
  14. echo "Tabela została dodana.<br />";
  15. } else {
  16. echo "Nie dodano tabeli.<br />";
  17. }
  18.  
  19. $result2 = dbquery("INSERT INTO ".$db_prefix."admin (admin_rights, admin_image, admin_title, admin_link, admin_page) VALUES ('SL', 'site_links.gif', 'Nawigacja 2', 'site_links2.php', 3)");
  20.  
  21. IF ($result2) {
  22. echo "Wpis został dodany.<br />";
  23. } else {
  24. echo "Nie dodano wpisu.<br />";
  25. }
  26. ?>


Ale wywala mi błąd:
  1. Wygląda na TO, że w twoim zapytaniu SQL jest błąd. W znalezieniu przyczyny problemu może pomóc także - jeśli się pojawi - poniższy opis błędu serwera MySQL
  2.  
  3. ERROR: Nieznany znak interpunkcyjny @ 1
  4. STR: <?
  5. SQL: <?php
  6. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");<?php
  7. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");<?php
  8. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");<?php
  9. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");<?php
  10. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");<?php
  11. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");<?php
  12. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");<?php
  13. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");<?php
  14. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");
  15.  
  16. Zapytanie SQL:
  17.  
  18. <?php $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2");
  19.  
  20. MySQL zwrócił komunikat: Dokumentacja
  21.  
  22. #1064 - 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 '<?php
  23. $result = dbquery("DROP TABLE IF EXISTS ".$db_prefix."site_links2")' at line 1


Prosze o pomoc smile.gif
Go to the top of the page
+Quote Post
nospor
post 2.03.2014, 12:55:04
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




To co masz zrobic to jest kod php z wykonaniem kodu mysql. Masz to odpalic w php a nie w mysql....


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

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 Wersja Lo-Fi Aktualny czas: 19.07.2025 - 11:34