I wrote a query but I got following error, Any ideas ?!
Error :
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in E:\AppServ\www\admin\index.php on line 545
Code :
require_once '../_db/databaseConnect.php';
$db = new databaseConnect();
$db->connect();
$queryResult = mysql_query("(SELECT * FROM tabelcomments WHERE publishStatus = 2) UNION (SELECT appTitleFa FROM tableapps WHERE appID = '$appID');");
for ($dataCnt = 0; $dataCnt < mysql_num_rows($queryResult); $dataCnt++)
{
//codes...
}
$db->close();
Both parts of a
UNIONshould return the same amount and same type of columns.Most likely, your
tabelCommentstable contains more columns than the single column returned from thetableAppstable in the second part of your union.You can fix this by explicitly selecting the appropriate column(s) from
tableCommentsor add dummy columns to theUNIONpart.Example