Forum Moderators: coopster
I've been trying things for weeks now, searched thoroughly in google many times but can not find the answer. Here is the script:
// Check to see if the banner ID flag is set
if(isset($_bannerID)) {
// Create an instance of the Database Layer
$DB = new DB_BANNER;
// Get info about banner from DB
$DB->query("SELECT * FROM banner
WHERE(uniqueid=$_bannerID)");
// Check to see if Banner ID is valid before doing
// anything else
if($DB->num_rows()!= 0) {
// Increment Click Counter
dbIncClks($_bannerID);
// Redirect user to new location, $_query_extra
// is the Extra parameters that were given to the
// script back in dbShowBan(). This feature is
// for if you want a banner on your own site, to
// your own site, but use sessions and don't want
// the user to lose their session when they
// click.
$url = $DB->f("URL"). $_query_extra;
Header("Location: $url");
}
}
function Display_Banner($bannerID = "none",
$query_extra = "") {
// Grab the Database Layer and the Config options
global $DB, $_bannercfg, $PHP_SELF;
// Did we pass a BannerID?
if($bannerID == "none") {
// If Not, Grab the next in rotation
// First, make sure that there is something to select
$DB->query("SELECT * FROM banner WHERE pos=''
LIMIT 1"); /* L I N E 8 2*/
// If there is nothing, then everything has
// been displayed
// Time to start from square 1
if($DB->num_rows() == 0) {
$DB->query("UPDATE banner SET pos='' WHERE(pos='A')");
}
// Finally, select the next banner
$DB->query("SELECT * FROM banner WHERE(pos='')
ORDER BY b_order LIMIT 1");
} else {
// If so, Grab the requested Banner
$DB->query("SELECT * FROM banner
WHERE(ID='$bannerID')");
}
// Make sure we grabbed something
if($DB->num_rows() == 0) {
return false;
}
$DB->next_record();
// Saved the data we got in a separate array
$ban_data = $DB->Record;
// Construct the HTML for the GET
$get = "?_bannerid=".urlencode($ban_data['ID']);
// Make the extra query string
if(is_array($query_extra)) {
foreach($query_extra as $key => $val) {
$get .= "&$key=".urlencode($val);
}
}
// Construct the HTML for the banner and include the GET // we constructed previously.
$html = "<a href='$PHP_SELF$get' target=\"_blank\">"
. "<img src='$_bannercfg[srcpath]$ban_data[SRC]' "
. "alt='$ban_data[ALT] "
. "border='$_bannercfg[border]'>"
. "</A>";
// Increment the hits
dbIncHits($ban_data['ID']);
// Flag the banner used as displayed (if it was selected
// by rotation) In special cases, we're not going to flag
// anything
if($bannerID == "none") {
$DB->query("UPDATE banner SET pos='A'
WHERE(ID='".$ban_data['ID']."')");
}
// Finally, echo the HTML
echo $html;
// Return True
return true;
}
function dbIncClks($_bannerID) {
global $DB;
$DB->query("SELECT clicks FROM banner
WHERE(ID='$_bannerID')");
if($DB->num_rows() == 0) {
return false;
}
$DB->query("UPDATE banner SET clicks=".($DB->f('clicks')+1)." WHERE(ID='$_bannerID')");
}
function dbIncHits($_bannerID) {
global $DB;
$DB->query("SELECT hits FROM banner
WHERE(ID='$_bannerID')");
if($DB->num_rows() == 0) {
return false;
}
$DB->query("UPDATE banner SET hits=".($DB->f('clicks')+1)." WHERE(ID='$_bannerID')");
}
And I get the following area:
Fatal error: Call to a member function on a non-object in /home/.../public_html/adrotator.php on line 82
On the page I want it to display I am including this file and using:
display_banner();
Thanks.
[edit]
Try this instead:
$DB->display_banner();
Fatal error: Call to a member function on a non-object in /home/graphics/public_html/header.php on line 57
Code:
<? include('adrotator.php');
$DB->display_banner(); ----------Line 57
?>
On the first post I just wrote Line 82 next to line 82 (probably a bit hard to find) So this is it:
$DB->query("SELECT * FROM banner WHERE pos=''
LIMIT 1");
auto_prepend_file adrotator.php
Hopefully theres an error in the way I've done that there because I'm still getting the same message. So hopefully someone can tell me if I've done that right.
Thanks for everyones help so far.
“PHP is presently the most popular scripting language in use on the Internet”
But you could access it via your server
<edit>
If you do not know how to do it, you should not try without asking if you are in the right direction.
First make a backup of the php.ini.
</edit>
If you are in a shared server environment you are probably not entitled to such access and modification.
You will need to contact your host and ask them about.
The bit about .htaccess is probably linked to the same alteration that might be performed out of .htaccess
thus not requiring you to edit the PHP.INI
The first time I opened it up, edited and saved as .htaccess from notepad. This saved it has .htaccess.txt so in the FTP I just took out the .txt. extension, however that messed up somthing. I kept getting a 403 Access Forbidden Error which I could not get rid of.
After contacting my provider it was fixed, but when I tried to add password protection again it did the same thing. Again I contacted them and they fixed another problem and it works fine now.
So before I try it again I thought I should ask. :)
comments in .htaccess are done like this
####my comments aaaa bbbb ##########
respect any previous provider addition, they help running your sector.
and now give it a try.
do you hace the correct path handy?
php_value auto_prepend_file "/your path/your file"
Edit:
I edited it properly and uploaded, this being the full file:
AuthType Basic
AuthName "Site Construction"
AuthUserFile "/home/graphics/.htpasswds/passwd"
require valid-user
auto_prepend_file adrotator.php
and got the following error:
500 server error
I encountered an unrecoverable server error. Please go back and try again.
[edited by: Jeigh at 12:52 am (utc) on July 9, 2007]
"Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/graphics/public_html/adrotator.php:207) in /home/graphics/public_html/header.php on line 1"
header.php line 1:
<? session_start();
and line 207 on adrotator.php is:
?>
without looking at the whole thing it will not be easy to find what causes it
you could resolve the problem by turning OB On (output buffering)
but since it seems that you may not modif php.ini you might ask you ISP to turn on OB
OR
add a new line in .htaccess
php_value output_buffering On