mysql_select_db('code1');
mysql_query("set names'utf8'");
$result = mysql_query('select*from user limit1');
$row = mysql_fetch_assoc($result);
print_r($row);
//接上面的代码
mysql_query("set names'utf8'");
$result = mysql_query('select*from user limit1');
$row = mysql_fetch_assoc($result);
print_r($row);
//接上面的代码
2017-03-19
<?php
//多个连接数据库
$link1 = mysql_connect('127.0.0.1','code1','');
$link2 = mysql_connect('127.0.0.1','code1','',true);
//开启一个新的连接
$res = mysql_query('select * from user limit 1', $link1); //从第一个连接中查询数据
mysql_connect('127.0.0.1', 'code1', '');
mysql_select_db('code1');
mysql_query("set names 'utf8'");
//多个连接数据库
$link1 = mysql_connect('127.0.0.1','code1','');
$link2 = mysql_connect('127.0.0.1','code1','',true);
//开启一个新的连接
$res = mysql_query('select * from user limit 1', $link1); //从第一个连接中查询数据
mysql_connect('127.0.0.1', 'code1', '');
mysql_select_db('code1');
mysql_query("set names 'utf8'");
2017-03-19
implode('',数组)是将数组的值拆分开来组合成字符串形式展示;第一个参数就是以什么样的链接符显示比如说数组:
$arr = array("苹果","香蕉","柿子");
$result = implode('__',$arr);//结果为:苹果__香蕉__柿子
echo $result;
$result1 = explode(',',$result);将$result这个字符串,转换为数组,并且以逗号隔开
echo $result1;//将字符串以逗号的形式隔开,变为数组
$arr = array("苹果","香蕉","柿子");
$result = implode('__',$arr);//结果为:苹果__香蕉__柿子
echo $result;
$result1 = explode(',',$result);将$result这个字符串,转换为数组,并且以逗号隔开
echo $result1;//将字符串以逗号的形式隔开,变为数组
2017-03-18
if (!preg_match('/^\w+(\.\w+)*@\w+\.\w+(\.\w+)*/',$user['email'])){
die('邮箱不合法');
}
die('邮箱不合法');
}
2017-03-17
$fruit["0"] = "苹果";
$fruit["1"] = "香蕉";
print_r($fruit["0"]);
print_r($fruit["1"]);
echo "<br/>";
$arr = array('0'=>'苹果','1'=>'香蕉');
$arr0 = $arr['0'];
$arr1 = $arr['1'];
print_r($arr0);
print_r($arr1);
$sg = array("苹果","凤梨");
foreach($sg as $k=>$v){
print_r("<br/>".$k."=>".$v);
}
$fruit["1"] = "香蕉";
print_r($fruit["0"]);
print_r($fruit["1"]);
echo "<br/>";
$arr = array('0'=>'苹果','1'=>'香蕉');
$arr0 = $arr['0'];
$arr1 = $arr['1'];
print_r($arr0);
print_r($arr1);
$sg = array("苹果","凤梨");
foreach($sg as $k=>$v){
print_r("<br/>".$k."=>".$v);
}
2017-03-17