Hello,
I have a problem and for the life of me cannot figure out the problem. I inherited the PHP/mySQL code from a friend which did no documentation whatsoever. I do not know how this happened but it did.
My problem is with displaying images correctly. The images are in a table stored in a BLOB type. I now know that is bad but I really do not want to redo this if I can avoid it as there are a lot of images already stored with more being added almost daily.
So, the details of the problem go like this...
A user goes to a page to look up an image by either ID number or name. The submit button passes it to a php that uses this information to pull the image from the database and the image is displayed. Users sometime need to print the image for paper records. So, the user hits the print button in the web browser and the image prints. Up until this point everything works correctly. Any image you search for comes up. The proble is in the printing. It doesn't matter which image you search for and try to print the only image that prints is the first one in the database. Even when using the print preview button the only image that shows up is the first image. I have looked at the code and it looks good. But I am no expert in PHP and have no formal instruction on it; just what I have acquired from my own learning. So, I come to experts to see if I can get help.
The search form...
And the results...
This is just the important search and results part. There is other code that pertains to the usual connections and stuff. Unless, of course, there is an off chance that this problem is related to the session that is used throughout the entire website. But I do not think that is the problem.
I have a problem and for the life of me cannot figure out the problem. I inherited the PHP/mySQL code from a friend which did no documentation whatsoever. I do not know how this happened but it did.
My problem is with displaying images correctly. The images are in a table stored in a BLOB type. I now know that is bad but I really do not want to redo this if I can avoid it as there are a lot of images already stored with more being added almost daily.
So, the details of the problem go like this...
A user goes to a page to look up an image by either ID number or name. The submit button passes it to a php that uses this information to pull the image from the database and the image is displayed. Users sometime need to print the image for paper records. So, the user hits the print button in the web browser and the image prints. Up until this point everything works correctly. Any image you search for comes up. The proble is in the printing. It doesn't matter which image you search for and try to print the only image that prints is the first one in the database. Even when using the print preview button the only image that shows up is the first image. I have looked at the code and it looks good. But I am no expert in PHP and have no formal instruction on it; just what I have acquired from my own learning. So, I come to experts to see if I can get help.
The search form...
Code:
<h2>Search For Card</h2> <form action="viewCard2.php" method="post" target="_blank"> Last 4 Digits of SSN: <input name=socsec maxlength="4" /><br>OR<br> Last Name: <input name="personname"><br><input type=submit value="View Card" /></form><br> (Card opens in new window. If window is blank, no card found.)
Code:
$conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die ('WARNING! YOU ARE NOT LOGGED IN. PLEASE RETURN TO MAIN PAGE AND TRY AGAIN WITH YOUR LOGIN INFORMATION'); mysql_select_db($dbname,$conn); $id = $_POST['socsec']; if($id=='') { $query = "SELECT Image, SSN, Type, Size FROM Images WHERE Name LIKE '%$personname'"; } else if($personname=='') { $query = "SELECT Image, SSN, Type, Size FROM Images WHERE SSN LIKE '%$id'"; } else { $query = "SELECT Image, SSN, Type, Size FROM Images WHERE SSN LIKE '%$id'"; } $result = mysql_query($query) or die('Error, query failed'); list($name, $soc, $type, $size) = mysql_fetch_array($result); header('Content-length: ' .$size); header('Content-type: ' .$type); echo $name; if($name=='') { echo "Sorry, no card found for $id $personname";
Comment