pugboy Posted June 7, 2008 Share Posted June 7, 2008 I am creating a script to display a dropdown filled with stuff from my text file... This is the code I have: <? $fileName = "./name.txt"; $fh = fopen($fileName, 'r'); $exists = file_exists($fileName); echo $exists; $nameB = fread($fh, filesize($fileName)); echo $nameB; fclose($fh); $name = explode("\n",$nameB); $fileName = "./var.txt"; $fh = fopen($fileName, 'r'); $varB = fread($fh, filesize($fileName)); fclose($fh); $var = explode("\n",$varB); for ( $id = 0; $id <= $maxid; $id += 1) { echo "<option value='$var[$id]'>$name[$id]</option>"; } ?> A lot of the code is just for debugging, and nothing is echoed at all... My directories are like this: home directory -name.txt -var.txt -UserCP --add.php (The code above) Why is nothing displayed? Do I have the file names set correctly? Link to comment https://forums.phpfreaks.com/topic/109077-solved-why-doesnt-this-work/ Share on other sites More sharing options...
digitalgod Posted June 7, 2008 Share Posted June 7, 2008 try <? $fileName = "../name.txt"; $fh = fopen($fileName, 'r'); $exists = file_exists($fileName); echo $exists; $nameB = fread($fh, filesize($fileName)); echo $nameB; $name = explode("\n",$nameB); fclose($fh); $fileName = "../var.txt"; $fh = fopen($fileName, 'r'); $varB = fread($fh, filesize($fileName)); $var = explode("\n",$varB); for ( $id = 0; $id <= $maxid; $id += 1) { echo "<option value='$var[$id]'>$name[$id]</option>"; } fclose($fh); ?> Link to comment https://forums.phpfreaks.com/topic/109077-solved-why-doesnt-this-work/#findComment-559582 Share on other sites More sharing options...
pugboy Posted June 7, 2008 Author Share Posted June 7, 2008 Ok, thanks I thought it was only 1 period... Link to comment https://forums.phpfreaks.com/topic/109077-solved-why-doesnt-this-work/#findComment-559584 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.