I must admit that when it comes to php, I consider myself 100% novice.
I do know, however, that my sql syntax is correct and I do have records in the database.
Yet when I run this code, I get my UDM (user-defined message) "Record doesn't exist"
Just a bit of a story of what is going on here.
We have a bunch of pdf files stored in an access database.
Originally, we used asp (with aspSmartUpload component) to do this.
Yes, I have always believed it is a bad idea to store images in a database; that is a different story, however.
In this case, we have provided the ability to retrieve these pdf files from access database using asp.
However, we decided to switch from asp to php.
This is my first php code and it really stinks but can someone, please see what I am doing wrong here?
Here is the entire code:
code:--------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>More Counts</title>
<link rel="stylesheet" type="text/css" href="/ms/style_css/styles.css">
</head>
<body bgcolor="#6270B5">
<div align="center">
<?php
// DB connection here.
$connectionstring = odbc_connect("Gounts", "", "") or die(odbc_error());
$sql = "SELECT FileData FROM ficFiles,fic where fic.site_Code = ficFiles.sCode and fic.sCode = '".$_REQUEST["sCode"]."'"; $rs=odbc_exec($connectionstring,$sql);
if (!$rs)
{
exit("Error in SQL");
}
if (($rs) == 1)
{
$fileType = odbc_result($result, 0, "contentType");
$fileContent = odbc_result($result, 0, "filedata");
header("Content-Type: $fileType");
header("Content-Length: " . strlen($filedata));
header("Content-Disposition: inline; filename=file.pdf;");
echo $fileContent;
}
else
{
echo "Record doesn't exist.";
}
?>
</body>
</html>
BTW: sCode is a text data type
So basically, I have a page that has something like this:
<td class="name">Site Code</td>
<td class="name">Distance </td>
<td class="name"> </td>
<td class="value">[SITE_CODE]</td>
<td class="value">[DISTANCE]</td>
<td class="name" width="10%" align="center" valign="top"><font size="-1"><a href="#" onClick="window.open('http://pw6/reports/trafficcounts/traffic_counts_more.php?siteCode=[SITECODE]','','width=500,height=200,scollbars,resizable=yes')">Study Info</a></font></td>
When I click on Study Info, I will like the link to take me to the page I first posted which will then contain the the files from the database.
Sorry but if I am not clear, please let me know.
This is really important to me.
Thanks in advance