php常用的连接MySQL以及delete例程如下:

<?php
define('DB_HOST', '127.0.0.1');
define('DB_USER', 'root');
define('DB_PASS', '123456');
define('DB_DATABASENAME', 'testdb');
define('DB_TABLENAME', 'gamedata');
//MySQL_connect
$conn = MySQL_connect('DB_HOST', DB_USER, DB_PASS) or die("connect failed" . MySQL_error());
MySQL_query("set names utf8");//设置数据库使用的编码方式
MySQL_select_db('DB_DATABASENAME', $conn);
$sql = "delete from gamedata where userid=1057";
$result = MySQL_query($sql, $conn);
if(!$result){echo "删除数据异常". MySQL_error();}
MySQL_close($conn);
?>

Related Posts: PHP-MySQL-delete例句 :