Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Nie oczekujący błąd
pawel06281990
post 13.03.2019, 13:12:09
Post #1





Grupa: Zarejestrowani
Postów: 281
Pomógł: 0
Dołączył: 10.01.2014

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


Witam,

Nie wiem dla czego pokazał mi się taki błąd

  1. Warning: mysqli_query() expects parameter 1 to be mysqli, string given in /home/twojhost/public_html/panel/funkcje.php on line 108
  2.  
  3. Warning: mysqli_error() expects parameter 1 to be mysqli, string given in /home/twojhost/public_html/panel/funkcje.php on line 110


To jest funkcja łączenia i zapisu mysqli działała mi to a teraz o coś mu chodzi ale nie wiem o co.

To moja funkcja

  1. function dbquery($link,$query) {
  2. $result = mysqli_query($link, $query);
  3. if (!$result) {
  4. echo mysqli_error($link);
  5. return false;
  6. } else {
  7. return($result);
  8. }
  9. }


A tak łącze sie z bazą danych

  1. $link = mysqli_connect($db_host, $db_user, $db_pass, $db_name);


O co mu chodzi. Proszę pomuszcie
Go to the top of the page
+Quote Post
nospor
post 13.03.2019, 13:21:35
Post #2





Grupa: Moderatorzy
Postów: 36 447
Pomógł: 6292
Dołączył: 27.12.2004




Gdzies tam w odmetach swojego kodu masz wywolanie dbquery() i wlasnie gdzies tam zle wstawiles parametry wywolania i zamiast query wstawiles link a zamiast link wstawiles query...

ps:
Cytat
Nie oczekujący błąd
Nie zebym sie jakos specjalnie czepiaj, ale chyba chciales napisac:
Nieoczekiwany błąd

ps2:
Cytat
pomuszcie

Wymienia sie na POMOC a wiec Ó oraz Ż od "pomożecie"
pomóżcie


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

"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
pawel06281990
post 13.03.2019, 13:26:53
Post #3





Grupa: Zarejestrowani
Postów: 281
Pomógł: 0
Dołączył: 10.01.2014

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


Dzięki za naukę języka polskiego smile.gif

A tak nawiasem to tak wygląda mój kod zapisu

  1. $result = dbquery($link,"INSERT INTO ".$db_prefix."certyfikatyssl SET id_user ='".$userdata['user_id']."', actionId='1', certId='2', certContactId='3'");


Ale ja tu błędu nie wiedzę.
Go to the top of the page
+Quote Post
nospor
post 13.03.2019, 13:28:38
Post #4





Grupa: Moderatorzy
Postów: 36 447
Pomógł: 6292
Dołączył: 27.12.2004




No to zrob var_dump w funkcji dbquery i wszystko bedzie jasne

  1. function dbquery($link,$query) {
  2. var_dump($link);
  3. $result = mysqli_query($link, $query);
  4. .....
  5. }


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

"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
pawel06281990
post 13.03.2019, 13:43:33
Post #5





Grupa: Zarejestrowani
Postów: 281
Pomógł: 0
Dołączył: 10.01.2014

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


No i dostaje taki komunikat

  1. object(mysqli)#1 (19) {
  2. ["affected_rows"]=>
  3. int(0)
  4. ["client_info"]=>
  5. string(79) "mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $"
  6. ["client_version"]=>
  7. int(50012)
  8. ["connect_errno"]=>
  9. int(0)
  10. ["connect_error"]=>
  11. NULL
  12. ["errno"]=>
  13. int(0)
  14. ["error"]=>
  15. string(0) ""
  16. ["error_list"]=>
  17. array(0) {
  18. }
  19. ["field_count"]=>
  20. int(0)
  21. ["host_info"]=>
  22. string(25) "Localhost via UNIX socket"
  23. ["info"]=>
  24. NULL
  25. ["insert_id"]=>
  26. int(0)
  27. ["server_info"]=>
  28. string(21) "5.5.5-10.3.13-MariaDB"
  29. ["server_version"]=>
  30. int(50505)
  31. ["stat"]=>
  32. string(140) "Uptime: 46933 Threads: 10 Questions: 63090 Slow queries: 0 Opens: 1347 Flush tables: 1 Open tables: 338 Queries per second avg: 1.344"
  33. ["sqlstate"]=>
  34. string(5) "00000"
  35. ["protocol_version"]=>
  36. int(10)
  37. ["thread_id"]=>
  38. int(2438)
  39. ["warning_count"]=>
  40. int(0)
  41. }
  42. object(mysqli)#1 (19) {
  43. ["affected_rows"]=>
  44. int(1)
  45. ["client_info"]=>
  46. string(79) "mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $"
  47. ["client_version"]=>
  48. int(50012)
  49. ["connect_errno"]=>
  50. int(0)
  51. ["connect_error"]=>
  52. NULL
  53. ["errno"]=>
  54. int(0)
  55. ["error"]=>
  56. string(0) ""
  57. ["error_list"]=>
  58. array(0) {
  59. }
  60. ["field_count"]=>
  61. int(23)
  62. ["host_info"]=>
  63. string(25) "Localhost via UNIX socket"
  64. ["info"]=>
  65. NULL
  66. ["insert_id"]=>
  67. int(0)
  68. ["server_info"]=>
  69. string(21) "5.5.5-10.3.13-MariaDB"
  70. ["server_version"]=>
  71. int(50505)
  72. ["stat"]=>
  73. string(140) "Uptime: 46933 Threads: 10 Questions: 63091 Slow queries: 0 Opens: 1347 Flush tables: 1 Open tables: 338 Queries per second avg: 1.344"
  74. ["sqlstate"]=>
  75. string(5) "00000"
  76. ["protocol_version"]=>
  77. int(10)
  78. ["thread_id"]=>
  79. int(2438)
  80. ["warning_count"]=>
  81. int(0)
  82. }


I co wynika questionmark.gif

Edit

Mój błąd zobaczyłem co było nie tak bo $link zapisałem zmiena klas dla certyfikatów smile.gif

Ten post edytował pawel06281990 13.03.2019, 13:49:54
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.04.2024 - 22:33