PHP Problem

JB112

Newbie
Oct 14, 2010
15
7
This might just be a small thing but i have no idea how to do it! I have a small bit of knowledge but not much!

I want a "random" banner to match up with it's link

so i want banner1 to associate with link 1 ect...

here's the code. anyone know what i am doing wrong? The banner is appearing as i want it to but the link is coming out like mysite.c0m/1 . The number is being posted to my domain name instead of a new link being create in a "a href" tag

Code:
<?php

$num = rand(1,4);
$web = $num;
if ($num == "1") {
    echo 'hxxp://vvv.xxxxxx.c0m/click-4232665-10489913?tid=1';
} else if ($num == "2") {
    echo ' hxxp://vvv.xxxxxxxx.c0m/click-4232665-10489913?tid=2';
} else if ($num == "3") {
    echo ' hxxp://vvv.xxxxxxxxx.c0m/click-4232665-10489913?tid=3';
} else if ($num == "4") {
    echo ' hxxp://vvv.xxxxxxxxx.c0m/click-4232665-10489913?tid=4';
}
?>

//this then is where i am trying to post to....

<div id="ad"><a href="<?php echo $web; ?>" target="_blank"><img src="_aImages/_images/banner<?php echo $num; ?>.jpg" width="535" height="100" /></a></div>

anyone able to help?

thanks
JB
 
It's ok i figured out what was wrong...sorry for wasting anyone's time

if anyone is wondering just had to change the code a bit

Code:
<?php

$num = rand(1,4);

?>

<div id="ad"><a href="<?php $web = $num;
if ($num == "1") {
    echo 'hxxp://vvv.xxxxxx.c0m/click-4232665-10489913?tid=1';
} else if ($num == "2") {
    echo ' hxxp://vvv.xxxxxxxx.c0m/click-4232665-10489913?tid=2';
} else if ($num == "3") {
    echo ' hxxp://vvv.xxxxxxxxx.c0m/click-4232665-10489913?tid=3';
} else if ($num == "4") {
    echo ' hxxp://vvv.xxxxxxxxx.c0m/click-4232665-10489913?tid=4';
}; ?>" target="_blank"><img src="_aImages/_images/banner<?php echo $num; ?>.jpg" width="535" height="100" /></a></div>
 
instead of
Code:
echo 'hxxp://vvv.xx...';

do

Code:
$web = 'hxxp://vvv.xx...';

Edit: Just noticed I was late :) Obviously this refers to the first post.
 
thanks man!

I just took a second to think about what was happening with the script! divine inspiration :p

cheers anyway dude! i appreciate the help :D
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock