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";

?>

 

Link to comment
Share on other sites

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";
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.