Database Tutorial

Course Tutorial Site

Site Admin

MySQL and PHP

with 18 comments

This page demonstrates how to upload, store, and manage Text (Character Large Data Streams) and BLOBs (Binary Large Objects). It provides MySQL equivalent instructions to those for manaing LOBs in an Oracle database. As covered in Chapter 8 in my Oracle Database 11g PL/SQL Programming book.

Before you begin these steps, you should have already installed Zend Server Community Edition. If you haven’t done so, please click here for instructions.

If you find any problems, please let me know. I’ll be happy to fix them.

Written by michaelmclaughlin

September 28th, 2009 at 11:39 pm

Posted in

18 Responses to 'MySQL and PHP'

Subscribe to comments with RSS or TrackBack to 'MySQL and PHP'.

  1. […] the mysqli_stmt_store_results($stmt); function (line number 76 in the program snippet below from source) between the execute and bind result […]

  2. A few of the downloads return a 404 and don’t work

    Aaron Haggen

    29 Mar 10 at 2:50 pm

  3. The ConvertBlobToImage needs to be renamed to ConvertMySQLBlobToImage or else the code won’t load the right file. It will try to use the Oracle version.

    Daren J.

    29 Mar 10 at 8:24 pm

  4. There are two files, not one. They’re both named correctly in the zip files.

    michaelmclaughlin

    29 Mar 10 at 9:45 pm

  5. I believe these are all resovled now.

    michaelmclaughlin

    29 Mar 10 at 9:53 pm

  6. The video scripts linked here don’t work for half of what they are trying to do

    Andrew T.

    30 Mar 10 at 9:52 am

  7. What video scripts? There are only screen shots.

    michaelmclaughlin

    30 Mar 10 at 12:07 pm

  8. You have mislabeled the required name for the Blob Conversion php script. The htm form is calling ConvertMySQLBlobToImage, but you labeled it ConvertBlobToImage.

    Skyler

    30 Mar 10 at 1:06 pm

  9. Skyler, I believe it’s fixed now. If I missed it somewhere else, please let me know.

    michaelmclaughlin

    1 Apr 10 at 12:17 pm

  10. for the create script i had to add a “SET FOREIGN_KEY_CHECKS = 0;” to get it to work. otherwise it had problems with foreign key conflicts. is this the correct approach, or is there a better way to handle it?

    jason

    9 Dec 10 at 1:26 pm

  11. The item table does not show Harry Potter 3 in it, just the first one. I don’t know if this is intentional or if we’re using a different seed file than you did when you created this.

    Mike Westover

    26 Mar 11 at 6:31 pm

  12. You just add the row.

    michaelmclaughlin

    2 May 11 at 10:58 am

  13. I’ve run into an interesting couple of problems. When trying to upload the picture, I get the following two errors.

    Error 1:

    Warning: main(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in C:Program Files (x86)ZendApache2htdocsmysqllobUploadItemBlobMySQL.php on line 62

    I was able to fix this line by adding the following line to the UploadItemBlobMySQL.php file:

    date_default_timezone_set('MST');

    Here was the second error:

    Fatal error: Call to undefined function mysqli_send_long_data() in C:Program Files (x86)ZendApache2htdocsmysqllobUploadItemBlobMySQL.php on line 62

    I haven’t been able to figure this error out yet…

    Cody Conder

    4 Apr 13 at 12:16 am

  14. Cody, The solution is on this post on my technical blog. As to the mysqli_send_long_data it was deprecated in PHP 5.3 and eliminated in PHP 5.4. I’ll need to write a new code module for those releases – great catch!

    michaelmclaughlin

    18 Mar 14 at 11:21 am

  15. Jason, That’s covered in the Lesson #2: Creating Tables web page under the Re-runnable Referential Integrity Scripts segment.

    michaelmclaughlin

    22 Oct 14 at 2:03 am

  16. Hurrah! After all I got a blog from where I can genuinely take valuable facts regarding my study and knowledge.

    ve may bay

    11 Mar 15 at 4:17 am

  17. UploadItemBlobMySQL.php

    Line 61 Changed from

    while ($start < strlen($item_blob)) {
            mysqli_send_long_data($stmt,0,substr($item_blob,$start,$chunk));
            $start += $chunk;
    }

    TO

    while ($start send_long_data(0,substr($item_blob,$start,$chunk));
            $start += $chunk;
    }

    Tyler Nelson

    6 Apr 15 at 3:48 pm

  18. Change in the code, but using procedural methods.

    michaelmclaughlin

    6 Apr 15 at 4:15 pm

Leave a Reply