View Full Version : Couldn't see jpg.

07-07-2005, 07:14 AM
$conn = @mysql_connect($host, $user, $pass) or die("host, user, pass .");
mysql_select_db($db, $conn) or die("$db ??.");
for ($i=1; $i<=1; $i++) {
$row = mysql_fetch(" select up_file, content from $up_load where files = '$up_files' and up_id = '$up_id' and file_no = '$i' ");
if (eregi('\.jpg', $row[up_file])) echo $row[up_file]. "<p>";

What am i missing?

07-07-2005, 07:42 AM
$conn = @mysql_connect($host, $user, $pass) or die("host, user, pass .");
mysql_select_db($db, $conn) or die("$db ??.");
for ($i = 1; $i <= 1; $i++)
$row = mysql_fetch(" SELECT `up_file`, `content` FROM '$up_load' WHERE `files` = '$up_files' AND `up_id` = '$up_id' AND `file_no` = '$i' ");
if (eregi('\.jpg', $row["up_file"]))
echo $row["up_file"]. "<p>";

Sorry i had too format it neatly to understand what you were doing :O all i could see while i had a quick look was $row[up_file] should have been $row["up_file"]...

if it still doesnt work have a look to see what the path of the image is thats trying to be included (right click and properties)... it may be looking to a different path also.

07-07-2005, 07:44 AM
Dear Serex,

Thanks a lot.

I will study. ;)

07-07-2005, 07:29 PM
1. $row[var] == $row['var'] == $row["var"], so long as var is only string or numeric data. "var" will probably give you troubles though with numeric. For stricter reasoning, you should enclose all strings within a set of single (or double, however for size and output times I recommend single) quotations, and numeric or constant data without quotations. This will keep notices away from your output as well. More information about 'why its bad...' here (http://ca3.php.net/manual/en/language.types.array.php).

2. mysql_fetch() does not exist. If you have php5.x, you can use mysqli_fetch, though its more of a OOP style class, and not quite the same for that. Otherwise, you are using a user defined function which I do not see declared. Assuming you are meaning to use mysql_fetch[row|array|assoc].

3. There is no content type header. If you use binary data, I would recommend this to be added.

4. I don't know what you are looking for. I'd say your looking for a binary data image, though you won't get it to work very well with the html in there. You would need two scripts to process this, one to output data to the browser directly, and another to create the call. Ex: <img src="myimage.php?imageid=4" /> for instance. I don't recommend combining both into one script if this is what you are doing. If you are retrieving file links, that is a completely different scenario.
If you provide more information for what it is you are retrieving and how the variables are being created, we can help you more with putting this together.