Jump to content

Reading Array


Mencarta

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?

Link to comment
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.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...