21-07-2012, 02:41
Słabo czytałeś ten manual:
Cytat: For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.Patrz zwłaszcza pierwszy i drugi akapit.
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.
(20-07-2012, 19:50)Moody napisał(a): Jeśli tak zrobię to echo drukuje mi "Resource id #5"No a co ma drukować?
(20-07-2012, 19:50)Moody napisał(a): Może mi ktoś wytłumaczyć dlaczego zwraca coś takiego i w takim razie jeśli to zwraca Resource id #5 to jak if na to reaguje, że zwraca true i wykonuje blok instrukcji?Bo czytacie ten manual i nie rozumiecie. Funkcja ta zwróci Ci true w przypadku jeśli zapytanie zostanie WYKONANE, a false w innym razie. Rezultat nie ma najmniejszego znaczenia. Ona Ci, w przypadku wykonania zapytania, zwraca resource, po którym to musisz przejechać funkcją mysql_fetch_assoc() czy też mysql_fetch_array().
Dobre samopoczucie w tym tygodniu sponsoruje cytat:
Cytat:Mogę tylko tylko na prawo i lewo ale na środek nie mogę.