Welcome to WebmasterWorld Guest from 18.104.22.168
I can handle making the form and such, I just need to know how to get the pictures into the db useing php.
Thanks for any help you can provide.
storing all the images in one folder and saving the filename as the primary key would be the way id try it.
$fp = fopen("s:/title.gif", "rb");
$content = mysql_escape_string(fread($fp, filesize("s:/title.gif")));
$y = mysql_query("INSERT INTO table SET content='$content'");
>>What is the var $y for?
This is explained in the PHP [php.net] manual entry for mysql_query() [php.net]: mysql_query() [php.net] returns TRUE on success and FALSE on error. It is a good idea to always check for success of an operation.
Please read the manual entries for the functions you are using. Iīm making this really easy by providing the links, so there is really no excuse not to spend a little time exploring on your own. This will help a lot and while it may take some time at first you will benefit from it in the long run.
Thatīs alright and perfectly understandable. And whenever you have a question do feel free to post here.
Itīs just that r = read is not one of those instances where the PHP [php.net] manual is hard to understand ;).
if your webserver uses cgi for your scripts, then there might be a cgi-limit. if every picture has to be displayed out of a script, then on a listing with 20 entries, you'll get 20 extra cgi spawns only for the pictures. this can heavily stress your webserver and the limit can be reached quite fast. then only broken images would be displayed.
on the other hand, it's easier to delete an item, because it's in the db only, not in the filesystem, too.
I did not try to advocate either ;).
In fact I sometimes do neither, that is I do not store the binary data in a BLOB [mysql.com] nor do I store the path of the binary file in the db. What I do is name the file after the value of the PRIMARY KEY [mysql.com] of the db.
I should have thought of this in the first place since all I really wanted was an easy way for users to send me thier pics with out having to use e-mail or FTP.
Talk about having a brain fart! :)
Now, once they have created the new dir and uploaded the pics, I just FTP them down to my computer.
Thanks again for the info for the db, I may need that someday.