Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling MySQL data

Status
Not open for further replies.

LuckySyringe

Technical User
Oct 11, 2005
35
0
0
US
This script I had displayed a flash file, but now it needs to be able to accept other MIME types as well -- I made a few changes, but it just returns blank...

Code:
<?php
error_reporting(E_ALL);
require 'config.php';
$id = $_GET['id'];
$dbTable = $_GET['tb'];
dbConnect();
$query = "SELECT content, mime_type FROM ".$dbTable." WHERE id=".$id;
$result = mysql_query("$query")
	or die("Invalid query: " . mysql_error());
$data = mysql_fetch_array($result);
header("Content-type: ".stripslashes($data['mime_type']));
echo stripslashes($data['content']);
dbDisconnect();
?>

...any help would be greatly appreciated.

-> LuckySyringe
 
i see you have error reporting set to E_ALL, do you have display_errors set to on in your php.ini file?
 
if you pass the query into mysql via the command line, do you obtain the anticipated results?
 
Yes, I get exactly what I asked for:

(in phpMyAdmin)

SQL query:
Code:
SELECT content, mime_type
FROM new_table
WHERE id =1

I get:
Code:
content mime_type
[BLOB - 227.9 KB] application/x-shockwave-flash

-> LuckySyringe
 
then, since your code looks fine and you get no errors, i suspect that the values are not being passed correctly from the url.

add die ($query) after the $query=... line to see what the query looks like.
 
This is really wierd, it prints out exactly that

Code:
SELECT content, mime_type FROM new_table WHERE id=1

...and when I change the code around to:
Code:
echo stripslashes($data['mime_type'])."\n\n";
echo stripslashes($data['content']);

...i get:
Code:
application/x-shockwave-flash

CWS?È... (a lot of random characters)

-> LuckySyringe
 
that looks right then. the random characters are the actual insides of the "content".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top