I have a piece of code
$sql = "(SELECT ID, url, alttext FROM cards WHERE (worth = 1 AND deny = 0) ORDER BY RAND() LIMIT ".$limit.") UNION (SELECT ID, url, alttext FROM cards WHERE (worth = 2 AND deny = 0) ORDER BY RAND() LIMIT 2)";
$result = mysql_query($sql) or die(sql_error($sql)); $card = '';
while($row = mysql_fetch_array($result)) {
$sql = "INSERT INTO user_inventory3 (ID, user_id, card_id, status, `from`) VALUES (NULL, '".$userid."', '".$row['ID']."', 'undefined', 'Join')"; $result = mysql_query($sql) or die(sql_error($sql));
$card .= '<img src="'.$row['url'].'" alt="'.$row['alttext'].'">';
}
which is supposed to select a certain amount of rows from the database, the amount defined in $limit.
The query seems to be fine, i can run it in phpmyadmin without problem.
But on the webpage i get the following error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.lagoons/midnighttempest/smarty/join2.php on line 54
Its probably something simple, but obviously something is wrong somewhere and i can't find it.
I get 1 image displayed, and that one is also entered in the insert, but there should be a total of 8/9 displayed/entered