hi all,

I have been trying to insert images into my mysql database thru PHP  for the
past 2 days without any luck.. After having tried various combinations of
queries, I gave up..

Wud be grateful if anyone can post a query for inserting images in to my
database..

TIA,
Sandeep


This is what i hv tried:

<HTML>
<HEAD>
<TITLE>Binary Data Insert Form</TITLE>
</HEAD>

<BODY>
<H1>Upload a File:</H1>

<FORM enctype="multipart/form-data"
 method="post" action="do_insert.php">
<INPUT type="file" name="img1" size="30">
<INPUT type="submit" name="submit"
 value="Use this File">

</FORM>
</BODY>
</HTML>

__________________________________________________________
<?
if (!isset($img1)) {
header("Location: insert_file.html");
exit;
}

$db = @mysql_connect("localhost","root","sandeep") or
die("Can't connect to server.");
@mysql_select_db("yourDB", $db) or
die("Can't select database.");

$binary_junk = addslashes (fread(fopen($img1, "r"), filesize($img1)));
$insert_data = "INSERT INTO
images (img_id, binary_junk, filename, filesize, filetype)
VALUES ('1', '$binary_junk', '$img1_name', '$img1_size', '$img1_type')";

@mysql_query($insert_data) or

The error is occuring here , am getting a "couldnt insert data error"

die("Couldn't insert data.");

?>



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to