Hi all.
I am using the below code for extracting some information from a database. The problem I am having is that while the code works fine for files uploaded without spaces in the file title, if there is a space the code does not work.
The full and correct file name is stored in the database but this code gets to the space and then doesnt continue. For example the file could be "phpbuilder.doc" and it will be fine but if it were "php builder.doc" the below code will only extract the file name to the space and not include the "builder.doc" as such the file links do not work.
If anyone could let me know why this code is not extracting the whole filepath from the database it would be a huge help.
$query = "SELECT * FROM news ORDER BY postdate";
$rs = mysql_query($query);
if($rs && mysql_num_rows($rs) > 0)
{
$list = "<table width=\"680\" colspan=\"4\" border=\"0\" cellpadding=\"2\" bgcolor=\"#FFFFFF\">";
while ( $row = mysql_fetch_array($rs))
{
$list .= "<tr>                        ...........................................................................................................................    </tr> <br>";
$list .= "<tr><b>Title </b>".$row["subject"]." <b>         Posted On </b>".$row["postdate"]."</tr> <br>";
$list .= "<tr>".$row["body"]."</tr>";
if ($row["filepath"] !="") //there is an associated file so show link
{
$list .= "<br><br><tr><a href=".$row["filepath"].">Click here </a> to view associated file</tr>";
}
if ( is_authed() or is_adminauthed() )
{
if ($row['memid'] != $_SESSION['userid']) //if user is same as poster show delete and edit buttons
{
$list .= "</tr>";
}
else
{
$list .= "<br><tr>
<form action=\"viewnews.php\" method=\"post\" class=\"button\">
<input type=\"submit\" name=\"delete\" value=\"Delete\">
<input type=\"hidden\" name=\"newsid\" value=".$row["newsid"]."> </form>
<form action=\"editnews.php\" method=\"post\" class=\"button\">
<input type=\"submit\" name=\"edit\" value=\"Edit\">
<input type=\"hidden\" name=\"newsid\" value=".$row["newsid"]."> </form>
</tr>";
$list .= "</tr>";
}
//elseif ($row['memid'] != $_SESSION['userid'])
}
}
$list .= "</table>";
echo ($list);