Jump to content
Mencarta

Reading Array

Recommended Posts

My code:index.php

<?php	$dir = "/files";	$files = array();		if ($handle = opendir("/files")) {		while ($false !== ($file = readdir($handle))) {			$files[] = $file;		}	}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>	<head>		<title>Fever 1793 - Home</title>		<link rel="stylesheet" type="text/css" href="fever.css" />	</head>	<body>		<div id="header">			<h1>Fever 1793</h1>		</div>		<div id="page">			<h2>Fever 1793</h2>			<div id="desc">Fever 1793 is a novel by Laurie Halse Anderson that takes place in Philidelphia. Mattie, a young girl, lives in Philidelphia						   during the Yellow Fever outbreak in 1793. The novel is in a diary format where Mattie shares her view of the day. Characters						   in the book include: Grandfather, Mother, Eliza, and Nethaniel Benson.			</div>			<div id="wrap">			<div id="powerpoint">				<h2>Powerpoint</h2>				<?php										print_r($files);									?>			</div>			<div id="scrapbook">				<h2>Scrapbook</h2>				<?php																	?>			</div>			<div id="links">				<h2>Links</h2>				<?php																	?>			</div>			<div id="gallery">				<h2>Gallery</h2>				<?php																	?>			</div>			</div>		</div>	</body></html>

Generates the error: Warning: opendir(/files) [function.opendir]: failed to open dir: No error in C:\apache\server\projects\fever.php on line 6Any ideas?

Share this post


Link to post
Share on other sites
My code:index.php
<?php	$dir = "/files";	$files = array();		if ($handle = opendir("/files")) {		while ($false !== ($file = readdir($handle))) {			$files[] = $file;		}	}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>	<head>		<title>Fever 1793 - Home</title>		<link rel="stylesheet" type="text/css" href="fever.css" />	</head>	<body>		<div id="header">			<h1>Fever 1793</h1>		</div>		<div id="page">			<h2>Fever 1793</h2>			<div id="desc">Fever 1793 is a novel by Laurie Halse Anderson that takes place in Philidelphia. Mattie, a young girl, lives in Philidelphia						   during the Yellow Fever outbreak in 1793. The novel is in a diary format where Mattie shares her view of the day. Characters						   in the book include: Grandfather, Mother, Eliza, and Nethaniel Benson.			</div>			<div id="wrap">			<div id="powerpoint">				<h2>Powerpoint</h2>				<?php										print_r($files);									?>			</div>			<div id="scrapbook">				<h2>Scrapbook</h2>				<?php																	?>			</div>			<div id="links">				<h2>Links</h2>				<?php																	?>			</div>			<div id="gallery">				<h2>Gallery</h2>				<?php																	?>			</div>			</div>		</div>	</body></html>

Generates the error: Warning: opendir(/files) [function.opendir]: failed to open dir: No error in C:\apache\server\projects\fever.php on line 6Any ideas?

Yeah try files/ instead of /files as directory.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...