PHP½«Í¼Æ¬´æÈëMYSQL
ÍêÕûµÄʵÏÖÁËPHP½«Í¼Æ¬´æÈëMYSQL
ǰÌ᣺
1 Ê×ÏȱØÐëÓµÓÐPHPµÄÔËÐл·¾³£¬ÁíÍ⻹µÃÓÐMYSQLÊý¾Ý¿â
2 Èç¹ûÎļþ²»ÄÜÉÏ´«³É¹¦Çë¼ì²épicsÊÇ·ñÊÇ¿ÉдµÄȨÏÞ
Ê×ÏÈÏȰÑpic2db.rarÎļþ½âѹµ½PHP¿ÉÒÔÔËÐÐĿ¼Ï¡£
Æä´ÎÔÚMYSQLÖн¨Á¢Ò»¸öÊý¾Ý¿â:pic2db,È»ºóÔÚ¸ÃÊý¾Ý¿âϽ¨Á¢Ò»¸ö±í£¬±í½á¹¹Îª£º
CREATE TABLE `pic` (
`pic_id` int(11) NOT NULL auto_increment,
`pic_userid` int(11) NOT NULL,
`pic_content` longblob NOT NULL,
PRIMARY KEY (`pic_id`)
)
ÔÙ½Ó×ÅÐÞ¸Äcommon_db.phpÖеÄÊý¾Ý¿âÁ¬½ÓµÄÓû§ÃûºÍÃÜÂ룬¸ù¾ÝÄãMYSQLÉèÖõÄÀ´
×îºóÔËÐÐupload.phpÎļþ½øÐÐÉÏ´«£¬¶ødisplay_all.phpÊÇÏÔʾÊý¾Ý¿âÖÐËùÓеÄͼƬ
ͼƬÉÏ´«upload.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÉÏ´«</title>
</head>
<body>
<form action="post_action.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<p> </p>
<p>
<label></label>
<label>
<input type="file" name="file" />
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="Ìá½»" />
</label>
</p>
<p> </p>
</form>
</body>
</html>
Á¬½ÓÊý¾Ý¿âµÄcommon_db.php:
<?php
/**
* Á¬½ÓÊý¾Ý¿âµÄº¯Êý
* Á¬½Ó³É¹¦½«»á·µ»ØÒ»¸öÁ¬½Ó×ÊÔ´
* @return mix
*/
function getLink() {
$link = mysql_connect("localhost","root","") or die("Êý¾Ý¿â·þÎñÆ÷Á¬½Óʧ°Ü!");
if(!mysql_select_db("crm",$link)) die("Êý¾Ý¿âÁ¬½Óʧ°Ü!");
return $link;
}
?>
´¦ÀíÉÏ´«µÄpost_action.php:
<?php
/**
* ±¾ÎļþÊǽ«Í¼Æ¬ÎļþÉÏ´«µ½·þÎñÆ÷¶Ë
* ²¢ÇÒ¶ÁÈ¡¸ÃÎļþµÄ¶þ½øÖÆÄÚÈÝ´æÈëµ½MYSQLµÄ
* pic±íÖÐlongblob×Ö¶Î
*
*/
//Ç¿ÖÆÒ³ÃæÊ¹ÓÃgb2312±àÂë
header("Content-Type: text/
Ïà¹ØÎĵµ£º
mysqlÎļþµ¼ÈëÂÒÂëÎÊÌâµÄ½â¾ö£º
1 ÃüÁî²ì¿´×Ö·ûÉèÖá£
mysql> show variables like "%char%";
2 ½«²»ÊÇutf-8µÄ¶¼¸Ä³Éutf8¡£Ö»ÓÐfilesystem²»±ä;
| Variable_name | Value
&nb ......
ÕâÊÇÎÒдµÄµÚÒ»¸ö¼ÆÊýÆ÷
<?
$s_ht="127.0.0.1";
$s_user="root";
$s_pas="123456";
$s_data="ceshi";
if (empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$myip = $_SERVER['REMOTE_ADDR'];
$myip = $_SERVER['REMOTE_ADDR'];
}
else {
$myip = explode(',', $_SERVER['HTTP_X_FORWA ......
1£¬Äê-ÔÂ-ÈÕ
echo date('Y-m-j');
2007-02-6
echo date('y-n-j');
07-2-6
´óдY±íʾÄêËÄλÊý×Ö£¬¶øÐ¡Ð´y±íʾÄêµÄÁ½Î»Êý×Ö£»
Сдm±íʾÔ·ݵÄÊý×Ö(´øÇ°µ¼)£¬¶øÐ¡Ð´nÔò±íʾ²»´øÇ°µ¼µÄÔ·ÝÊý×Ö¡£
echo date('Y-M-j');
2007-Feb-6
echo date('Y-m-d');
2007-02-06
´óдM±íʾÔ·ݵÄ3¸öËõд×Ö·û£¬¶øÐ¡Ð´mÔò±íÊ¾Ô ......
ÕâÁ½ÌìÎÒ×°ÁËUBUNTU £¬ÔÚ±àÒë°²×°MYSQLµÄʱºòûÓгöʲôÎÊÌ⣬
µ½scripts/mysql_install_db --user=mysql
ÕâÒ»²½Ê±£¬µÃµ½ÈçÏ´íÎó
FATAL ERROR: Can't find mysqld. Please specify your installation
directory with the '--basedir=' option.
FATAL ERROR: Could not find SQL file '/fill_help_tables.sql'
µ½ÍøÉ ......