PHP / MySQL Hata Kodu - phpMyAdmin ince Çıkışlar ama Browser Hatalar

0 Cevap php

Ben bir MySQL sorgusu koşuyorum, işte burada:

CREATE TEMPORARY TABLE LeaderBoard (
`agent_name` varchar(20) NOT NULL,
`job_number` int(5) NOT NULL,
`job_value` decimal(3,1) NOT NULL,
`points_value` decimal(8,2) NOT NULL
);
INSERT INTO LeaderBoard (`agent_name`, `job_number`, `job_value`, `points_value`) SELECT agent_name, job_number, job_value, points_value FROM jobs WHERE YEAR(booked_date) = 2010 && WEEKOFYEAR(booked_date) = 49;
INSERT INTO LeaderBoard (`agent_name`) SELECT DISTINCT agent_name FROM apps WHERE YEAR(booked_date) = 2010 && WEEKOFYEAR(booked_date) = 49;
SELECT agent_name, SUM(job_value), SUM(points_value) FROM leaderboard GROUP BY agent_name ORDER BY SUM(points_value) DESC

I phpmyadmin sql alanında bu sorguyu çalıştırırsanız, çalışır ve ben kullanmak istiyorum doğru veriyi olsun!

"Uyarı: mysql_fetch_array () parametre 1 C verilen kaynak, dize olmasını bekler: hattında 383 \ xampp \ htdocs \ reporting_2010.php" Ben benim PHP komut dosyası içine bu koyduğunuzda Ama söyleyerek bir hata ile geri geliyor

İşte benim PHP Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Reports - Yearly Summary 2010</title>
    <link rel="stylesheet" type="text/css" href="css/allreset.css">
    <link rel="stylesheet" type="text/css" href="css/input.css">
    <link rel="stylesheet" type="text/css" href="css/calendar.css">
    <script language="JavaScript" src="calendar_db.js"></script>
</head>

<?php include("config.php"); ?>

<body>

<?php

/* Config Script START */

    $current_year = 2010;

/* Config Script END */

    $date_today = date("Y-m-d");
    $day_number = date('w');
    $week_begin = date("Y-m-d",time() - ($day_number)*60*60*24);
    $last_week = $current_week - 1;
    $days[0] = 'Saturday';
    $days[1] = 'Sunday';
    $days[2] = 'Monday';
    $days[3] = 'Tuesday';
    $days[4] = 'Wednesday';
    $days[5] = 'Thursday';
    $days[6] = 'Friday';
    $time_now = date ('H:i:s');

    $result = mysql_query("SELECT booked_date FROM jobs WHERE YEAR(booked_date) = $current_year GROUP BY WEEKOFYEAR(booked_date)");
    $numrows = mysql_num_rows($result);

    function getAgentAppsDay($agent_search,$day_search,$current_year) {
        $result = mysql_query("SELECT * FROM apps WHERE YEAR(booked_date) = '$current_year' && agent_name = '$agent_search' && booked_date = '$day_search' ");
        $num_apps = mysql_numrows($result);
        return $num_apps;
    }

    function getAgentAppsWeek($agent_search,$week_search,$current_year) {
        $result = mysql_query("SELECT * FROM apps WHERE YEAR(booked_date) = '$current_year' && agent_name = '$agent_search' && WEEKOFYEAR(booked_date) = '$week_search' ");
        $num_apps = mysql_numrows($result);
        return $num_apps;
    }

    function getAppsDay($day_search,$current_year) {
        $result = mysql_query("SELECT * FROM apps WHERE YEAR(booked_date) = '$current_year' && booked_date = '$day_search' ");
        $num_apps = mysql_numrows($result);
        return $num_apps;
    }

    function getAppsDayNumber($day_search,$current_year) {
        $result = mysql_query("SELECT * FROM apps WHERE YEAR(booked_date) = '$current_year'&& DAYOFWEEK(booked_date) = '$day_search' ");
        $num_apps = mysql_numrows($result);
        return $num_apps;
    }

    function getAppsWeek($week_search,$current_year) {
        $result = mysql_query("SELECT * FROM apps WHERE YEAR(booked_date) = '$current_year' && WEEKOFYEAR(booked_date) = '$week_search' ");
        $num_apps = mysql_numrows($result);
        return $num_apps;
    }

    function getAppsHour($hour_search,$current_year) {
        $result = mysql_query("SELECT * FROM apps WHERE YEAR(booked_date) = '$current_year' && HOUR(booked_time) = '$hour_search' ");
        $num_apps = mysql_numrows($result);
        return $num_apps;
    }

    function getAgentJobsWeek($agent_search,$week_search,$current_year) {
        $result = mysql_query("SELECT SUM(job_value) FROM jobs WHERE YEAR(booked_date) = '$current_year' && agent_name = '$agent_search' && WEEKOFYEAR(booked_date) = '$week_search' ");
        $row = mysql_fetch_array($result);
        return $row[0];
    }

    function getAgentPointsWeek($agent_search,$week_search,$current_year) {
        $result = mysql_query("SELECT SUM(points_value) FROM jobs WHERE YEAR(booked_date) = '$current_year' && agent_name = '$agent_search' && WEEKOFYEAR(booked_date) = '$week_search' ");
        $row = mysql_fetch_array($result);
        return $row[0];
    }
