Koozali.org: home of the SME Server

BLOB data in mysql

nottely

BLOB data in mysql
« on: May 03, 2005, 06:41:51 AM »
Hi all,
Can any one tell me why I can’t post BLOB (pics, zip, etc... files) in mysql on 6.0.1-01?

The script I’m using is:

-------------------------------------------------------------------------------------------------------
[code]
<html>
<head><title>Store binary data into SQL Database</title></head>
<body>

<?php
// code that will be executed if the form has been submitted:

if ($submit) {

    // connect to the database
    // (you may have to adjust the hostname,username or password)

    MYSQL_CONNECT("localhost","root","password");
    mysql_select_db("binary_data");

    $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));

    $result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
        "VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");

    $id= mysql_insert_id();
    print "<p>This file has the following Database ID: <b>$id</b>";

    MYSQL_CLOSE();

} else {

    // else show the form to submit new data:
?>

    <form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
    File Description:<br>
    <input type="text" name="form_description"  size="40">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000">
    <br>File to upload/store in database:<br>
    <input type="file" name="form_data"  size="40">
    <p><input type="submit" name="submit" value="submit">
    </form>

<?php

}
[code]
I have used this script on red hat server without error.


I’ve also tried adding with phpmyadmin and nothing.
There are no errors what so ever.

I can add text and number with out a problem. It’s just like when it sees the binary data it passes it over and adds everything else.

My configuration is the default one. I haven’t changed anything. [code][/code]

Olsen

BLOB data in mysql
« Reply #1 on: May 04, 2005, 06:34:48 PM »
Nottely,

I have also tried to add Blob (images) to mySQL, on SME, but I have not gotten it to work either, you are not alone....

Offline dmajwool

  • *****
  • 180
  • +0/-0
BLOB data in mysql
« Reply #2 on: May 04, 2005, 11:29:56 PM »
Quote

My configuration is the default one. I haven’t changed anything.


By default, SME doesn't allow user access to MySql - you need to grant some privileges along the lines of

Code: [Select]
grant all privileges on *.* to user@localhost identified by 'password' with grant option;
flush privileges;


HTH, David.