Simple PHP Prob
Posted: Fri Mar 28, 2003 4:10 pm
HI Guys,
<?php
switch(mt_rand(0,2)) {
case 0: print "link1";
case 1: print "link2";
case 2: print "link3";
}
?>
I am signed up with a number of affiliate schemes and i am using (trying to) get this to randomly display which one is shown but it gives this error
Parse error: parse error, unexpected T_STRING in /home/collyer/public_html/front.php on line 23
line 23 is the case 0 line. I know php works as i have php bb on the server working.
Any help appreciated..
Edit: worked out its becuase the links have a " in...any ideas?
Edit2: ok i have used the escape charater to stop the errors but now the script will print link1, or link 1 and 2, or link 1 and 2 and 3
It seems that if the case is 2 then it is printing 1 and 2 not just 2 any ideas on this.
Cheers
Richard
<?php
switch(mt_rand(0,2)) {
case 0: print "link1";
case 1: print "link2";
case 2: print "link3";
}
?>
I am signed up with a number of affiliate schemes and i am using (trying to) get this to randomly display which one is shown but it gives this error
Parse error: parse error, unexpected T_STRING in /home/collyer/public_html/front.php on line 23
line 23 is the case 0 line. I know php works as i have php bb on the server working.
Any help appreciated..
Edit: worked out its becuase the links have a " in...any ideas?
Edit2: ok i have used the escape charater to stop the errors but now the script will print link1, or link 1 and 2, or link 1 and 2 and 3
It seems that if the case is 2 then it is printing 1 and 2 not just 2 any ideas on this.
Cheers
Richard