1 $datetoday = date('Y-m-d'); 2 $datetime = $thedate; 3 $data_info = $data; 4 5 $db = array( 6 'dsn' => 'mysql:host=192.168.1.111;dbname=wz_action', 7 'host' => '192.168.1.111', 8 'dbname' => 'wz_action', 9 'username' => 'root', 10 'password' => '123456', 11 'charset' => 'utf8', 12 'port' => '3306', 13 ); 14 //建立连接 15 $link = mysql_connect($db['host'], $db['username'], $db['password']) or die( 'Could not connect: ' . mysql_error ()); 16 //选择数据库 17 mysql_select_db($db['dbname'], $link) or die ( 'Can\'t use foo : ' . mysql_error ($link)); 18 // 设置字符集 19 mysql_set_charset($db['charset'], $link); 20 21 // 删除数据 22 mysql_query("delete from calendar where datetoday = '{$datetime}'"); 23 // 保存数据 24 $exec="insert into calendar(datetoday,datetime,data_info) values('$datetoday','$datetime','$data_info')"; 25 $result=mysql_query($exec); 26 // 查询语句 27 $sel_sql = "select datetoday from calendar where datetime = '{$thedate}'"; 28 $res = mysql_query($sel_sql); 29 $timeArr = mysql_fetch_array($res,MYSQL_NUM);
php 操作数据库
猜你喜欢
转载自www.cnblogs.com/ysx215/p/9052418.html
今日推荐
周排行