Wuu Posted September 30, 2008 Author Report Share Posted September 30, 2008 Blin ka lai jums iestāsta ERROR metas āra kad mysql neatgriež nekādus parametrus ,kad query neko neatrod jobcik! Skaidrīte? Lai tiktu gala ar to erroru visur jāizmanto empty pārbaude! Link to comment Share on other sites More sharing options...
codez Posted September 30, 2008 Report Share Posted September 30, 2008 Wuu, tu gribi strīdēties arī ar PHP izstrādātājiem? http://lv2.php.net/function.mysql-query Return Values 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. Link to comment Share on other sites More sharing options...
andrisp Posted September 30, 2008 Report Share Posted September 30, 2008 Lūdzu, tad pierādi to mums, un pēc mysql_query() izdrukā pašu kveriju kā arī mysql_error() saturu. Link to comment Share on other sites More sharing options...
bubu Posted September 30, 2008 Report Share Posted September 30, 2008 Blin ka lai jums iestāsta ERROR metas āra kad mysql neatgriež nekādus parametrus ,kad query neko neatrod jobcik! doh, acīmredzot līku SQL kveriju izveido no datiem (x un y), kad tas neko neatgriež. Un ja jau ir kļūda kverijā, tad loģiski ka neko neatgriezīs. Un kā lai tev iestāsta - RTFM. codez jau skaidri un gaiši noquotēja. mysql_query() returns TRUE on success or FALSE on error. Un viena no lietām, ko empty dara, pārbauda uz FALSE vērtību padoto argumentu. Skaidrīte? Nevajag līkus SQL pieprasījumus veidot un vainot php. Link to comment Share on other sites More sharing options...
Wuu Posted September 30, 2008 Author Report Share Posted September 30, 2008 (edited) Skaidrīte vai neskaidrīte empty tapat jalieto tad viss ir ok... p.s. if (mysql_error()) {f(814,'center'); echo 'MySql Error:'.mysql_errno().':'. mysql_error(); f_(); } mysql_close ($link); šitas man stāv visu scriptu beigās visu laiku! Edited September 30, 2008 by Wuu Link to comment Share on other sites More sharing options...
bubu Posted September 30, 2008 Report Share Posted September 30, 2008 mysql_error ir jālieto pēc katra kverija uzreiz. Ja tu pēc kverija izsaukci citu kveriju, tad mysql_error pārbaudīs tikai otrā kverija kļūdas - pirmā kverija kļūdas tas aizmirsīs. Ja nepatīkt mysql_error, tad izdari echo "SELECT ..." mysql_query vietā uz tā "vainīgā" kverija, kurš tev tukšu atgriež. Un iekopē šeit to, ko tev izvada. Link to comment Share on other sites More sharing options...
Ghenis Posted September 30, 2008 Report Share Posted September 30, 2008 Takš var darīt vienkāršāk if(!($result = mysql_query("SELECT * FROM table"))){ throw new errorException(mysql_error()); } //daram tālāk ar datiem, ko gribam. Link to comment Share on other sites More sharing options...
bubu Posted September 30, 2008 Report Share Posted September 30, 2008 Vienkāršāk ir uzrakstīt funkciju, kas to darīs. Tb saņems argumentā kveriju, izpildīs to, un attiecīgi apstrādās kļūdas gadījumu. Nevis katru reizi ar roku manuāli pārbaudīt mysql_query rezultātu. Link to comment Share on other sites More sharing options...
Wuu Posted January 9, 2009 Author Report Share Posted January 9, 2009 (edited) Kāpēc šis strādā? $result = mysql_query('select id from users where id = '.$id.' && active IS NULL limit 1;'); bet šis nē $result = mysql_query('select id from users where id = '.$id.' && active = NULL limit 1;'); Edited January 9, 2009 by Wuu Link to comment Share on other sites More sharing options...
xPtv45z Posted January 9, 2009 Report Share Posted January 9, 2009 Varu kļūdīties, bet tāpēc, ka NULL nav vērtība. :) Link to comment Share on other sites More sharing options...
Gints Plivna Posted January 9, 2009 Report Share Posted January 9, 2009 Kāpēc šis strādā?$result = mysql_query('select id from users where id = '.$id.' && active IS NULL limit 1;'); bet šis nē $result = mysql_query('select id from users where id = '.$id.' && active = NULL limit 1;'); Lasi salīdzināšana ar NULL, tur ir ar visiem piemēriem. Gints Plivna http://datubazes.wordpress.com Link to comment Share on other sites More sharing options...
Recommended Posts