通过表单错误增加数据库值

时间:2014-02-05 17:07:10

标签: php mysql

我在页面上有一个表单,我提交了一个url,如果我提交了相同的url,它曾经给我一个错误说它是重复的,这是因为我在数据库中创建了唯一的url。

我已经删除了显示错误的回声,所以现在没有任何反应。

我正在尝试而不是做任何事情来将列值增加1

例如

如果我使用我的表单提交两次网址,那么价值会上升一个

我的桌子

id | url           | status | count |
1  | example1.com  |  1     | 1     |
2  | example2.com  |  1     | 3     |

这是用于向我提供消息的代码

 $retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
//end
echo "fuk it";
mysql_close($conn);
}
else
{

我希望尝试让行die('Could not enter data: ' . mysql_error());将列数增加1

这甚至可能吗?

我用来输入表单的sql如下

$sql = "INSERT INTO site".
       "(url, status) ".
       "VALUES('$url','$curl')ON DUPLICATE KEY UPDATE site SET count=count+1";

0 个答案:

没有答案