View Full Version : Somewhat Urgent - Header Problems
JimF
Thu 10th Aug '00, 5:25pm
Here's the deal. I found out that I've been doing my ads all wrong on my entire site - I've been losing about 6,000 impressions daily for abuot 3 months due to my stupidity. Anyway, I've talked to the techs at my ad broker - I got a cool little javascript that gives the banner a different number every time.
I initially tried putting it in the fivelinks template - it didn't work. After much messing around, I finally got it working as a php-parsed header. I do a include() to the .txt file. I had it working - and beautifully, I might add - until I tried the "Go To First New Post" or "Go To Last Post" feature from forumdisplay.php. Then I get this nasty error:
Warning: Cannot add more header information - the header was already sent (header information may be added only before any output is generated from the script - check for text or whitespace outside PHP tags, or calls to functions that output text) in /usr/etc/public_html/forums/showthread.php on line 37
And Also
Warning: Cannot add more header information - the header was already sent (header information may be added only before any output is generated from the script - check for text or whitespace outside PHP tags, or calls to functions that output text) in /usr/etc/public_html/forums/showthread.php on line 27
And then the same thing, but with line 19 when accessed from forumhome.
I looked at the code but I'm not *that* far into knowing php to know what it was doing.
Any help would be very, very appreciated. :D
Thanks
-jim
doron
Thu 10th Aug '00, 6:21pm
what sort of ad script? javascript and html? What ad service? I put mine in the general header without any parsing from burstnet and flycast...
JimF
Thu 10th Aug '00, 6:43pm
Thanks for your reply :D
It's a javascript from Advertising.com; it doesn't seem like it should be causing so many problems. Here it is:
<!-- ---------- Advertising.com Banner Code -------------- -->
<SCRIPT LANGUAGE=JavaScript>
var bnum=new Number(Math.floor(99999999 * Math.random())+1);
document.write("<A HREF=http://servedby.advertising.com/click/site=5925/bnum=" +
bnum + " target=_blank><IMG SRC=http://servedby.advertising.com/site=5925/bnum="
+ bnum + "/bins=1/rich=0 border=0 alt=\"Click to learn more...\"></A>");
</SCRIPT>
<!-- ---------- Advertising.com Banner Code -------------- -->
It wouldn't work as is - I kept getting parse errors. I read some posts on these forums, and it seems that many people have had problems putting JS into the headers. That's when I decided to go with the php route. It wouldn't even work as straight javascript if I had stuck it right in the middle of the template.
It seems very strange to me.
FYI, I've disabled the go to new/last features on my board so as to avoid many angry emails and posts. If anybody would need it to trouble shoot, let me know and I'll uncomment out the code.
-jim
Thanks again doron :D
doron
Fri 11th Aug '00, 2:11am
did you insert it into the Change Styles | Header section and turn off php parsing? Are you getting javascript errors or erros from the vB?
JimF
Fri 11th Aug '00, 7:51pm
Yes, I put it into the Header section - but it is PHP, so I had to turn the "parse header code as php" funtion on. Otherwise it just printed out my code at the top of the page.
The warning message appears on the screen - similar as to how a "Parse Error" message appears. It will load the banner, and then this message will appear right after it - nothing else on the page will load.
Here is a link to see what for yourself what is going on:
http://www.bronx-bombers.com/testforum/showthread.php?goto=newpost&threadid=2199
Thanks again doron :D - I appreciate your help, and I apologize that you seem to be the only one that is willing to help.
I guess it's silly for someone who, when it comes to being a helper or a helpee, has a post ratio of about 25 to 1 to expect any help from the community - and I thank you for your time.
Let me know if there is any more info you need - I could even grant you admin access if you register on my test forum - so that you can play around with things, and see what I was experiencing first hand.
-jim
Thanks again :)
Freddie Bingham
Fri 11th Aug '00, 8:36pm
Did you follow this rule:
Parse header as PHP code. In this case, the header variable must be specifically set in the header template. An example would be this:
//--Start header template--
$header = "<p>This is an advert</p>";
//--End header template
Paste what you have set as your header. It seems to me that you must set the $header variable.
i.e.
$header = "Your javascript , and etc code";
no?
JimF
Fri 11th Aug '00, 8:53pm
It didn't work when it was set as $header - I tried that a dozen times, a dozen different ways. Right now all I have is include("myfile"); - and it works on all the other pages. It is only when using the blue arrows from forumdisplay or the index page that this error happens. If what I did was wrong, how come it works on all the other pages properly?
Is there a script that gets used for every page - like global.php that I could insert my code into - to have it hardcoded into every page?
Thanks for your reply, rangersfan :D
-jim
bira
Fri 11th Aug '00, 9:02pm
Hi JimF,
I had a similar code and had no problem with including it in the header WITHOUT parsing as PHP. What happens if you choose NOT to parse the header as PHP, and paste that javascript code in the header?
Another way to go about it - though a bit annoying and a lot of work - is to add this code in all the pages' templates.
As for why the include doesn't work with the blue arrow - sorry, no idea. Sounds very odd.
Freddie Bingham
Fri 11th Aug '00, 9:19pm
You could put it at the bottom of global.php and it would appear at the top of every page.
JimF
Fri 11th Aug '00, 9:25pm
bira,
as explained in my initial post, it didn't work when I put it straight in my templates. I kept getting parse errors. That was why I had to go to php in the header to begin with. But I appreciate your reply :D.
rangersfan,
that would work perfectly - I just insert it into the bottom anywhere? Thanks :)
-jim
Freddie Bingham
Fri 11th Aug '00, 9:29pm
yes just put it before the ?> at the bottom
You will need to "echo" it, just don't paste it in
i.e.
echo ("<--- Java Start --->");
etc
etc
[Edited by rangersfan on 08-11-2000 at 08:30 PM]
JimF
Fri 11th Aug '00, 9:51pm
Hrm, it's still not working. I used the straight JS code, and I also used the include - but neither worked. Looking at the source of the pages, it appears as if it is appearing before the <html> tags - which would explain the header problems. I just wish I knew why this happened only on certain screens. That's the most frustrating.
-jim
Thanks again :D
Susan
Sat 12th Aug '00, 3:18am
Jim, we had the same problems with ad.com banners. What finally worked for us was putting the following in the header/footer box in the control panel (no parsing as Php needed): <!-- ---------- Advertising.com Banner Code -------------- -->
<SCRIPT LANGUAGE=JavaScript><!--
var bnum=new Number(Math.floor(99999999 * Math.random())+1);
document.write("<SCRIPT LANGUAGE='Javascript' SRC='http://servedby.advertising.com/site=6034/bnum="+bnum+"'><\/SCRIPT>");
// --></SCRIPT> <NOSCRIPT> </FONT><A HREF="http://servedby.advertising.com/click/site=6034/bnum=39405464" TARGET="_top"><FONT COLOR="#9966FF">
<IMG SRC="http://servedby.advertising.com/site=6034/bnum=39405464/bins=1/rich=0" ALT="Click to learn more..." BORDER=0 ALIGN=bottom></FONT></A><FONT COLOR="#9966FF">
</NOSCRIPT> <!-- ---------- Copyright 2000, Advertising.com ---------- -->
It's been counting accurately ever since.
Hope this helps,
Susan
eva2000
Sat 12th Aug '00, 5:39am
Originally posted by Susan
Jim, we had the same problems with ad.com banners. What finally worked for us was putting the following in the header/footer box in the control panel (no parsing as Php needed): <!-- ---------- Advertising.com Banner Code -------------- -->
<SCRIPT LANGUAGE=JavaScript><!--
var bnum=new Number(Math.floor(99999999 * Math.random())+1);
document.write("<SCRIPT LANGUAGE='Javascript' SRC='http://servedby.advertising.com/site=6034/bnum="+bnum+"'><\/SCRIPT>");
// --></SCRIPT> <NOSCRIPT> </FONT><A HREF="http://servedby.advertising.com/click/site=6034/bnum=39405464" TARGET="_top"><FONT COLOR="#9966FF">
<IMG SRC="http://servedby.advertising.com/site=6034/bnum=39405464/bins=1/rich=0" ALT="Click to learn more..." BORDER=0 ALIGN=bottom></FONT></A><FONT COLOR="#9966FF">
</NOSCRIPT> <!-- ---------- Copyright 2000, Advertising.com ---------- -->
It's been counting accurately ever since.
Hope this helps,
Susan i ran advertising.com ads too from nickelaclick on my forums a few weeks back and put them in the header template as well.... no problems now i just run linkexchange ads in the header
Sharg
Sat 12th Aug '00, 12:32pm
Got same kind of problem and it turns me mad.
Here is the code my adgency provided me:
<script language="javascript">
var a=Math.round(Math.random()*9999999999);
var b="<a href=\"http://www.domain.com/cgi-bin/c.cgi?000110="+a+"\"><img src=\"http://www.domain.com/cgi-bin/a.cgi?000110="+a+"\" width=468 height=60 border=0></a>";
document.write(b);
</script>
I contacted them and they replied that I should try this code that is specificaly FOR php:
print"<script language=\"javascript\">";
print"var a=Math.round(Math.random()*9999999999);";
print"var b=\"<a href=\\\"http://www.domain.com/cgi-bin/c.cgi?000110=\"+a+\"\\\"><img src=\\\"http://www.domain.com/cgi-bin/a.cgi?000110=\"+a+\"\\\" width=468 height=60 border=0></a>\";";
print"document.write(b);";
print"</script>";
But got the same error: parse error. When I turn on the
"useadvheader" I got another parse error affecting another Vb script.
I have no solution, and I really need help or I'm afraid I'll have problem with my advertising company.
I cannot put the code right in the script, because I have different header for each forums.
Why the hell is it so difficult just to include a damn code in the header, why doesn't it just print it and let the browser play with it ?
please help, thanks,
Benj
JimF
Sat 12th Aug '00, 9:18pm
Susan, you are my new hero!! That worked beautifully! :) Except you have a few of my p/v's because I forgot to change the site# initially :o.
I was growing increasingly frustrated because I found out it was happening when the user logged in as well - But now it works perfectly. I owe you big time.
When I saw the amount of my impressions almost triple, I would of rather had a faulty login system and lack of ability to jump to new posts than make less money - but you have enabled me to have both. Many, many thanks to you :D.
-jim
Mike Sullivan
Sat 12th Aug '00, 11:08pm
FYI, it's probably easier (and maybe even better) to just generate the random number with PHP...
Actually, this won't be random - it is quite systematic, but it will always be getting larger.
For example, turn on PHP parsing in your header, and do something similar to this...
$header = "<a href=\"www.where-ever.com\"><img src=\"http://www.where-ever.com/ad.gif?blahblah=".time()."\" border=0></a>"
Notice the 'blahblah=".time()."' part
Should work, but I'm not up with the ad agencies :)
Sharg
Sun 13th Aug '00, 10:00am
I don't understand how I should place the $header = "Header html + ad code " with php parsing on ?!
Should I put it in my header template, so lets say in headercustom template I created, I only have to put $header = "Header HTML + ad code" ?
Thanks,
Benj
Mike Sullivan
Sun 13th Aug '00, 1:05pm
Yep, but actually I made a typo. It should be:
$header = "All your header code with quotes escaped: \". More header code";I just missed the ;
Make sure you escape your quotes like I mentioned though.
Sharg
Sun 13th Aug '00, 7:45pm
Ok and, thanks for your answer here is the code i've put in my test forum's header:
$header = "print"<script language=\"javascript\">";
print"var a=Math.round(Math.random()*9999999999);";
print"var b=\"<a href=\\\"http://www.myaddomain.com/cgi-bin/c.cgi?0002110=\"+a+\"\\\"><img src=\\\"http://www.myaddomain.com/cgi-bin/a.cgi?0002110=\"+a+\"\\\" width=468 height=60 border=0></a>\";";
print"document.write(b);";
print"</script>";
";
It returned this error:
Parse error: parse error in /big/dom/xparlonsdetout/www/forums/forumdisplay.php on line 223
So I turned in the option useadvheader ON and got this new message:
Parse error: parse error in global.php on line 751
There is no way I can make this advertising code working.
This is really a big problem for me if I can't run advertisement on my VB.
I need a soluion please.
Thanks,
Benj
[Edited by Benj on 08-13-2000 at 06:48 PM]
bira
Sun 13th Aug '00, 9:26pm
Benj, from my limited knowledge of PHP, that code in itself is full of mistakes.
For one, the correct syntax is print("whatever");. Furthermore, you have way too many escapes ahead of a quotation mark, and in one of the lines you have ";"; at the end -- php would expect something before the second "; or it would return a parse error.
I think that I'm not talking nonesense :)
Mike Sullivan
Sun 13th Aug '00, 9:28pm
Umm... just a little off there. :)
I'm changing your code, BTW. It should be better, as it won't rely on JS.
$header = "<a href=\"http://www.myaddomain.com/cgi-bin/c.cgi?0002110=".time()."\"><img src=\"http://www.myaddomain.com/cgi-bin/a.cgi?0002110=".time()."\" width=468 height=60 border=0></a>";
bira
Sun 13th Aug '00, 9:40pm
So I was wrong, Ed?
Mike Sullivan
Sun 13th Aug '00, 10:00pm
No, you were mostly right.
The part you weren't right about was the "print" part, because you don't want to use that.
But regarding escapes and semi-colons, you were correct.
I'just rewrote the code to get rid of the JS and use PHP's time() function to keep the images fresh.
bira
Sun 13th Aug '00, 10:13pm
Originally posted by Ed Sullivan
The part you weren't right about was the "print" part, because you don't want to use that.
For my own self-educating reasons it's important for me to understand this: I thought that print (put aside for a minute whether you would want to use it or not) syntax is print(""); - I'm only interested in knowing if I got that much right :)
Mike Sullivan
Sun 13th Aug '00, 11:53pm
Well, your syntax was fine.
There are several alternatives to print:
echo and printf come to mind. But that's just a side note.
The problem was that you can't say:
$header = "print \"hello world\";";
When you call header, it will literally print this:
print "hello world";
(FYI, this may be a source of confusion. When I say $header = "...";, I mean, you put all that in your header template. not just the stuff after the =)
See, when you turn PHP parsing on, vB is forced to parse the header and footer prematurely.
So if you have print/echo statements in there, they'll get printed out before the <html>.
Instead of printing the stuff out, you asign all the output to $header, as that variable is still used by vB.
Understand?
Basically, you don't want to print anything out directly when you turn PHP parsing on. Try turning it on with your footer, and printing stuff out - you'll see what I mean.
bira
Mon 14th Aug '00, 8:23am
ok, I understand. Thanks :)
Sharg
Mon 14th Aug '00, 8:52am
Thanks Ed.
So what I did is erease all my header and copy past your code in it:
$header = "<a href=\"http://www.myaddomain.com/cgi-bin/c.cgi?0002110=".time()."\"><img src=\"http://www.myaddomain.com/cgi-bin/a.cgi?0002110=".time()."\" width=468 height=60 border=0></a>";
But got the exact same parse error I had with the previous code :(
Do you have any other solution please ?
Thanks
Benj
Mike Sullivan
Mon 14th Aug '00, 1:32pm
Dunno.
$header = '<a href="http://www.myaddomain.com/cgi-bin/c.cgi?0002110='.time().'"><img src="http://www.myaddomain.com/cgi-bin/a.cgi?0002110='.time().'" width=468 height=60 border=0></a>';?????????????????????
JimF
Mon 14th Aug '00, 1:50pm
You wanna know what I love about this program? The ability to go back and edit the original topic so that I can turn off email notification :D
-jim
Sharg
Mon 14th Aug '00, 4:18pm
?????????????????????
Ed, there is a lot of progress. I DON'T get anymore the damn parse error message !!
But now I get some weird stuff: The add don't display. I can see the 468x68 broken image, and when I put my mouse over I see that the link is: http://www.mysite.com"http://www.theaddagency.com+code
Which of course is invalid.
Think you can tweak it ?
Thanks,
Benj
eva2000
Mon 14th Aug '00, 5:01pm
Originally posted by JimF
You wanna know what I love about this program? The ability to go back and edit the original topic so that I can turn off email notification :D
-jim yeah great feature... but how many members of other vbs know of it's existence :(
Mike Sullivan
Mon 14th Aug '00, 7:44pm
Ben -
I need you to paste 2 things here for me.
1. Your header, grabbed via CP
2. Your header, grabbed via view source on a page where it's included.
Thanks.
Sharg
Mon 14th Aug '00, 8:20pm
Code on my custom header (several forums have their own header, and its the case with this) from CP:
$header = '<a href="http://www.domain.com/cgi-bin/c.cgi?000110='.time().'"><img src="http://www.domain.com/cgi-bin/a.cgi?000110='.time().'" width=468 height=60 border=0></a>';
Code on the page:
<a href=\"http://www.domain.com/cgi-bin/c.cgi?000110=966294556\"><img src=\"http://www.domain.com/cgi-bin/a.cgi?000110=966294556\" width=468 height=60 border=0></a>
I modified the domain, because I don't know if the add agency would want to see their name published.
Benj
Mike Sullivan
Mon 14th Aug '00, 8:34pm
Umm... you got some magic quote problems, which would explain the parse errors.
You need to talk to your host to either turn off magic quotes in php.ini or let them be set at runtime.
I think - do you have any other problems in the forum with " coming up as \" ????
Sharg
Mon 14th Aug '00, 8:46pm
I have absolutely no problem with VB. Everything runs fine, exept this.
I'll drop a word to my host and see what they say.
Thanks,
Benj
Mike Sullivan
Mon 14th Aug '00, 9:20pm
That's really really weird.
I'm not really sure what to do.
But I'd like to try one last thing.
In global.php, find:
eval(gettemplate("header",0));
Replace with:
eval(gettemplate("header"));
I think that may make things worse, but it's worth a shot...
If that doesn't work, lets try this line:
eval(stripslashes(gettemplate("header",0)));
Or finally:
eval(stripslashes(gettemplate("header")));
Hehe. Please try those 3. If none of them work, go back to the original. :D
Sharg
Tue 15th Aug '00, 10:21am
Ed, I contacted my host, and they told me how do disable magic quote.
I will try to disable it before trying your last suggestions, but I wish to know, If i have no problem with my board (except for the advertising code) and if I disable magic quote, is there a chance it will mess up the entire board ?
Thanks,
Benj
Mike Sullivan
Tue 15th Aug '00, 2:17pm
I don't think so - because you don't want magic quotes on... but if it does, just re-enable them.
Sharg
Tue 15th Aug '00, 4:06pm
Well it did... I turned magic quote off and it ruined the entire board: internal server error on the index page.. :(
I don't think the problem comes from magic quotes: if it was the case, the script wouldn' be able to run with it turned on...
Maybe John will be able to help more. I'm waiting for him. (Support didn't answered to my email about this).
Benj
redranger
Thu 17th Aug '00, 8:59am
You've probably got a syntax error in your .htaccess file, which would explain the Internal Server Errors. If you've got PHP4 installed, the syntax of the options has changed, although I don't know them offhand, sorry :|
--red
Sharg
Thu 17th Aug '00, 9:04am
Yes, I had a syntax error.... but I corrected it.
Didn't get anymore the internal error... but it didn't resolved the problem: sill the parse error with the advertising code :(
Benj
vBulletin® v3.8.0 Beta 4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.