Thread: bannersystem

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Eindhoven, NL
    Posts
    22
    Rep Power
    0
    I wrote a small little bannersystem that displays a banner like this:

    <a href="view.php3"><img src="banner.php3"> </a>

    This seems to work perfect, but when I test it, it doesn't seem to update the database consequently. Can anyone track an error or provide another solution? It has to display the banner and keep track of the displays and clicks.

    Thanx in advance,
    Jeroen

    banner.php3

    <?php

    mysql_connect (localhost, x, x)or die ("Can't connect to SQL server !");
    mysql_select_db (x);

    $result=mysql_query("select *, bid*0+rand() as a from banner order by a limit 1");

    $row=mysql_fetch_row($result);

    $cookie = $row[0];
    setcookie("banner", $cookie);

    $views = $row[7];
    $views++;

    $data = mysql_query("UPDATE banner SET views='$views' WHERE bid='$row[0]'") or
    die ("Can't get query !");

    Header( "Location: $row[2]");

    ?>

    view.php3

    <?php

    mysql_connect (localhost, x, x)or die ("Can't connect to SQL server !");

    mysql_select_db (x);

    $result=mysql_query("select * from banner where bid='$banner'") or die ("can't get query 1");

    $row=mysql_fetch_row($result);

    $visits = $row[7];
    $visits++;

    $data = mysql_query("UPDATE banner SET visits='$visits' WHERE bid='$banner'") or
    die ("Can't get query !");

    Header( "Location: $row[3]");
    ?>
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    Progression,

    Is your bid field an integer column or something ?.If it is an integer then you have to issue a query like

    "UPDATE banner SET views='$views' WHERE bid=$row[0]"
    ie,with out single quotes.

    ---------------------

    i think rest of the things are ok!!!



    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Eindhoven, NL
    Posts
    22
    Rep Power
    0
    Yup, I think it is.

    Gonna have to try it, but strange thing is that it works sometimes and sometimes fails, or is that normal with wrong querry issues?

IMN logo majestic logo threadwatch logo seochat tools logo