inserting php in non-php pages (dynamic banner)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

inserting php in non-php pages (dynamic banner)

Post by kendall »

Hi,

sorry but couldnt really think of an appropriate name for the question....

I have created a banner script that randomly displays images from a database...

the script is to be called with a variaiable parameter and then echoes a img tag with the information...

How do you guys get this to work on non-php pages... reason for this is that i want to be able to have ppl display my banners by merely calling the script

here my theory of function

php script
<?php

i get the type of banner to display true $_GET['type'];

get the random banner from database using mysql_query();

echo banner using <img src=PATH.mysql_result>

?>

but how do i call the script from a non php stand point?

Kendall
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

i think you need to use the cgi-module which needs to be called via <script language="php"></script>
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

inserting php in non-php pages (dynamic banner)

Post by kendall »

m3rajk,
i think you need to use the cgi-module
what is the cgi-module... 8O

i did use a

Code: Select all

<script language = php src = file.php></script>
but it didnt work...i got no output :?:
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Re: inserting php in non-php pages (dynamic banner)

Post by vigge89 »

kendall wrote:m3rajk,
i think you need to use the cgi-module
what is the cgi-module... 8O

i did use a

Code: Select all

<script language = php src = file.php></script>
but it didnt work...i got no output :?:
what about

Code: Select all

<script language="php" src="file.php"></script>
?
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

vigger,

uhmmm... thats what i meant
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

just to update...there's a attribute to the <script> tag...

Code: Select all

<script runat='server'>
found it in dreamweaver but not on W3C documentation

wat is it?

Kendall
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

kendall wrote:just to update...there's a attribute to the <script> tag...

Code: Select all

<script runat='server'>
found it in dreamweaver but not on W3C documentation

wat is it?

Kendall
does that work?

and also, my name is victor - nickname is vigge, not vigger, veggo or something :P
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

viggee,

noooooo........... :(

what is meant by a cgi-module?

Kendall
evilMind
Forum Contributor
Posts: 145
Joined: Fri Sep 19, 2003 10:09 am
Location: Earth

Post by evilMind »

cgi: common gateway interface - standard for running external programs from a web server. CGI specifies how to pass arguments to the program as part of the request.

module: An independent piece of software which forms part of one or more larger programs. Modules are usually compiled seperately (in compiled languages) and provide an abstraction or information hiding mechanism so that a module's implementation can be changed without requiring any change to other modules.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

php can be installed as a stand alone. in this version all your pages are .php

or as a cgi-module, in which case i believe you have pages as .html with <script language="php"> /* php in here */ </script>
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

I belive that...

Code: Select all

<img src="http://www.phpdrivenserver.net/image.php?name=foo" />
...should do the trick. If you have the correct header()'s in the file on the php driven server, you should get an image. by using $_GET you can choose what image.

I cant see any other problems.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

evilMind,

I kinda know what CGI and MODULE's are i just wanted to know what was meant by it in relation to PHP

m3rajk,

AH....thanks i think you made it a bit clearer for me....

so your saying that all i need to do is insert

Code: Select all

<script language="php">
<?php
php code here
?>
</script>
then how come...

Code: Select all

<script language="php" runat="www.onlinetnt.com" src='file.php'></script>
doesn't work??? further more...WTF is the attribute 'runat' ??? i dont see it in the 3WC documentation. this is something that 'popped' up in dreamweaver coding hints.

JAM,

ma man Jamm....believe it or not seeing that all else failed i was attempting this method because all i want people to do is just insert one small tag that will link the banners to there pages and not have to insert a large bunch of code with <script><?php ?></script> method...i'm having a bit of a time understanding how it actually works but im still trying to figure it out myself...


Kendall
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

Jam...

quick question if my banners were HTML coded how would this react when i <img src='banner.php?banner=html'> which generated an html banner?

Kendall
Stil...trial and error is the best way to learn
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

JAM...

I can't seem to get this thing to work

heres my php code

Code: Select all

// after getting the results
$Image = mysql_fetch_assoc($IMG);
// display image
// get content type
echo 'http://www.onlinetnt.com/images/advertisements/'.$Image['file'];
here's what i do to retieve the script

Code: Select all

&lt;img src="http//onlinetnt.com/ad_system.php?type=B"&gt;
what else do i need to do??

Kendall
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

Kendall,

ok guys i got it i had to invoke a javascript document.write() in order to this display the image
Post Reply