Re: mysql + php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Will Contact" <willcontactme@xxxxxxxxxxx>

> Now I am  programming php+mysql.  I put word, excel, mpeg and
> any binaries into
> the mySQL database using php on linux server,But I can take out these
binay
> from mySQL database. I would like to see the files and save my pc from
> server. So how can I take out from
> these binaries?
[snip]
>     $sql_insert = "INSERT INTO objects(b_col, file_name, file_size,
> file_type,file_date) VALUES
>
('$UploadedFile','$UploadedFile_name','$UploadedFile_size','$UploadedFile_ty
pe',now())";
>
>    mysql_query($sql_insert);

Are you sure anything is even being put in the database here? There's no
error checking. Is the blob empty?

> // But it does not work at. I can not see anything in my browser
>     $sql_select = "select b_col, file_name, file_size, file_type,
file_date
> from objects where  file_name like 'gball.gif'";
>     if(!($result=mysql_query($sql_select,$db))){
>       die;
>       }
>
>                $file_name = mysql_result ($result,0,"file_name");
>                echo $file_name;

You need to check what's actually in your database. If you don't get a
result here, then there's nothing matching "gball.gif" in your database
(even if you think there is).

As for displaying these files again (obligatory mention that storing binary
files in the database is a BAD idea, IMHO) it's a simple matter of using
header() to send an appropriate CONTENT header matching whatever kind of
file you're sending "text/plain", "image/jpg", etc and then echoing the data
from the blob.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux