Forum Moderators: open

Message Too Old, No Replies

Link Rotator Script - help

         

Danm

11:01 pm on Apr 20, 2009 (gmt 0)

10+ Year Member



Hi guys,

I found this code:

<html>
<head>
<title>Put Your Website Title Here</title>
<meta name="keywords" content="Put Your Keywords Here">
<style>
* {margin:0; padding:0;}
</style>

</head>
<body>

<?
$urls = array(
"http://affiliatelinkaddress1.com",
"http://affiliatelinkaddress2.com",
"http://affiliatelinkaddress3.com",
"http://affiliatelinkaddress4.com");
$url = $urls[array_rand($urls)];

echo '<iframe style="margin:0; padding:0; border:0;" src='.$url.' width=100% height=100% frameborder=no></iframe>';

?>
</body>
</html>

But some thing's wrong with it. When I load the page I just get an empty page with:

'; ?>

That's all I see.

What I'm trying to get it to do is randomly redirect people to different landing pages so I can see which performs best.

Also, should this be a .php file or does it not matter?

Thanks all!

rocknbil

2:25 am on Apr 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah Danm, what you have there is php, so the first instance of this

<?

Should be this

<?php

and the second instance of it is correct, it should be

?>

Those are the beginning and ending delimiters of inline PHP code, and the file should be saved with a PHP extension.

Danm

3:57 pm on Apr 21, 2009 (gmt 0)

10+ Year Member



Thanks rocknbil, I changed it to this like you said:

<html>
<head>
<title>Put Your Website Title Here</title>
<meta name="keywords" content="Put Your Keywords Here">
<style>
* {margin:0; padding:0;}
</style>

</head>
<body>

<?php
$urls = array(
"http://affiliatelinkaddress1.com",
"http://affiliatelinkaddress2.com",
"http://affiliatelinkaddress3.com",
"http://affiliatelinkaddress4.com");
$url = $urls[array_rand($urls)];

echo '<iframe style="margin:0; padding:0; border:0;" src='.$url.' width=100% height=100% frameborder=no></iframe>';

?>
</body>
</html>

but I still get '; ?> when I preview the page. It's a .php file too.

Any other suggestions that might help?

I'm basically trying to iframe but also rotate the landing pages in the iframe to see which converts better.

Thanks!

swa66

4:07 pm on Apr 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have php processing enabled in you http server ?

Also look at the source code your browsers get (view source), if the script is in there, the php isn't parsed server side as it should have been.

Danm

4:51 pm on Apr 21, 2009 (gmt 0)

10+ Year Member



Thanks both of you, I got it working with your help. I didn't know php files had to be uploaded to the server. I was previewing them locally which is why I kept getting '; ?>

All working great now, thanks again ;-)