![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 53 Pomógł: 0 Dołączył: 4.12.2009 Ostrzeżenie: (0%) ![]() ![]() |
Witam, mam problemik z dodawaniem klienta do bazy danych. Mam formularz z którego pobierane są dane i za pomocą zapytania mysql (Insert) mają zostać dodane do bazy, jednak występuje problem.
oto kod:
Samo zapytanie mysql jest poprawne, problem pojawia się przy instrukcji if. Jeżeli wykomentuje instrukcję klient zostaje dodany do bazy ale nie mam żadnego potwierdzenia tej operacji. Instrukcja ma wywołać komunikat pozytywny lub negatywny w zależności od tego czy klient został dodany. Cały czas wyskakuje mi taki błąd: Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\boss\add_panel\add_client.php on line 100 Niestety, dodanie klienta nie powiodło się Proszę o pomoc gdzie robię błąd i dlaczego bez if zapytanie zostaje wykonane a z if wysypuje się. |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 2 885 Pomógł: 463 Dołączył: 3.10.2009 Skąd: Wrocław Ostrzeżenie: (0%) ![]() ![]() |
Zobacz co zwraca mysql_query dla poleceń INSERT, nie zwraca zasobu, a booleana:
Cytat For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error. For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error. The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data. Use mysql_num_rows() to find out how many rows were returned for a SELECT statement or mysql_affected_rows() to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement. mysql_query() will also fail and return FALSE if the user does not have permission to access the table(s) referenced by the query. Pilsener raczej nie przeczytałeś tematu, zapytanie jest poprawne, nie o to chodziło. Agata czyli wystarczy tak:
Ten post edytował darko 21.12.2009, 15:06:59 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 6.10.2025 - 20:42 |