?>

<div id="container">

    <div id="header">
        <img src="images/logo.jpg" align="left">
        <img src="images/logo.jpg" align="right">
        <h3>Reports - Yearly Summary 2010</h3>
    </div>

    <div align="center">
        <form class="menu">
            <input type="button" class="btn" value="Log-Out" onClick="parent.location='index.php'"> //
            <input type="button" class="btn" value="This Week/Last Week" onClick="parent.location='reporting.php'"> -
            <input type="button" class="btn" value="This Month/Last Month" onClick="parent.location='reporting_month.php'"> -
            <input type="button" class="btn" value="Yearly Summary 2011" onClick="parent.location='reporting_2011.php'"> -
            <input type="button" class="btn" value="Yearly Summary 2010" onClick="parent.location='reporting_2010.php'"> -
            <input type="button" class="btn" value="Yearly Summary 2009" onClick="parent.location='reporting_2009.php'">
        </form>
    </div>

    <div id="message">
        <?php echo $message.'Year: '.$current_year.', Number of Weeks: '.$numrows;?>
    </div>

    <div id="reports">
    <table align="center">
    <tr>
    <td valign="top">
        <p align="center">Summary of job booking times by hour</p>
        <table cellpadding=10>
            <colgroup style="width: 80px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 80px"></colgroup>

            <tr bgcolor='#ff6600' style="text-align: center; font-weight: bold">
                <td>Hour</td>
                <td>Jobs</td>
                <td>Points</td>
                <td>Apps</td>
            </tr>

<?php

    $hour = 9;
    $i = 0;
    while ($hour < 18){
        $hourresult = mysql_query("SELECT SUM(job_value), SUM(points_value) FROM jobs WHERE YEAR(booked_date) = $current_year && HOUR(booked_time) = $hour");
        $row = mysql_fetch_array($hourresult);
        $num_per_hour = mysql_numrows($hourresult);
        $i++;
?>

            <tr class="tr<?php echo ($i & 1) ?>">
                <td style="font-weight: bold;"><?php echo $hour; ?></td>
                <td><?php echo $row['SUM(job_value)'] ?></td>
                <td><?php echo $row['SUM(points_value)'] ?></td>
                <td><?php echo getAppsHour($hour,$current_year); ?></td>
            </tr>

<?php 

      $hour++;
    }
?>

        </table>
    </td>
    <td valign="top">
        <p align="center">Summary of job booking times by day</p>
        <table cellpadding=10>
            <colgroup style="width: 120px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 80px"></colgroup>

            <tr bgcolor='#ff6600' style="text-align: center; font-weight: bold">
                <td>Day</td>
                <td>Jobs</td>
                <td>Points</td>
                <td>Apps</td>
            </tr>

