Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple code to create array fails

Status
Not open for further replies.

ksquared3

Programmer
Sep 2, 2007
18
US
This code fails, error message: No input file specified. The text file is on the server.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<title>array</title>
</head>
<body>
<?php $descriptions = file(“paintinglist2.txt”); ?>
</body>
</html>[code]

Am I missing something?
 
It is working now that I added a line.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<title>array</title>
</head>
<body>
<?php $descriptions = file("paintinglist2.txt"); ?>
<?php echo $descriptions[1]; ?>

</body>
</html>

However when I insert the code in my main php page. Nothing displays and when I look at the computated code, everything between the <head> and <body> is missing! Please see lines 90-91.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<?php $thisPage="fullPainting"; ?>
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
var paintingBack = 1;
var paintingNext = 1;
var caption = 1;
var pointback;
var backToDiv;
var pointnext;
var nextToDiv;
var captionsList = " ";
function processback() {
pointback();
backToDiv();
captionToDiv();
}
function pointback(){
if (paintingBack > 1) {
paintingBack = paintingBack-1;}
return;
}
function backToDiv(){
document.getElementById("paintingImage").innerHTML = "<img src=\"images/painting_"+paintingBack+".jpg\" />";
paintingNext = paintingBack;
caption = paintingBack;
return false;
} 
function processnext() {
pointnext();
nextToDiv();
captionToDiv();
}
function pointnext(){
if (paintingNext < 49){
paintingNext++;}
return;
}
function nextToDiv(){
document.getElementById("paintingImage").innerHTML =  "<img src=\"images/painting_"+paintingNext+".jpg\" />";
paintingBack = paintingNext;
caption = paintingBack;
return false;
}
function captionToDiv() {
document.getElementById("captionHere").innerHTML = captionsList[caption];
return false;
}
function captionsToCaptionsList() {
		try{
			txtFile = new XMLHttpRequest();
		}
		catch(e){
			try{
				txtFile = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e) {
				try{
					txtFile = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e){
					alert("Ajax not supported by your browser!");
					return false;
				}
			}
		}
		txtFile.open("GET", "paintinglist.txt", true);
		txtFile.onreadystatechange = function() {
			if (txtFile.readyState === 4) {// Makes sure the document is ready to parse.
				if (txtFile.status === 200) {// Makes sure it's found the file.
					captionsList = txtFile.responseText.split("\n"); 
}
}
}
txtFile.send(null);
}
captionsToCaptionsList();
//-->
</script>
<title>STEPHANIE PEEK</title>
</head>
<body>
<div id="center" align="center">
	<div id="container">
	  <div id="main">
	  <?php $paintingNumber = $_REQUEST['paintingNumber']; ?>
     <?php $descriptions = file("paintinglist2.txt"); ?>
		<?php echo $descriptions[$paintingNumber]; ?>
      <script type="text/javascript">
	  paintingBack = "<?php echo $paintingNumber; ?>";
	  paintingNext = "<?php echo $paintingNumber; ?>";
	  caption= "<?php echo $paintingNumber; ?>";
	  </script>
      <script type="text/javascript">
		function captionsToCaptionsList() {
		try{
			txtFile = new XMLHttpRequest();
		}
		catch(e){
			try{
				txtFile = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e) {
				try{
					txtFile = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e){
					alert("Ajax not supported by your browser!");
					return false;
				}
			}
		}
		txtFile.open("GET", "paintinglist.txt", true);
		txtFile.onreadystatechange = function() {
			if (txtFile.readyState === 4) {// Makes sure the document is ready to parse.
				if (txtFile.status === 200) {// Makes sure it's found the file.
					captionsList = txtFile.responseText.split("\n"); 
}
}
}
txtFile.send(null);
}
captionsToCaptionsList();
</script>
<script type="text/javascript">
</script>

	  <?php include ("includes/topNav.php"); ?>
      <div class="clear"></div>
      <div class="painting" id="paintingImage"><img src='images/painting_<?php echo $paintingNumber; ?>.jpg' /></div>
      <div class="captionText" id="captionHere"<?php echo $descriptions[$paintingNumber;] ?></div>
      <div class="clear"></div>
      </div><!--end main -->
	</div><!--end container -->
</div><!--end center -->
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top