PHP 中MySQL 连接,查询,更新操作



$this->con = mysql_connect("10.10.0.1:3306","test","test1234");
if (!$this->con){
	die('Could not connect: ' . mysql_error());
}       
$this->db_selected = mysql_select_db("test",$this->con);
mysql_query("set names utf8");

$sql = "select * from kaifu_num where kaifu_id = $kaifu_id limit 1";
$result = mysql_query($sql, $this->con);
if( !$result )
{
	print 'error'.mysql_error();
}
$row = mysql_fetch_array($result);
if (empty($row))
{
	exit("{\"errno\":\"102\",\"errmsg\":\"502\"}");
} 
$num = $row['num'];


$sql = "update kaifu_num set uid = '$user_id' where id = $num_id ";
$result = mysql_query($sql, $this->con);
if( !$result )
{
	print 'error'.mysql_error();
}   


你可能感兴趣的:(PHP 中MySQL 连接,查询,更新操作)