<?php

    $day = 2;
    $i = 0;
    while ($day < 7){
        $dayresult = mysql_query("SELECT SUM(job_value), SUM(points_value) FROM jobs WHERE YEAR(booked_date) = $current_year && DAYOFWEEK(booked_date) = $day");
        $row = mysql_fetch_array($dayresult);
        $num_per_hour = mysql_numrows($dayresult);
        $i++;
?>

            <tr class="tr<?php echo ($i & 1) ?>">
                <td style="font-weight: bold;"><?php echo $days[$day] ?></td>
                <td><?php echo $row['SUM(job_value)'] ?></td>
                <td><?php echo $row['SUM(points_value)'] ?></td>
                <td><?php echo getAppsDayNumber($day,$current_year); ?></td>
            </tr>
<?php

    $day++;
    }
?>

        </table>
    </td>
    <td valign="top">
        <p align="center">Summary of weekly results</p>
        <table cellpadding=10>
            <colgroup style="width: 80px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 80px"></colgroup>

            <tr bgcolor='#ff6600' style="text-align: center; font-weight: bold">
                <td>Week</td>
                <td>Starting</td>
                <td>Jobs</td>
                <td>Points</td>
                <td>Apps</td>
            </tr>
<?php

    $weeklyresult = mysql_query("SELECT booked_date, SUM(job_value), SUM(points_value) FROM jobs WHERE YEAR(booked_date) = $current_year GROUP BY WEEKOFYEAR(booked_date) ORDER BY booked_date DESC");
    $i = 0;
    while ($row = mysql_fetch_array($weeklyresult)){
        $appsweek = $row['booked_date'];
        $weeknum = date('W', strtotime($appsweek));
        $starting = date('d/m/Y', strtotime($appsweek));
        $number_of_apps = getAppsWeek($weeknum,$current_year);
        $i++;
?>

            <tr class="tr<?php echo ($i & 1) ?>">
                <td style="font-weight: bold;"><?php echo $weeknum ?></td>
                <td><?php echo $starting ?></td>
                <td><?php echo $row['SUM(job_value)'] ?></td>
                <td><?php echo $row['SUM(points_value)'] ?></td>
                <td><?php echo $number_of_apps ?></td>
            </tr>
<?php

    }
?>

        </table>
    </td>
    </tr>
    </table>
    <table align="center">
    <tr>
    <td valign="top">

<?php

    $agentresult = mysql_query("SELECT DISTINCT agent_name FROM jobs WHERE YEAR(booked_date) = '$current_year' ORDER BY agent_name ASC");
    while ($row = mysql_fetch_array($agentresult)){
        $agentname = $row['agent_name'];
?>
        <p align="center"><?php echo $agentname ?></p>
        <table cellpadding=10>
            <colgroup style="width: 80px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 80px"></colgroup>

            <tr bgcolor='#ff6600' style="text-align: center; font-weight: bold">
                <td>Week</td>
                <td>Starting</td>
                <td>Jobs</td>
                <td>Points</td>
                <td>Apps</td>
            </tr>

<?php

    $agentresult2 = mysql_query("SELECT booked_date, SUM(job_value), SUM(points_value) FROM jobs WHERE YEAR(booked_date) = $current_year && agent_name = '$agentname' GROUP BY WEEKOFYEAR(booked_date) ORDER BY booked_date DESC");
    $i = 0;
    while ($row = mysql_fetch_array($agentresult2)){
        $appsweek = $row['booked_date'];
        $weeknum = date('W', strtotime($appsweek));
        $starting = date('d/m/Y', strtotime($appsweek));
        $number_of_apps = getAgentAppsWeek($agentname,$weeknum,$current_year);
        $i++;
?>

        <tr class="tr<?php echo ($i & 1) ?>">
            <td style="font-weight: bold;"><?php echo $weeknum ?></td>
            <td><?php echo $starting ?></td>
            <td><?php echo $row['SUM(job_value)'] ?></td>
            <td><?php echo $row['SUM(points_value)'] ?></td>
            <td><?php echo $number_of_apps ?></td>
        </tr>

<?php

    }
?>

        </table>

<?php

    }
?>
    </td>
    <td width="100px">
    </td>
    <td valign="top">
