Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Checkbox-błąd przy otwieraniu strony.!
woxala123
post
Post #1





Grupa: Zarejestrowani
Postów: 361
Pomógł: 12
Dołączył: 9.01.2010

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


Witam.
Mam oto taki stworzony plik do edytowania i usuwania userów. Gdy go otwieram to wyskakuje mi błąd:

"Notice: Undefined index: checkbox in D:\xampp\htdocs\yogi\fff.php on line 127

Warning: implode(): Invalid arguments passed in D:\xampp\htdocs\yogi\fff.php on line 127
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1"

Domyślam się że mogę mieć sformułowany checkbox. Tylko próbujeę różnych technik i siedzę w martwym punkcie. Czy może chodzi o funkcję implode.[php]

oto linijka 127 kodu

$query_Recordset1 = "SELECT user_id, firstname, lastname, username, password, email, dateregister, lastlogin, active FROM userlogin WHERE user_id IN (". implode(',',$_POST['checkbox']).")";

Pozdrawiam i życzę Szczęsliwego Nowego Roku 2016


Ten post edytował woxala123 3.01.2016, 11:03:37
Go to the top of the page
+Quote Post
viking
post
Post #2





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

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


Nie masz zmiennej $_POST['checkbox', w związku z czym sypie się implode czego następstwem jest błąd zapytania. Do tego jeszcze sql injection.
Masz wszystko opisane, wystarczy czytać co PHP do ciebie "mówi".


--------------------
Go to the top of the page
+Quote Post
woxala123
post
Post #3





Grupa: Zarejestrowani
Postów: 361
Pomógł: 12
Dołączył: 9.01.2010

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


No włąśnie dodałem zmienną i teraz wyskakuje to samo
Notice: Undefined index: checkbox in D:\xampp\htdocs\yogi\fff.php on line 127

Notice: Undefined index: checkbox in D:\xampp\htdocs\yogi\fff.php on line 128

Warning: implode(): Invalid arguments passed in D:\xampp\htdocs\yogi\fff.php on line 128
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
Go to the top of the page
+Quote Post
viking
post
Post #4





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

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


W jaki sposób dodałeś? Ona pochodzi zapewne z formularza.


--------------------
Go to the top of the page
+Quote Post
woxala123
post
Post #5





Grupa: Zarejestrowani
Postów: 361
Pomógł: 12
Dołączył: 9.01.2010

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


dodałęm przed linijką 127
Go to the top of the page
+Quote Post
viking
post
Post #6





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

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


Szał. Ja bym dodał przed 46.


--------------------
Go to the top of the page
+Quote Post
woxala123
post
Post #7





Grupa: Zarejestrowani
Postów: 361
Pomógł: 12
Dołączył: 9.01.2010

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


Jak chcesz viking to prześle ci plik z kodem i podpowiedz gdzie w tkwi błąd i sam spróbuje z twoim nakierowaniem go rozwiązać.
Go to the top of the page
+Quote Post
viking
post
Post #8





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

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


Wklej kod tutaj. Konkretnie ten który dodałeś - na początek. Bo jak pewnie rozumiesz nie mamy tu szklanych kul. Kiedy mówisz że coś dodałeś - nie wiemy co, w jakim systemie i jak to coś działa.


--------------------
Go to the top of the page
+Quote Post
woxala123
post
Post #9





Grupa: Zarejestrowani
Postów: 361
Pomógł: 12
Dołączył: 9.01.2010

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


Tu jest link http://wklej.to/WOu90 do kodu
Go to the top of the page
+Quote Post
viking
post
Post #10





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

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


Wstaw tam to samo co w 211 i może zadziała. Dawno takiego śmietnika nie widziałem.


--------------------
Go to the top of the page
+Quote Post
woxala123
post
Post #11





Grupa: Zarejestrowani
Postów: 361
Pomógł: 12
Dołączył: 9.01.2010

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


Notice: Undefined index: checkbox in D:\xampp\htdocs\yogi\fff.php on line 127

Notice: Undefined index: checkbox in D:\xampp\htdocs\yogi\fff.php on line 128

Warning: implode(): Invalid arguments passed in D:\xampp\htdocs\yogi\fff.php on line 128
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM 'userlogin' WHERE 'user_id' IN ()' at line 1
Próbuje jeszcze z tym sql powalczyć teraz tak zrobiłem i wywala to co u góry
$checkbox=$_POST['checkbox'];
$query_Recordset1 = "SELECT 'user_id', 'firstname', 'lastname', 'username', 'password', 'email', 'dateregister', 'lastlogin', 'active' * FROM 'userlogin' WHERE 'user_id' IN (" .implode(',' ,$_POST['checkbox']).")";
Go to the top of the page
+Quote Post
com
post
Post #12





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

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


nie rób implode w stringu, pyzatym musisz mieć warunek który sprawdza czy jest POST bo tak lecą notice wink.gif
Go to the top of the page
+Quote Post
woxala123
post
Post #13





Grupa: Zarejestrowani
Postów: 361
Pomógł: 12
Dołączył: 9.01.2010

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


Witam!
Rozwiązanie było bardzo banalne proste. Nie było kolumny lastlogin i dlatego wywalał komunikat o sql który odnosił się do informacji że żle zdefiniowane zapytanie.
Wszystkim serdecznie dziękuje za zainteresowanie się tematem. Choć teraz będę pracował jak zrobić by zaznaczonych userów przenieść do następnej strony by móc ich edytować.Z góry dziękuje już osobom które może coś podpowiedzą do tego kodu. Pozdrawiam.
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: 19.08.2025 - 02:27