Jump to content

Recommended Posts

i get this error when i ahve this code
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/chris/public_html/index.php on line 199

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253

Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253


[code]
<?
mysql_select_db($database_localhost, $localhost);
$query_archives = "SELECT date_format(date, '%Y-%c-%e') as ArticleDate FROM articles";
$archives = mysql_query($query_archives, $localhost) or die(mysql_error());
$row_archives = mysql_fetch_assoc($archives);
$totalRows_archives = mysql_num_rows($archives);
?>
<?php
            function build_calendar($month,$year,$day) {
                /* Declaring the variables */
                $daysOfWeek = array('Su','Mo','Tu','We','Th','Fr','Sa');
                $firstDayOfMonth = mktime(0,0,0,$month,1,$year);
                $noDays = date('t',$firstDayOfMonth);
                $dateComponents = getdate($firstDayOfMonth);
                $dayOfWeek = $dateComponents['wday'];
                $monthName = date('F',mktime(0,0,0,$month,1,$year));
                
                global $rsArticleDates;
                global $_GET;
                
                if (mysql_num_rows($archives) > 0){
                    mysql_data_seek($archives,0);
                    while($row_archives = mysql_fetch_assoc($archives)){
                        $dates[] = $row_archivess['date'];
                    }
                }
    
                /* Computing the previous month. */
                if($month == 1) {
                     $mn=12;
                     $yn=$year-1;
                 } else {
                         $mn=$month-1;
                         $yn=$year;
                }
                
                /* Computing the next month. */
                if($month == 12) {
                    $mn2=1;
                    $yn2=$year+1;
                } else {
                    $mn2=$month+1;
                    $yn2=$year;
                }
                
                /* Calendar header: next and previous month links */
                $calendar = "<table>";
                $calendar .= "<tr><td><a href=day.php?m=$mn&y=$yn&d=$day>&lt;</a></td>";
                $calendar .="<td colspan=5 align=center>$monthName, $year</td>";
                $calendar .="<td><a href=day.php?m=$mn2&y=$yn2&d=$day>&gt;</a></td></tr>";
                $calendar .="<tr>";         
                
                /* Calendar header: Display the days of the week */
                foreach($daysOfWeek as $day) {
                      $calendar .= "<td>$day</td>";
                }
                $calendar .= "</tr>";
                $calendar .= "<tr>";

              $currentDay = 1;
            

              /* Fill in the beginning of the calendar    body */    
              if ($dayOfWeek > 0) {  
                 $calendar .= "<td  colspan='$dayOfWeek'>&nbsp;</td>";  
              }
            
              /* Generate the calendar body */        
              while ($currentDay <= $noDays) {
                    if ($dayOfWeek == 7) {
                       $dayOfWeek = 0;
                       $calendar .= "</tr><tr>";
                    }
                    $date = $year."-".$month."-".$currentDay;
                    if (in_array($date,$dates)) {
                        $calendar .= "<td><a href='day.php?m=$month&y=$year&d=$currentDay'>$currentDay</a></td>";
                    } else {
                        $calendar .= "<td>$currentDay</td>";
                    }
                   $currentDay++;
                   $dayOfWeek++;
              }

            /* Filling in the end of the calendar body */
            if ($dayOfWeek != 7) {  
                  $remainingDays = 7 - $dayOfWeek;
                  $calendar .= "<td colspan='$remainingDays'>&nbsp;</td>";  
            }
  
              $calendar .= "</table>";
            return $calendar;
}
if (isset($_GET['m']) && isset($_GET['y']) && isset($_GET['d'])){    
    $month = $_GET['m'];
    $year = $_GET['y'];
    $day = $_GET['d'];
} else {
    $dateComponents = getdate();
    $month = $dateComponents['mon'];
    $year = $dateComponents['year'];
    $day = $dateComponents['mday'];
}

echo build_calendar($month,$year,$day);

        ?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/10758-clander/
Share on other sites

[!--coloro:#999999--][span style=\"color:#999999\"][!--/coloro--]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/chris/public_html/index.php on line 199[!--colorc--][/span][!--/colorc--]
Your mysql_num_rows obviously failed which, according to your code, would skip the $dates creation
So you technically have no variable $dates if mysql_num_rows() failed explaining this error
[!--coloro:#C0C0C0--][span style=\"color:#C0C0C0\"][!--/coloro--]Warning: in_array(): Wrong datatype for second argument in /home/chris/public_html/index.php on line 253[!--colorc--][/span][!--/colorc--]

which you posted ...... many many times in a row

So the key is to fix your mysql_num_rows....

check your MySQL result resource...which is $query_archives, AKA your query
and make sure that your date field in your database is of the DATE/DATETIME datatype
Link to comment
https://forums.phpfreaks.com/topic/10758-clander/#findComment-40188
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.