Re: Warning messages on web page.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    Hold everything, Mike!

On Wed, Jun 23, 2010 at 05:18, Mike Davies <mike@xxxxxxxxxxxxxxxxxxxxxx> wrote:
[snip!]
>
> <?php
> mysql_select_db($database_general, $general);
> $query_details = "SELECT * FROM news WHERE news_id = '$_GET[id]'";

    /**
     *  Above line is placed here so that we can be easily,
     *  deliberately, and permanently destroyed.  Of course,
     *  I suppose we *could* avoid that by sanitizing the input.
     *  Perhaps mysql_real_escape_string() or something....
     */

> $details = mysql_query($query_details, $general) or die(mysql_error());
> $row_details = mysql_fetch_assoc($details);
> $totalRows_details = mysql_num_rows($details);
>
> mysql_select_db($database_general, $general);

    // You don't need to reconnect to the database between queries.
    // Since you're using the same here as above, the same link is fine.

> $query_thumbs = "SELECT * FROM news_thumbs";
> $thumbs = mysql_query($query_thumbs, $general) or die(mysql_error());

    // You don't need to tell mysql_query() which database to use every time
    // either, when using the same database for queries.

> $totalRows_thumbs = mysql_num_rows($thumbs);

    // Doesn't look like you use this --- at least in this code
snippet.  Necessary?

> $i = 1;

    // I'd lose the above line as well.  You'll see why in a second....

/** REPLACE THIS:
> while ($row_thumbs = mysql_fetch_assoc($thumbs)){
> $thumbsarray[$i] = $row_thumbs;
> $i++;
> }
**/

// WITH THIS:
while($row_thumbs = mysql_fetch_assoc($thumbs)) {
    $thumbsarray[] = $row_thumbs;
}

> //print_r($thumbsarray);
> ?>


> This is exactly the same as the code which is working for the 'projects'
> pages.

    Okay.  On the database to which you're connecting, use phpMyAdmin,
the MySQL CLI, or something other than this and run the following
query:

        SELECT * FROM news_thumbs;

    Is anything returned?

-- 
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx
http://www.parasane.net/ || http://www.pilotpig.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux