Hello,

For some reason, whenevr I try and access the database contents, it turns up
empty. What I do is randomly select an ID (the lowest being 1 and the
highest being however many IDs are in the database [this section of
accessing the database works]). After I select the ID, I get an ad according
to the ID the script randomly chose. For this particular site I'm working
on, the ID is always 6 which I want it to be. The problem lies in getting th
einformation from the database according to this ID. There is an entry with
the ID of 6, but for some reason I variables are empty.

The real twist is that sometimes it works (it automatically refreshes every
45 seconds to get a new random ad) and sometimes the variables are empty.
Can anyone tell me how to fix this? Here's the code I use to asign the
variables with the database contents:

 srand ((double) microtime() * 1000000);
 $rand = rand(1,$id);
 $sql = "select * from ads where id='$rand' and zone='".$zone."'";
 $result = mysql_query($sql, $conn);
 if(!$result)
 {
  echo "Unable to get ad information";
  exit;
 }
  $row = mysql_fetch_assoc($result);
  $id = stripslashes($row["id"]);
  $new = stripslashes($row["impressions"]);
  $new += 1;
  $sql_one = "UPDATE ads SET impressions='$new' WHERE id='$id'";
  @mysql_query($sql_one, $conn);
  $type = stripslashes($row["type"]);
  $text = stripslashes($row["text"]);
  $url2 = stripslashes($row["url"]);
  $target = stripslashes($row["target"]);
  $bar = stripslashes($row["bar"]);
  $cpc = stripslashes($row["cpc"]);
  $zone = stripslashes($row["zone"]);

Thanks,
Stephen Craton
http://www.melchior.us


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

Reply via email to