<?php

    $weeknumresult = mysql_query("SELECT booked_date FROM jobs WHERE YEAR(booked_date) = $current_year GROUP BY WEEKOFYEAR(booked_date) ORDER BY booked_date DESC");
    while ($row = mysql_fetch_array($weeknumresult)){
        $appsweek = $row['booked_date'];
        $weeknum = date('W', strtotime($appsweek));
?>

        <p align="center">Week No. <?php echo $weeknum; ?>, Starting: <?php echo $starting; ?></p>
        <table cellpadding=10>  
            <colgroup style="width: 120px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 80px"></colgroup>

            <tr bgcolor='#ff6600' style="text-align: center; font-weight: bold">
                <td>Day</td>
                <td>Jobs</td>
                <td>Points</td>
                <td>Apps</td>
            </tr>

<?php

    $weeknumresult2 = mysql_query("SELECT booked_date, SUM(job_value), SUM(points_value) FROM jobs WHERE YEAR(booked_date) = $current_year && WEEKOFYEAR(booked_date) = $weeknum GROUP BY booked_date ORDER BY booked_date ASC");
    $i = 0;
    while ($row = mysql_fetch_array($weeknumresult2)){
        $number_of_apps = getAppsDay($row['booked_date'],$current_year);
        $i++;
?>

            <tr class="tr<?php echo ($i & 1) ?>"> 
                <td style="font-weight: bold;"><?php echo date('l', strtotime($row['booked_date'])) ?></td>
                <td><?php echo $row['SUM(job_value)'] ?></td>
                <td><?php echo $row['SUM(points_value)'] ?></td>
                <td><?php echo $number_of_apps ?></td>
            </tr>

<?php

    }

    $weeknumresult3 = mysql_query("SELECT SUM(job_value), SUM(points_value) FROM jobs WHERE YEAR(booked_date) = $current_year && WEEKOFYEAR(booked_date) = $weeknum");
    $row = mysql_fetch_array($weeknumresult3);
    $number_of_apps = getAppsWeek($weeknum,$current_year);
?>

            <tr bgcolor='#ff6600' style="text-align: center; font-weight: bold">
                <td>Total</td>
                <td><?php echo $row['SUM(job_value)']; ?></td>
                <td><?php echo $row['SUM(points_value)']; ?></td>
                <td><?php echo $number_of_apps; ?></td>
            </tr>
        </table>
        <br/>
        <table cellpadding=10>
            <colgroup style="width: 120px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 100px"></colgroup>
            <colgroup style="width: 80px"></colgroup>

            <tr bgcolor='#ff6600' style="text-align: center; font-weight: bold">
                <td>Agent</td>
                <td>Jobs</td>
                <td>Points</td>
                <td>Apps</td>
            </tr>

<?php

    $agentsquery = ("
    CREATE TEMPORARY TABLE LeaderBoard (
        `agent_name` varchar(20) NOT NULL,
        `job_number` int(5) NOT NULL,
        `job_value` decimal(3,1) NOT NULL,
        `points_value` decimal(8,2) NOT NULL
    );
    INSERT INTO LeaderBoard (`agent_name`, `job_number`, `job_value`, `points_value`) SELECT agent_name, job_number, job_value, points_value FROM jobs WHERE YEAR(booked_date) = $current_year && WEEKOFYEAR(booked_date) = $weeknum;
    INSERT INTO LeaderBoard (`agent_name`) SELECT DISTINCT agent_name FROM apps WHERE YEAR(booked_date) = $current_year && WEEKOFYEAR(booked_date) = $weeknum;
    SELECT agent_name, SUM(job_value), SUM(points_value) FROM leaderboard GROUP BY agent_name ORDER BY SUM(points_value) DESC
    ");
    $i = 0;
    while ($row = mysql_fetch_array($agentsquery)){
        $number_of_apps = getAgentAppsWeek($row['agent_name'],$weeknum,$current_year);
        $i++;
?>

            <tr class="tr<?php echo ($i & 1) ?>">
                <td style="font-weight: bold;"><?php echo $row['agent_name'] ?></td>
                <td><?php echo $row['SUM(job_value)'] ?></td>
                <td><?php echo $row['SUM(points_value)'] ?></td>
                <td><?php echo $number_of_apps; ?></td>
            </tr>

<?php

    }
?>

        </table>

<?php

    }

    mysql_close($con);
?>

    </td>
    </tr>
    </table>
    </div>
</div>
<br/>
</body>
</html>

0 Cevap