omegle clone的mysql_num_rows错误[关闭]

Upon downloading an omegle clone. This is of course poorly written, so there is an error in a crucial file. here's the site if you want to check it out. The error I get is Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a1687121/public_html/listenToReceive.php on line 11 here is the file:

<?php
$userId=$_REQUEST["userId"];

$msg   ="";
$randomUserId;

include ('config.inc.php');
include ('database.inc.php');
$result=mysql_query("SELECT * FROM chats WHERE userId = $userId ");

if (mysql_num_rows($result) > 0)
    {
    $result=mysql_query("SELECT * FROM msgs WHERE randomUserId = $userId ORDER BY sentdate limit 1");

    $id    =0;

    while ($row=mysql_fetch_array($result))
        {
        $id          = $row["id"];
        $msg         =$row["msg"];
        $randomUserId=$row["userId"];
        }

    if ($id != 0)
        {
        mysql_query ("DELETE FROM msgs WHERE id = $id ");
        mysql_query ("INSERT INTO oldMsgs(userId,randomUserId,msg) VALUES( $randomUserId,$userId,'$msg'); ");
        }
    }
else
    {
    echo "||--rut roh!--||";
    }

mysql_close ($con);

echo $msg;
?>

I checked it a million times. I cant find anything wrong. Thanks!

$result=mysql_query("SELECT * FROM chats WHERE userId = $userId ");
// add the error check
if (!$result) {
    die('ERROR: ' . mysql_error());
}