Skipjackrick Posted February 8, 2009 Share Posted February 8, 2009 I am using the "opendir" to open pics from a particular directory. I want to put a variable inside the directory and it is not working. The following code gives me this error. Any ideas around this? Warning: opendir(/home/mysite/public_html/$team_name/pics/) [function.opendir]: failed to open dir: No such file or directory <?php if ($handle = opendir('/home/mysite/public_html/$team_name/pics/')) { while (false !== ($file = readdir($handle))) { if (preg_match("/\.(jpg|png|jpeg)$/i", $file)) { echo "<a href='$file' onclick='return hs.expand(this)' class='highslide'>\n"; echo "<img src='show_image.php?filename=$file&width=100&height=100' alt=''/>\n"; echo "</a>\n"; } } closedir($handle); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/144396-opendir-wont-accept-a-variable/ Share on other sites More sharing options...
wildteen88 Posted February 8, 2009 Share Posted February 8, 2009 variables are only parse able within double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/144396-opendir-wont-accept-a-variable/#findComment-757727 Share on other sites More sharing options...
Skipjackrick Posted February 8, 2009 Author Share Posted February 8, 2009 variables are only parse able within double quotes. Doh!?!?! Thanks..... Quote Link to comment https://forums.phpfreaks.com/topic/144396-opendir-wont-accept-a-variable/#findComment-757750 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.