Hello guys, im a bit new to website developing but i dont understand the code 100% i would love to learn alot and here

is something i want to fix in a gaming website for a game im working on take a look im having this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\site_includes\blocks.php on line 23

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\site_includes\blocks.php on line 24

Its pointing to me erros on line 23 and 24 here is line 23 and 24:

// ASC or DESC
$lotto_wina = mysql_fetch_array( $lotto_win ); <-- Line 23
$r8 = mysql_fetch_row( $total_sales ); <---Line 24
$tickets = $r8[0];
if($tickets >= '1')
{
$mysql = mysql_select_db( $SiteSQL["config-database_db"] , $Site_sqlcon) or die( mysql_error() );
$lotto_win2 = mysql_query("SELECT a_name FROM t_characters WHERE a_admin = '0' AND a_enable = '1' AND a_user_code = ". $lotto_wina['a_user_index'] ." ");
$lotto_wina3 = mysql_fetch_array( $lotto_win2 );
$lottowinner = $lotto_wina3['a_name']; } else { $lottowinner = "No Winner"; };
$mysql = mysql_select_db( $SiteSQL["config-database_site"] , $Site_sqlcon) or die( mysql_error() );
$result_settings = mysql_query("SELECT a_customblock_on, a_customblock_title, a_custonblock_code, a_vote1, a_vote2, a_vote3, a_vote4 from t_settings WHERE a_index = 1");
$result_settings1 = mysql_fetch_array( $result_settings );