pX79 Posted October 16, 2008 Report Share Posted October 16, 2008 Sveiki. Tiek attālināti izmantots MySQL 4.0.24, PHP Version 4.4.8 un Apache/1.3.41 (Unix). Uz tā es nevaru neko mainīt. Nekādi neizdodas atrast kāpēc nestrādā atiecīgais kods. $query = "SELECT ne.ne_id, DATE_FORMAT(ne.ne_add, '%Y-%m-%d %H:%i:%s') AS ne_add, ne.ne_userid, RTRIM(ne.ne_title) AS ne_title, RTRIM(ne.ne_news) AS ne_news, ne.ne_prew, CONCAT(RTRIM(us.us_lastname), ' ', RTRIM(us.us_firstname)) AS auth1, nc.comCount1 FROM tbl_hk_news AS ne LEFT JOIN tbl_hk_user AS us ON ne.ne_userid = us.us_userid LEFT JOIN (SELECT Count(nc_commentid) AS comCount, nc_newsid FROM tbl_hk_news_comment GROUP BY nc_newsid) AS nc ON ne.ne_id = nc.nc_newsid WHERE ne.ne_prew=0 ORDER BY ne.ne_add DESC"; $result = mysql_query($query, $connection); echo '<p>'.mysql_num_rows($result).'</p>'; for($i = 0; $i < mysql_num_rows($result); $i++) // NORĀDA KA ŠAJĀ RINDĀ IR PROBLĒMA. { $a = mysql_result($result, $i, "ne.ne_id"); Met ārā šādu paziņojumu " Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /user.php on line 146 ". Tajā rindā ir for($i = 0; $i < mysql_num_rows($result); $i++) kods. Lokāli uz WinXP datora viss strādā normāli. Kurā vietā varētu būt problēma? Link to comment Share on other sites More sharing options...
andrisp Posted October 16, 2008 Report Share Posted October 16, 2008 Kverijs nepareizs. Kas tieši par problēmu - to var noskaidrot ar mysql_error() satura izdrukāšanu uzreiz pēc mysql_query(). Link to comment Share on other sites More sharing options...
pX79 Posted October 16, 2008 Author Report Share Posted October 16, 2008 Viņš izmet šādu paziņojumu You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT Count(nc_commentid) AS comCount, nc_newsid FROM tbl_hk_n bet es tur neredzu nekādu kļūdu. Link to comment Share on other sites More sharing options...
andrisp Posted October 16, 2008 Report Share Posted October 16, 2008 (edited) Pag, tu centies LEFT JOINot subselektu ? Tad ļoti iespējams, ka 4 versija to neatblasta, bet tikai 5ā. Jā: http://dev.mysql.com/doc/refman/5.0/en/subqueries.html Starting with MySQL 4.1, all subquery forms and operations that the SQL standard requires are supported, as well as a few features that are MySQL-specific. Edited October 16, 2008 by andrisp Link to comment Share on other sites More sharing options...
bubu Posted October 16, 2008 Report Share Posted October 16, 2008 Lokāli uz WinXP datora viss strādā normāli. Uzliec lokāli tieši tādas pašas MySQL, PHP un Apache versijas, un tad pamēģini ;) Link to comment Share on other sites More sharing options...
Recommended Posts