以下 PHP 代码为何SQL语句没有执行成功?
<?php$mysql=newMysql();$mysql->sql("DELETEFROMwatching_userWHEREname='233')");classMy...
<?php
$mysql = new Mysql();
$mysql->sql("DELETE FROM watching_user WHERE name = '233' )");
class Mysql {
private $con = null;
function __construct () {
$con = mysql_connect("localhost","love_sql","8JSczHsZJB");
if (!$con) {
die(mysql_error());
}
}
function sql ($sql) {
mysql_select_db("love_sql", $con);
if (mysql_query($sql)) {
echo 1;
} else {
echo 2;
}
}
}
?> 展开
$mysql = new Mysql();
$mysql->sql("DELETE FROM watching_user WHERE name = '233' )");
class Mysql {
private $con = null;
function __construct () {
$con = mysql_connect("localhost","love_sql","8JSczHsZJB");
if (!$con) {
die(mysql_error());
}
}
function sql ($sql) {
mysql_select_db("love_sql", $con);
if (mysql_query($sql)) {
echo 1;
} else {
echo 2;
}
}
}
?> 展开
2个回答
2017-02-03
展开全部
有mysql_error可以获取到最后一次的错误,你答应出来看看。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询