Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP/MySQL-有时会将一个空白条目添加到表中_Php_Mysql - Fatal编程技术网

PHP/MySQL-有时会将一个空白条目添加到表中

PHP/MySQL-有时会将一个空白条目添加到表中,php,mysql,Php,Mysql,下面的代码允许我的用户将项目($site)添加到表($find)中。它工作得很好。但每隔一段时间,它会在用户添加的值之外,向表中添加一个空白值 你知道为什么吗 提前感谢, 约翰 您应该检查以确保用户确实输入了一些内容 大致如下: if(trim($find) && trim($site)) { mysql_query("INSERT INTO `$find` VALUES (NULL, '$site',1,0)"); } else { print "You must en

下面的代码允许我的用户将项目($site)添加到表($find)中。它工作得很好。但每隔一段时间,它会在用户添加的值之外,向表中添加一个空白值

你知道为什么吗

提前感谢,

约翰


您应该检查以确保用户确实输入了一些内容

大致如下:

if(trim($find) && trim($site)) {
  mysql_query("INSERT INTO `$find` VALUES (NULL, '$site',1,0)");
} else {
  print "You must enter values!";
}

我想你把下面这句话倒着发了“$\u GET['find']=$find;”
<?
$remove_array = array('http://www.', 'http://', 'https://', 'https://www.', 'www.');
$site = str_replace($remove_array, "", $_POST['site']);
$site = strtolower($site);

function check_porn_terms($input){
     $porn_terms = array(here are a lot of swear words and porn terms); //add terms here
     foreach($porn_terms as $term){
          if(substr_count($input, $term) > 0) return false;
     }

     return true;
}


if(!check_porn_terms($_POST['site']))
{

   session_write_close();
   header("Location:http://www.site.com/index.php");
   exit;

}


mysql_connect("mysqlv10", "username", "password") or die(mysql_error());
mysql_select_db("bookfeather") or die(mysql_error());

$_GET['find'] = $find;
$find = urldecode($find);
$find = mysql_real_escape_string($find);

$site = mysql_real_escape_string($site);
$illegal = array("/", "\"");
$site = str_replace($illegal, '', $site);

mysql_query("INSERT INTO `$find` VALUES (NULL, '$site',1,0)");
?>
if(trim($find) && trim($site)) {
  mysql_query("INSERT INTO `$find` VALUES (NULL, '$site',1,0)");
} else {
  print "You must enter values!";
}