Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   PHP (http://www.flasher.ru/forum/forumdisplay.php?f=20)
-   -   Random Quote Error (http://www.flasher.ru/forum/showthread.php?t=39913)

Tagore 22.11.2002 02:12

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)){ 


ihorko 22.11.2002 12:10

Код:

if ($number_reached >($no_of_quotes - 1)){
попробуй так:

Код:

$myVar = $no_of_quotes - 1;
if ($number_reached>$myVar) { ...

смешно, но иногда помогает. я абсолютно серьезно


Часовой пояс GMT +4, время: 03:58.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.