sir_jeans
04-18-2012, 12:14 PM
I'm pretty sure that this is a simple problem to fix, but I don't have the necessary expertise. And after about 4 hours of trawling the net, I can't find a solution.
I am conducting an experiment and need to randomly redirect participants to one of three conditions (I.e. web pages). Someone from these forums was lovely enough to help me with this a while ago, and I managed to get the code to work beautifully. that thread is here: http://www.codingforums.com/showthread.php?p=1203705#post1203705
The code uses a .txt file containing numbers "1", "2" and "3" in random order. I am doing it this way for good reason - I need my participants to be redirected according to a number list that I made myself.
The problem is, the code works fine on my laptop, but now that I've uploaded the website to a host, it keeps coming up with a 404 error message. I think I know what the problem is: the script (below) redirects people to pages that are named "1" "2" or "3". However, it does NOT redirect to pages named "1.php", "2.php" and "3.php".
How do I make the script below do this? I.e, how do I assign the values "1", "2" and "3" in the .txt file to "1.php", "2.php" and "3.php"? Here's the code:
<?php
$page = file('test.txt', FILE_IGNORE_NEW_LINES);
$useThis = $page[0];
$love = array_shift($page);
array_push($page, $useThis);
$arr = $page;
$fp=fopen("test.txt","w");
foreach($arr as $key => $value){
fwrite($fp,$value."\n");
}
header("Location: $useThis");
?>
I really hope someone can help me with this - I need to get my study online asap!
I am conducting an experiment and need to randomly redirect participants to one of three conditions (I.e. web pages). Someone from these forums was lovely enough to help me with this a while ago, and I managed to get the code to work beautifully. that thread is here: http://www.codingforums.com/showthread.php?p=1203705#post1203705
The code uses a .txt file containing numbers "1", "2" and "3" in random order. I am doing it this way for good reason - I need my participants to be redirected according to a number list that I made myself.
The problem is, the code works fine on my laptop, but now that I've uploaded the website to a host, it keeps coming up with a 404 error message. I think I know what the problem is: the script (below) redirects people to pages that are named "1" "2" or "3". However, it does NOT redirect to pages named "1.php", "2.php" and "3.php".
How do I make the script below do this? I.e, how do I assign the values "1", "2" and "3" in the .txt file to "1.php", "2.php" and "3.php"? Here's the code:
<?php
$page = file('test.txt', FILE_IGNORE_NEW_LINES);
$useThis = $page[0];
$love = array_shift($page);
array_push($page, $useThis);
$arr = $page;
$fp=fopen("test.txt","w");
foreach($arr as $key => $value){
fwrite($fp,$value."\n");
}
header("Location: $useThis");
?>
I really hope someone can help me with this - I need to get my study online asap!