Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MySQL]problem z sql
Forum PHP.pl > Forum > Przedszkole
grucha87
probouje zaimportowac na yoyo baze ale wywala mi bład co w niej jest nie tak?:
  1. <?php
  2. class error
  3. {
  4. Public $type;
  5. Public $text;
  6.  
  7. function printme()
  8. {
  9. echo $this -> text;
  10. }
  11. }
  12.  
  13. class db
  14. {
  15. Public $guery;
  16. Public $output;
  17. Public $connected;
  18. public $conected;
  19. private static $instance;
  20.  
  21. private function __construct()
  22. {
  23. include ('config/db.php');
  24. if(mysql_connect($host, $dbuser, $dbpass))
  25. {
  26. $this -> connected = "true";
  27. mysql_select_db($dbname);
  28. // mysql_query('SET NAMES "utf8"');
  29. }
  30. else
  31. {
  32. $err = new error();
  33. $err -> text = "Nie uda�o si� po��czy� z baz�";
  34. $err -> printme();
  35. }
  36. }
  37.  
  38. public static function getInstance()
  39. {
  40. if(empty(self::$instance))
  41. self::$instance = new db();
  42. return self::$instance;
  43. }
  44.  
  45. function getRow($query)
  46. {
  47. $result = mysql_query($query);
  48. $row = mysql_fetch_assoc($result);
  49. $this -> output = $row;
  50. return $this -> output;
  51. }
  52.  
  53. function getValue($query,$value)
  54. {
  55. $result = mysql_query($query);
  56. $row = mysql_fetch_assoc($result);
  57. $this -> output = $row["$value"];
  58. return $this -> output;
  59. }
  60.  
  61. function getAll($query)
  62. {
  63. $result = mysql_query($query);
  64. $i = 0;
  65. while ($row = mysql_fetch_assoc($result))
  66. {
  67. $arr[$i] = $row;
  68. $i++;
  69. }
  70. $this -> output = $arr;
  71. return $this -> output;
  72. }
  73.  
  74. function count($query)
  75. {
  76. $result = mysql_query($query);
  77. $i = 0;
  78. while ($row = mysql_fetch_assoc($result))
  79. {
  80. $i++;
  81. }
  82. $this -> output = $i;
  83. return $this -> output;
  84. }
  85.  
  86. function send($query)
  87. {
  88. mysql_query($query);
  89. }
  90.  
  91. function test()
  92. {
  93. echo $this -> conected;
  94. }
  95. }
  96. ?>
skowron-line
Cytat(grucha87 @ 18.12.2009, 12:22:58 ) *
probouje zaimportowac na yoyo baze ale wywala mi bład co w niej jest nie tak?:

Moja szklana kula mówi mi że jest to problem na linii krzesło -> klawiatura. Bądź łaskaw i pokaż nam jaki to błąd.
grucha87
  1. [b]Błąd[/b]
  2. 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.
  3.  
  4. ERROR: Nieznany znak przestankowy @ 1
  5. STR: <?
  6. SQL: <?php
  7. class db
  8. {
  9. Public $guery;<?php
  10. class db
  11. {
  12. Public $guery;<?php
  13. class db

  1. [b]apytanie SQL:[/b] <?php class db { Public $guery;
  2.  
  3. [b]MySQL zwrócił komunikat: [/b][url="http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html"][img]http://mysql1.yoyo.pl/themes/original/img/b_help.png[/img][/url]
  4.  
  5. #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
  6. class db
  7. {
  8. Public $guery' at line 1
piotrekkr
Eee wygląda na to że w zapytaniu wysyłasz kod php smile.gif Możliwe że tak miało być ale zapomniałeś użyć mysql_real_escape_string() na dodawanej treści.
grucha87
ale gdzie to mam dodac?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.