38 users online (0 members and 38 guests)  

Thread: phpAds


  Results 1 to 6 of 6
  1. #1
    Enigma's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Nov 2000
    Posts
    426

    Post phpAds

    Ok, this is only the second PHP script that I've tried to install, lol.

    I'm trying to use the remote invocation method, but I'm having trouble displaying multiple banners on one page that don't repeat.

    The documentation says:

    To use multiple banners on a single page, select a unique name for each banner and assign it to the "n" argument for both "click.php3" and "phpads.php3".

    I've done that using this code:

    <a href="http://66.51.112.89/phpAds/click.php?n=first" target="_blank"><img src="http://66.51.112.89/phpAds/phpads.php?what=ezbookmarksbutton&n=first" height=31 width=88 border=0></a>
    <br>
    <a href="http://66.51.112.89/phpAds/click.php?n=second" target="_blank"><img src="http://66.51.112.89/phpAds/phpads.php?what=ezbookmarksbutton&n=second" height=31 width=88 border=0></a>
    <br>
    <a href="http://66.51.112.89/phpAds/click.php?n=third" target="_blank"><img src="http://66.51.112.89/phpAds/phpads.php?what=ezbookmarksbutton&n=third" height=31 width=88 border=0></a>
    <br>
    <a href="http://66.51.112.89/phpAds/click.php?n=fourth" target="_blank"><img src="http://66.51.112.89/phpAds/phpads.php?what=ezbookmarksbutton&n=fourth" height=31 width=88 border=0></a>
    <br>
    <a href="http://66.51.112.89/phpAds/click.php?n=fifth" target="_blank"><img src="http://66.51.112.89/phpAds/phpads.php?what=ezbookmarksbutton&n=fifth" height=31 width=88 border=0></a>

    and I'm still getting the same banner showing up more than once. I do have more than 5 banners for this keyword.

    Note: I had to change the extension from .php3 to .php because of the host I have it on. I have a sample page http://beelzebulb.com/cgi-bin/ezbookmarks/ezbookmarkads.html



  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Question

    I'm assuming that you urls are actually to scripts in your webspace. Could you post the scripts? The variables will be processed in there. Cheers.

    ------------------
    QuietDean-

  3. #3
    Enigma's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Nov 2000
    Posts
    426

    Post

    Here's click.php:

    <?

    /* $ID: click.php,v 1.2 1999/02/02 18:43:19 tobias Exp $ */
    require("config.php");

    if(isset($bannerNum) && !empty($bannerNum)) $bannerID = $bannerNum;
    if(isset($n) && is_array($banID)) $bannerID = $banID[$n];

    $res = mysql_db_query($phpAds_db, "
    SELECT
    url
    FROM
    $phpAds_tbl_banners
    WHERE
    bannerID = $bannerID
    ") or mysql_die();
    $url = mysql_result($res,0 ,0);

    if($phpAds_log_adclicks)
    {

    if($phpAds_reverse_lookup)
    {
    $host = isset($REMOTE_HOST) ? $REMOTE_HOST : @gethostbyaddr($REMOTE_ADDR);
    }
    else
    {
    $host = $REMOTE_ADDR;
    }

    // Check if host is on list of hosts to ignore

    $found=0;
    while (($found == 0) && (list ($key, $ignore_host)=each($phpAds_ignore_hosts)))
    if (eregi($ignore_host, $host)) { // host found in ignore list
    $found=1;
    }

    if ($found == 0) {
    $res = @mysql_db_query($phpAds_db, sprintf("
    INSERT %s
    INTO $phpAds_tbl_adclicks
    VALUES
    (
    '$bannerID',
    null,
    '$host'
    )
    ", $phpAds_insert_delayed ? "DELAYED": ""));
    }
    }
    Header("Location: $url");
    ?>

    and here's phpads.php:

    <?
    /* $Id: phpads.php,v 1.8 2000/03/19 18:00:02 tobias Exp $ */

    require("config.inc.php");
    require("view.inc.php");
    require("acl.inc.php");

    if (!$clientID)
    {
    $clientID=0;
    }

    mysql_pconnect($GLOBALS["phpAds_hostname"], $GLOBALS["phpAds_mysqluser"], $GLOBALS["phpAds_mysqlpassword"]);
    if (eregi("^[[:digit:]]+$", $what))
    $what = (int)$what;
    $row = get_banner($what,$clientID);

    if(!empty($row["bannerID"]))
    {
    $url = parse_url($GLOBALS["phpAds_url_prefix"]);
    SetCookie("bannerNum", $row["bannerID"], $url["path"]);
    if(isset($n)) SetCookie("banID[$n]", $row["bannerID"], $url["path"]);

    if ($row["format"] == "html")
    {
    echo $row["banner"];
    log_adview($row["bannerID"]);
    }
    else
    {
    if($row["format"] == "url") // bkl
    {
    Header( "Location: $row[banner]");
    log_adview($row["bannerID"]);
    }
    else
    {
    Header( "Content-type: image/$row[format]; name=".microtime());
    echo $row["banner"];
    log_adview($row["bannerID"]);
    }
    }
    }
    else
    {
    Header( "Content-type: image/$row[format]");
    echo $row["banner"];
    }
    ?>




    ------------------
    Enigma

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Post

    Looking at it, looks to be no problem with the script. I am guessing that the problem is probably in the database table.

    I'm a bit of a mySQL newbie, but if you want to dump an entire database into HTML table, use this code -

    <?php

    // This is the only info you need change

    $dbname = "database";
    $loginname = "whatever";
    $loginpass = "secret";
    $dbhost = "localhostorwhatever";

    // End change info

    echo('<html><body bgcolor="#FFFFFF">');
    echo('<font face="arial" size="+4"><center>');
    echo("Database $dbname");

    $id_link = @mysql_connect($dbhost, $loginname, $loginpass);

    $tables = mysql_list_tables($dbname, $id_link);

    $num_tables = mysql_num_rows($tables);

    // store table names in an array
    $arr_tablenames[] = '';

    // store number of fields per table(index 0,1,2..) in an array
    $arr_num_fields[] = '';
    for ($i=0; $i < $num_tables; $i++) {
    $arr_tablenames[$i] = mysql_tablename($tables, $i);
    $arr_num_fields[$i] = mysql_num_fields(mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link));
    }

    // store field names in a multidimensional array:
    // [i] == table number, [ii] == field number for that table
    for ($i=0; $i < $num_tables; $i++) {
    for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
    $result = mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link);
    $hash_field_names[$i][$ii] = mysql_field_name($result, $ii);
    }
    }

    for ($i=0; $i < $num_tables; $i++) {
    echo("<center><h2>Table $arr_tablenames[$i] </h2></center>");
    echo('<table align="center" border="0" cellpadding="2" cellspacing="0"><tr>');
    $result = mysql_db_query($dbname, "select * from $arr_tablenames[$i]", $id_link);
    for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
    echo("<th>");
    echo $hash_field_names[$i][$ii];
    echo("</th>");
    }
    echo("</tr><tr>");
    $number_of_rows = @mysql_num_rows($result);
    for ($iii = 0; $iii < $number_of_rows; $iii++) {
    $record = @mysql_fetch_row($result);
    for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) {
    echo("<td>");
    echo $record[$ii];
    echo("</td>");
    }
    echo("</tr>");
    }
    echo("</table>");
    }



    echo('</body></html>');
    ?>


    The code itself looks fine, and phpclicks seems to marry in with phpads, which would point at the database being the problem.

    Hope this helps.

    ------------------
    QuietDean-

  5. #5
    Enigma's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Nov 2000
    Posts
    426

    Post

    If I dump the database into a table, what should I look for? Keep in mind that I'm very, very new at PHP, but I have a fairly good understanding of how databases work.

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Post

    basically, you are looking for rows that have repeated themselves. Should be fairly obvious. My only worry is that because you will be dumping the entire database, it may well be huge!

    ------------------
    QuietDean-



Tags for this Thread