Search Google for "insert image into mysql php" I found it yesterday, and have it working from an upload. :) Here is a sample...
%s\n", mysql_errno (), mysql_error (), $query); mysql_close ($conn_id); exit (); } $row = mysql_fetch_array ($res_id); if ($row) { $data = $row["bin_data"]; $type = $row["filetype"]; /* * SANDER_BOSMAN_FIX */ $filename = $row["filename"]; $query = "update tbl_binary_data set hits = hits + 1 where id = $id"; $res_id = mysql_query ($query, $conn_id); if (! $res_id) { printf ("MySQL Error: (%d) %s

%s\n", mysql_errno (), mysql_error (), $query); mysql_close ($conn_id); exit (); } mysql_close ($conn_id); /* * SANDER_BOSMAN_FIX */ Header ("Content-disposition: filename=".$filename); Header ("Content-type: $type"); echo $data; exit (); } else { printf ("There were no rows found with id = %d\n", $id); mysql_close ($conn_id); } } printf ("\n"); printf ("\n"); printf ("File Upload\n"); printf ("\n"); printf ("\n"); printf ("

\n"); printf ("This is my test page for sending files to and getting files from a mysql database with php4.\n"); printf ("

\n"); printf ("

\n"); printf ("Click Here to view the source.\n"); printf ("

\n"); if ($submit == 'Upload File') { printf ("

\n"); printf ("Your file %s was successfully uploaded.
\n", $input_file_name); $file_size = filesize ($input_file); $fp = fopen ($input_file, 'r'); $data = addslashes (fread ($fp, $file_size)); fclose ($fp); unlink ($input_file); mysql_connect ('localhost', 'username', 'password'); mysql_select_db ('database'); $res_id = mysql_query ("insert into tbl_binary_data values ( 0, '$description', '$data', '$input_file_name', '$input_file_size', '$input_file_type', '0' )"); $new_id = mysql_insert_id (); /* * MICHAEL_VINCE_FIX * the following line was mysql_close ($conn_id); */ mysql_close (); if ($new_id > 0) { printf ("Database id for your file: %s
\n", $new_id); } else { printf ("Your file was not successfully inserted!\n"); } printf ("

\n"); } printf ("

\n"); printf ("*** Send File ***\n"); printf ("

\n"); printf ("

\n"); printf ("

\n"); printf ("\n"); printf ("File description:   \n"); printf ("
\n"); printf ("File name:   \n"); printf ("
\n"); printf ("\n"); printf ("
\n"); printf ("

\n"); printf ("

\n"); printf ("*** Retrieve File ***\n"); printf ("

\n"); printf ("

\n"); printf ("

\n"); printf ("Database Id:   \n"); printf ("
\n"); printf ("\n"); printf ("
\n"); printf ("

\n"); printf ("\n"); printf ("\n"); ?> ----- Original Message ----- From: "Sundar" To: Sent: Monday, February 10, 2003 4:16 PM Subject: Re: Inserting a text file to MySQL > Thanks David, > > When you say > > insert into foo ( [contents of file]); > > Does it mean > > insert into foo ( filename ); > > I am just trying to achieve it with a SQL query. > > - Sundar > > > David A. Sinck wrote: > > >\_ SMTP quoth Sundar on 2/10/2003 10:26 as having spake thusly: > >\_ > >\_ Hi, > >\_ > >\_ I am retrieving some text files from our Oracles server and been asked > >\_ to populate some feasible local server. So, obviously I selected MySQL, > >\_ though I haven't personally used it much. Now, I have a problem. How do > >\_ I store a text file in MySQL? > > > >create table foo ( > > thefile text > >); > > > >insert into foo ( [contents of file]); > > > >YMMV. There's also 'longtext' and 'verylongtext' IIRC. > > > >David > >--------------------------------------------------- > >PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us > >To subscribe, unsubscribe, or to change you mail settings: > >http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss > > > > > > > --------------------------------------------------- > PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us > To subscribe, unsubscribe, or to change you mail settings: > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss >