Jump to content

This php script will not display anything if i add a href


madspof

Recommended Posts

this is a script that i use to display files for a specific acount on my website i wanted to add a link from each file so that they could delete a file if they wanted. But when i add the extra href to the end of the echo the script does not display thing i have provided the original script and the one i have edited

This is the original:

<?php

include "../status.php";

$cookie_info = explode("-", $_COOKIE['cookie_info']);

$namecookie = $cookie_info[0];

$files = array();

$dir=opendir("./$namecookie");

while(($file = readdir($dir)) !== false) 

if($file !== '.' && $file !== '..' && !is_dir($file)) 

$files[] = $file; 

closedir($dir);

natcasesort($files);

echo "<ul>\n";

for($i=0; $i<count($files); $i++) 

{

if($files[$i] != "index.php")

echo "<li><a href=\"$namecookie/".$files[$i]."\">".$files[$i]."</a></li>\n";

}

echo "</ul>\n";

?>

 

This is the edited script:

  <?php

include "../status.php";

$cookie_info = explode("-", $_COOKIE['cookie_info']);

$namecookie = $cookie_info[0];

$files = array();

$dir=opendir("./$namecookie");

while(($file = readdir($dir)) !== false) 

if($file !== '.' && $file !== '..' && !is_dir($file)) 

$files[] = $file; 

closedir($dir);

natcasesort($files);

echo "<ul>\n";

for($i=0; $i<count($files); $i++) 

{

if($files[$i] != "index.php")

echo "<li><a href=\"$namecookie/".$files[$i]."\">".$files[$i]."</a><a href="delete.php?del=$namecookie">delete </a></li>\n";

}

echo "</ul>\n";

?>

 

orite okay wel here is the orignal code :

  <?php
include "../status.php";
$cookie_info = explode("-", $_COOKIE['cookie_info']);
$namecookie = $cookie_info[0];
$files = array();
$dir=opendir("./$namecookie");
while(($file = readdir($dir)) !== false)  
{  
if($file !== '.' && $file !== '..' && !is_dir($file))  
{  
	$files[] = $file;  
}  
}  
closedir($dir);
natcasesort($files);
echo "<ul>\n";
for($i=0; $i<count($files); $i++)  
{
if($files[$i] != "index.php")
echo "<li><a href=\"$namecookie/".$files[$i]."\">".$files[$i]."</a></li>\n";
}
echo "</ul>\n";
?>

 

and here is the altered code:

 

  <?php
include "../status.php";
$cookie_info = explode("-", $_COOKIE['cookie_info']);
$namecookie = $cookie_info[0];
$files = array();
$dir=opendir("./$namecookie");
while(($file = readdir($dir)) !== false)  
{  
if($file !== '.' && $file !== '..' && !is_dir($file))  
{  
	$files[] = $file;  
}  
}  
closedir($dir);
natcasesort($files);
echo "<ul>\n";
for($i=0; $i<count($files); $i++)  
{
if($files[$i] != "index.php")
echo "<li><a href=\"$namecookie/".$files[$i]."\">".$files[$i]."</a><a href="delete.php?del=$namecookie">Delete</a></li>\n";
}
echo "</ul>\n";
?>

Parse or Syntax errors are errors in code that causes the script to not compile.

 

http://en.wikipedia.org/wiki/Parsing

 

So basically every language has certain characteristics that you use to make it run, since the compiler does not have a human brain it has to have certain rules, like a variable in PHP is denoted by a $ and literal data is encapsulated in " " or ' '

 

So it is sort of like the grammar for programming. When you are reading someones paper you take in the information, if they missed a period somewhere or have a fragmented sentence that does not make sense it generally causes you to pause and or stop. Same with compilers.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.