SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2009
    0 Post(s)
    0 Thread(s)

    mysql_select_db disabling ads

    $db = mysql_select_db ("thukme_ca",$connection) or die ("Cannot connect to database");
    Seems like the line above disables the ads on my page. When I remove it, the ads show. Anyone know why this could be happening?

    Here is the complete code

    $connection = mysql_connect ("localhost","thuMN", "")or die ("Cannot make the connection");
    $db = mysql_select_db ("tha",$connection) or die ("Cannot connect to database");
    $sql_query = "SELECT * FROM aa_abm1 ORDER BY RAND() LIMIT 14";
    $result = mysql_query($sql_query);
    while($row = mysql_fetch_row($result))
    echo ("<div style=\"float:left; font-size:.8em; font-weight:bold; height:60px; line-height:1.4em; padding:6px 2px 28px 2px; text-align:center; width:70px; \"> <a href=\"$row[9]\" target=\"_blank\"><img src=\"$row[4]\" alt=\"$row[2]\" width=\"70\" height=\"60\" border=\"2\" /></a>
    <p><a href=\"$row[9]\" target=\"_blank\">$row[2]</a></p>
    </div>") ;
    echo "no values in the database";
    AllTopExchange - Banner Ad Network
    40,000+ Free Impressions When You Join.

    TrinityClicks Best GPT Site EVER! Join Now!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    West Springfield, Massachusetts
    194 Post(s)
    2 Thread(s)
    That doesn't disable ads, it die('message_output')s most likely mucking things up.

    I know a lot of code examples show die(), but that's really for learning/developing. IMHO the best way would be to use custom error/exception handling, though it might be easier to put that block of code inside a function and not return anything if it fails. Or you could go hackish and simply remove the die()s and suppress errors.

    It depends on how crucial that block of code is to the rest of the page.

    You should ultimately figure out why your db cnx is failing, but even then they do still fail from time to time anyway.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts