[PHP] Placing the Ads in PHP Pages

Chris

New Member
Messages
1,538
Reaction score
0
Points
0
For some reason, I am totally running out of time today, for pretty much everything I do, hehe... First I am going to create a simple tutorial on how to place the ads in PHP pages. Then I will look through the forums and look for other problems people are finding for ads and add that. A super tutorial!

PLACING THE ADS IN PHP PAGES

In order to use javascript is PHP pages, you have to modify it a little. You have to do all of the following:
Add echo" to the start of each javascript line
Add \n to the end of each javascript line
Add "; to the very end of each javascript line
Escape all double quotes (") by adding a backslash (\) before them

Notice how this can be very tedios to do if you have a large piece of javascript. So, I have written a very basic/easy program to automate this process. These are the ad codes to use if you want to put the ads in PHP pages:

Text Link(x10Static)
Code:
echo "<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script>\n";
echo "<script language='JavaScript' type='text/javascript'>\n";
echo "<!--\n";
echo "if (!document.phpAds_used) document.phpAds_used = ',';\n";
echo "phpAds_random = new String (Math.random());\n";
echo "phpAds_random = phpAds_random.substring(2,11);\n";
echo "document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\");\n";
echo "document.write (\"http://x10hosting.com/advert/adjs.php?n=\" + phpAds_random);\n";
echo "document.write (\"&amp;what=zone:3&amp;target=_blank\");\n";
echo "document.write (\"&amp;exclude=\" + document.phpAds_used);\n";
echo "if (document.referrer)\n";
echo "document.write (\"&amp;referer=\" + escape(document.referrer));\n";
echo "document.write (\"'><\" + \"/script>\");\n";
echo "//-->\n";
echo "</script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a915c788' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:3&amp;n=a915c788' border='0' alt=''></a></noscript>\n";
echo "\n";
echo "\n";

Medium Banner(x10Advanced)
Code:
echo "<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script>\n";
echo "<script language='JavaScript' type='text/javascript'>\n";
echo "<!--\n";
echo "if (!document.phpAds_used) document.phpAds_used = ',';\n";
echo "phpAds_random = new String (Math.random());\n";
echo "phpAds_random = phpAds_random.substring(2,11);\n";
echo "document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\");\n";
echo "document.write (\"http://x10hosting.com/advert/adjs.php?n=\" + phpAds_random);\n";
echo "document.write (\"&amp;what=zone:2&amp;target=_blank\");\n";
echo "document.write (\"&amp;exclude=\" + document.phpAds_used);\n";
echo "if (document.referrer)\n";
echo "document.write (\"&amp;referer=\" + escape(document.referrer));\n";
echo "document.write (\"'><\" + \"/script>\");\n";
echo "//-->\n";
echo "</script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a4f0eec1' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:2&amp;n=a4f0eec1' border='0' alt=''></a></noscript>\n";
echo "\n";
echo "\n";

Large Banner (x10Corporate)
Code:
echo "<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script>\n";
echo "<script language='JavaScript' type='text/javascript'>\n";
echo "<!--\n";
echo "if (!document.phpAds_used) document.phpAds_used = ',';\n";
echo "phpAds_random = new String (Math.random());\n";
echo "phpAds_random = phpAds_random.substring(2,11);\n";
echo "document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\");\n";
echo "document.write (\"http://x10hosting.com/advert/adjs.php?n=\" + phpAds_random);\n";
echo "document.write (\"&amp;what=zone:1&amp;target=_blank\");\n";
echo "document.write (\"&amp;exclude=\" + document.phpAds_used);\n";
echo "if (document.referrer)\n";
echo "document.write (\"&amp;referer=\" + escape(document.referrer));\n";
echo "document.write (\"'><\" + \"/script>\");\n";
echo "//-->\n";
echo "</script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a7fb3e9d' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:1&amp;n=a7fb3e9d' border='0' alt=''></a></noscript>\n";

In order for this to work properly, you have to include this in the php tags (<?php and ?>), in a PHP or HTML page. Although, if you are using an HTML page, just use the regular code...

I have found out how to do this by searching google and by find this page: http://www.karakas-online.de/EN-Book/javascript-php.html.

More tutorials coming soon as described above.
 
Last edited:

Tyler

Retired Staff
Messages
8,564
Reaction score
0
Points
0
Wow, Thanks for that! Unfortunatly it did not work for me, but im sure its just me im probly doing somthing wrong :) Good work!
 

Chris

New Member
Messages
1,538
Reaction score
0
Points
0
thesims2extreme said:
Wow, Thanks for that! Unfortunatly it did not work for me, but im sure its just me im probly doing somthing wrong :) Good work!
What's the problem? What page did you insert it in?
 

Tyler

Retired Staff
Messages
8,564
Reaction score
0
Points
0
I PMed you, Thanks again for your help :) its very much appreciated
 

johndoe

New Member
Messages
50
Reaction score
0
Points
0
the problem is with php nuke. Becuse the best place to place the add is on the header.html file that comes whit teh theme of cyour choise. but echo tags an javascrip tags didn't work
 

Chris

New Member
Messages
1,538
Reaction score
0
Points
0
Oh yea... I made a mistake. You use the normal tags for PHP-Nuke.
 

johndoe

New Member
Messages
50
Reaction score
0
Points
0
yes, but the problem is that i do not understand php nuke because the header is an html file, and when i put html tags like
Code:
<script></script>>
, the add don't appear.
 

Chris

New Member
Messages
1,538
Reaction score
0
Points
0
johndoe said:
yes, but the problem is that i do not understand php nuke because the header is an html file, and when i put html tags like
Code:
<script></script>>
, the add don't appear.

Are you putting the code in the body? It should work because I myself has got it to work in PHP-Nuke.
 

prasys

New Member
Messages
330
Reaction score
0
Points
0
PHP:
<html>
<?php
switch($_GET['id'])
{
case "corporate":
?>

<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script>
<script language='JavaScript' type='text/javascript'> 
<!-- 
if (!document.phpAds_used) 
document.phpAds_used = ','; 
phpAds_random = new String (Math.random());
phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='"); 
document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); 
document.write ("&amp;what=zone:1&amp;target=_blank"); 
document.write ("&amp;exclude=" + document.phpAds_used); 
if (document.referrer) 
document.write ("&amp;referer=" + escape(document.referrer)); 
document.write ("'><" + "/script>"); 
//--> 
</script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a7fb3e9d' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:1&amp;n=a7fb3e9d' border='0' alt=''></a></noscript>

<?php
break;
case "advanced":
?>

<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script> 
<script language='JavaScript' type='text/javascript'> 
	if (!document.phpAds_used) document.phpAds_used = ',';
	phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
	document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
	document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); 
	document.write ("&amp;what=zone:2&amp;target=_blank"); document.write ("&amp;exclude=" + document.phpAds_used); 
	if (document.referrer)
		document.write ("&referer=" + escape(document.referrer));
	document.write ("'><" + "/script>"); 
</script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a4f0eec1' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:2&n=a4f0eec1' border='0' alt=''></a></noscript>

<?php
break;
case "static":
?>

<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script> 
<script language='JavaScript' type='text/javascript'> 
<!-- 
if (!document.phpAds_used) document.phpAds_used = ','; 
phpAds_random = new String (Math.random()); 
phpAds_random = phpAds_random.substring(2,11); 
document.write ("<" + "script language='JavaScript' type='text/javascript' src='"); 
document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); 
document.write ("&amp;what=zone:3&amp;target=_blank"); 
document.write ("&amp;exclude=" + document.phpAds_used); 
if (document.referrer) 
document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>"); 
//--> 
</script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a915c788' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:3&amp;n=a915c788' border='0' alt=''></a></noscript>

<?php
break;
}
?>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Coming Soon</title>
</head>
<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script> <script language='JavaScript' type='text/javascript'> <!-- if (!document.phpAds_used) document.phpAds_used = ','; phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11); document.write ("<" + "script language='JavaScript' type='text/javascript' src='"); document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); document.write ("&amp;what=zone:1&amp;target=_blank"); document.write ("&amp;exclude=" + document.phpAds_used); if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); document.write ("'><" + "/script>"); //--> </script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a7fb3e9d' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:1&amp;n=a7fb3e9d' border='0' alt=''></a></noscript>
<body>
<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script> <script language='JavaScript' type='text/javascript'> <!-- if (!document.phpAds_used) document.phpAds_used = ','; phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11); document.write ("<" + "script language='JavaScript' type='text/javascript' src='"); document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); document.write ("&amp;what=zone:1&amp;target=_blank"); document.write ("&amp;exclude=" + document.phpAds_used); if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); document.write ("'><" + "/script>"); //--> </script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a7fb3e9d' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:1&amp;n=a7fb3e9d' border='0' alt=''></a></noscript>
<p>Coming Soon..I'm working on a True Mac Site ! </p>
<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script> <script language='JavaScript' type='text/javascript'> <!-- if (!document.phpAds_used) document.phpAds_used = ','; phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11); document.write ("<" + "script language='JavaScript' type='text/javascript' src='"); document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); document.write ("&amp;what=zone:1&amp;target=_blank"); document.write ("&amp;exclude=" + document.phpAds_used); if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); document.write ("'><" + "/script>"); //--> </script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a7fb3e9d' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:1&amp;n=a7fb3e9d' border='0' alt=''></a></noscript>
<script language='JavaScript' type='text/javascript' src='http://x10hosting.com/advert/adx.js'></script> <script language='JavaScript' type='text/javascript'> <!-- if (!document.phpAds_used) document.phpAds_used = ','; phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11); document.write ("<" + "script language='JavaScript' type='text/javascript' src='"); document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); document.write ("&amp;what=zone:1&amp;target=_blank"); document.write ("&amp;exclude=" + document.phpAds_used); if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); document.write ("'><" + "/script>"); //--> </script><noscript><a href='http://x10hosting.com/advert/adclick.php?n=a7fb3e9d' target='_blank'><img src='http://x10hosting.com/advert/adview.php?what=zone:1&amp;n=a7fb3e9d' border='0' alt=''></a></noscript>
</body>

</html>

This is a Sample Code for coding in Frontpage..Hopefully that should help you users that use Frontpage (should work in Windows aswell)..:D
 

Kalim3ru

New Member
Messages
16
Reaction score
0
Points
0
What about Coppermine Photo Gallery?

I'm using it in my webpage, with the theme Hardwired...Does anyone know how to put the ad code on the header??
 

yhap2003

New Member
Messages
222
Reaction score
0
Points
0
With the code prasys posted here it's far more easier to get the ad working. I had my problems using the first set of codes!!!
 

Richard

Active Member
Messages
2,028
Reaction score
0
Points
36
You can just place the ad code anyware between the <body> </body> tags
 

BrettFreeman

New Member
Messages
106
Reaction score
0
Points
0
Re: Placing the Ads in Various Pages

You can include HTML in PHP. For example:
PHP:
<html>
<head>
<title>TITLE</title>
</head>
<body>
<p>Html</p>
<?
$test = "PHP!";

echo "$test";

?>
<p>HTML again</p>
</body>
</html>
 

Chris

New Member
Messages
1,538
Reaction score
0
Points
0
Re: Placing the Ads in Various Pages

joejoe said:
How to do that in HTML (not PHP)?

Seeker responded correctly, but just to clarify, if you are posting it in HTML pages, you don't use the modified "echo" tags. You just use the original code provided in the other thread.
 

