Тема: Random Quote Error
Показать сообщение отдельно
Старый 22.11.2002, 09:50     # 1
GodFather
Guest
 
Сообщения: n/a

Question Random Quote Error

PHP код:
<? $con = mysql_connect($DB_SERVER, $DB_USER, $DB_PASS);
    mysql_select_db($DB_NAME);

    $getNoOfQuotesQuery = mysql_query("select count(*) from quotes", $con);
    $no_of_quotes = mysql_result($getNoOfQuotesQuery,0);
    
    $getMetaDataQuery = mysql_query("SELECT * FROM quotes_meta", $con);
    $row = mysql_fetch_row($getMetaDataQuery); 
    $number_reached = $row[1];
    $date_modified= $row[2];
    
    // get the current day of the month (from 1 to 31)
    $day_today = date("j");    
    if ($date_modified != $day_today){
        // we have reached the end of the quotes
        if ($number_reached >($no_of_quotes - 1)){
            $number_reached = 1;
            $query3 = mysql_query('UPDATE quotes_meta SET date_modified = "'.$day_today.'", number_reached = "'.$number_reached.'"', $con);
            mysql_query($query3,$con);
        } else {
        // we haven't reached the end of the quotes
        // therefore we increment $number_reached
        $number_reached = $number_reached + 1;
        $query3 = mysql_query('UPDATE quotes_meta SET date_modified = "'.$day_today.'", number_reached = "'.$number_reached.'"', $con);
        mysql_query($query3,$con);
        }
    }    
?>
    </head>
    <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
        <p>
            &nbsp;</p>
        <table align="center" cellpadding="0" cellspacing="0" width="300" height="70">
            <tr>
                <td width="28" valign="top" rowspan="2">
                    <p>
                        <img src="../img/openquote.gif" width="26" height="20" border="0">
                    </p>
                </td>
                <td width="232">
                    <p class="articlebig"><b>
                    <?
// we get the quote with 'id = $number_reached' from the database
    $getQuoteQuery = mysql_query("SELECT quote,author FROM quotes WHERE id = ".$number_reached, $con);
    $row = mysql_fetch_row($getQuoteQuery);    
    echo $row[0];
?>        
                    </p></b>
                </td>
                <td width="6" align="right" valign="bottom" rowspan="2">
                    <p style="margin-bottom: 7px;">
                        <img src="../img/closequote.gif" width="25" height="20" border="0">
                    </p>
                </td>
            </tr>
            <tr>
                <td width="232" height="20" ><br>
                <div align="right">
                    <p class="articlebig" align="right"><b><i>--
<?   echo $row[1]; 
    mysql_close($con); ?> 
     &nbsp;&nbsp;&nbsp;</i></b></p>        
    </div>
                </td>
            </tr>
        </table>
        <p>
            &nbsp;
        </p>
    </body>
</html>
В этом месте код преривается и перестает работает. Что там не так - так однажди даже заработал, но чо то всеравно тут не то. Это типа ... цитата дня.
PHP код:
        if ($number_reached >($no_of_quotes 1)){