Jump to content
php.lv forumi

Nekādi negrib strādāt vienkārš PHP/MySQL kods uz hostētāja servera.


pX79

Recommended Posts

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

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

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 by andrisp
Link to comment
Share on other sites

×
×
  • Create New...