Conquester777

New Member
Messages
180
Reaction score
0
Points
0
Re: Placing the Ads in Various Pages

Why use echo so much? This works (0.000001secs) faster:

Corporate:
Code:
echo '<script language="JavaScript" type="text/javascript" src="http://x10hosting.com/advert/adx.js"></script> <script language="JavaScript" type="text/javascript"> <!-- if (!document.phpAds_used) document.phpAds_used = \',\'; phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11); document.write ("<" + "script language=\'JavaScript\' type=\'text/javascript\' src=\'"); document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); document.write ("&amp;what=zone:1&amp;target=_blank"); document.write ("&amp;exclude=" + document.phpAds_used); if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); document.write ("\'><" + "/script>"); //--> </script>';<noscript><a href="http://x10hosting.com/advert/adclick.php?n=a7fb3e9d" target="_blank"><img src="http://x10hosting.com/advert/adview.php?what=zone:1&amp;n=a7fb3e9d" border="0" alt=""></a></noscript>

Advance:
Code:
echo '<script language="JavaScript" type="text/javascript" src="http://x10hosting.com/advert/adx.js"></script> <script language="JavaScript" type="text/javascript"> <!-- if (!document.phpAds_used) document.phpAds_used = \',\'; phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11); document.write ("<" + "script language=\'JavaScript\' type=\'text/javascript\' src=\'"); document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); document.write ("&amp;what=zone:2&amp;target=_blank"); document.write ("&amp;exclude=" + document.phpAds_used); if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); document.write ("\'><" + "/script>"); //--> </script><noscript><a href="http://x10hosting.com/advert/adclick.php?n=a4f0eec1" target="_blank"><img src="http://x10hosting.com/advert/adview.php?what=zone:2&amp;n=a4f0eec1" border="0" alt=""></a></noscript>

Static:
Code:
echo '<script language="JavaScript" type="text/javascript" src="http://x10hosting.com/advert/adx.js"></script> <script language="JavaScript" type="text/javascript"> <!-- if (!document.phpAds_used) document.phpAds_used = \',\'; phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11); document.write ("<" + "script language=\'JavaScript\' type=\'text/javascript\' src=\'"); document.write ("http://x10hosting.com/advert/adjs.php?n=" + phpAds_random); document.write ("&amp;what=zone:3&amp;target=_blank"); document.write ("&amp;exclude=" + document.phpAds_used); if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); document.write ("\'><" + "/script>"); //--> </script><noscript><a href="http://x10hosting.com/advert/adclick.php?n=a915c788" target="_blank"><img src="http://x10hosting.com/advert/adview.php?what=zone:3&amp;n=a915c788" border="0" alt=""></a></noscript>
 

Chris

New Member
Messages
1,538
Reaction score
0
Points
0
Re: Placing the Ads in Various Pages

None of those work...

You can't have the code on one line...
 
Last edited:

kaliforna

New Member
Messages
60
Reaction score
0
Points
0
Re: Placing the Ads in Various Pages

Question: how would one go about adding the advertisement into a .CGI script?

~kaliforna

btw: thank-you for the PHP help, works fine! as well as the HTML version. Now,
back to the question. CGI addition of the advertisement. thankz for the info. l8r
 

kaliforna

New Member
Messages
60
Reaction score
0
Points
0
Re: Placing the Ads in Various Pages

kaliforna said:
Question: how would one go about adding the advertisement into a .CGI script?

~kaliforna

btw: thank-you for the PHP help, works fine! as well as the HTML version. Now,
back to the question. CGI addition of the advertisement. thankz for the info. l8r

. sit'n around, dazed and confused! ~ CGI advertisement ? :blink:
 

hotvins

New Member
Messages
20
Reaction score
0
Points
0
Hi

How to integrate Google Adsense ads in the 4images gallery, coppermine photo gallery and phpbb ?
 
Top