「ファイルをBLOBフィールドに挿入する方法」の編集履歴(バックアップ)一覧はこちら
「ファイルをBLOBフィールドに挿入する方法」の最新版変更点
追加された行はこの色になります。
削除された行はこの色になります。
-<?php - + <?php + /* Test script to upload a file and store in a BLOB field */ - + $localfile = file_get_contents("/home/shuichi/9500.txt"); /* Connect to MySQL */ $link = mysql_connect("localhost:5015","root","") or die("Could not connect"); /* Select Database */ mysql_select_db("test") or die("Could not select DB"); /* Print the value before escape */ echo ("Before escape:\t"); echo bin2hex($localfile); print ("<br>\n"); /* Escape the file */ $escapedfile = mysql_real_escape_string($localfile); /* Print the values after escape */ echo ("After escape:\t"); echo bin2hex($escapedfile); /* Set character set to cp932 */ //mysql_query ("SET NAMES cp932"); /* Insert into BLOB table CREATE TABLE `blob_tbl` ( `c1` BLOB ) ENGINE = MyISAM DEFAULT CHARSET = cp932; */ $result = mysql_query ("INSERT INTO blob_tbl (c1) select '$escapedfile'") or die ("invalid query" . mysql_error(). "\n"); /* Close the connection */ mysql_close($link); ?>
このwikiの更新情報RSS