<?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); ?>
atwikiでよく見られているWikiのランキングです。新しい情報を発見してみよう!
最近アクセスの多かったページランキングです。話題のページを見に行こう!