Php 如果包含某些不起作用的内容,请删除mysql行

Php 如果包含某些不起作用的内容,请删除mysql行,php,mysql,mysqli,sql-like,Php,Mysql,Mysqli,Sql Like,我正在使用以下脚本从我的留言簿中清除垃圾邮件链接,如果我将查询复制并通过phpmyadmin,它就可以正常工作,如果我在浏览器中运行以下脚本并保存为php文件,我会收到错误“无法执行查询:”。我已经看过了,看不出静脉注射有什么不对,有人能看到明显的静脉注射遗漏了什么吗 <?php // Checks to see if the key value is set if (isset($_GET['key'])) { $key = $_GET['key'

我正在使用以下脚本从我的留言簿中清除垃圾邮件链接,如果我将查询复制并通过phpmyadmin,它就可以正常工作,如果我在浏览器中运行以下脚本并保存为php文件,我会收到错误“无法执行查询:”。我已经看过了,看不出静脉注射有什么不对,有人能看到明显的静脉注射遗漏了什么吗

    <?php
    // Checks to see if the key value is set
    if (isset($_GET['key'])) {
        $key = $_GET['key'];
    }
    // If the key value isnt set give it a value of nothing
    else
    {$key = '';}

    // Checks to see if the key value is valid to authenticate the user
    if ($key == 'keycode'){
    // If the key value is correct the user is granted access
    $con = mysql_connect("localhost","user","password");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    // Select mysql db
    mysql_select_db("towerroa_TRA", $con);
    mysqli_query($con, "DELETE FROM `itsnb_phocaguestbook_items` WHERE `content` LIKE '%<a%'")or die ("Couldn't execute query: ".mysqli_error());

    echo 'Spam Purged !';
    }
    else {
    // Denies the user access if the key value isnt correct 
    echo '<h1>Access Denied !</h1>';}

问题是你把
mysql\uu
mysqli\u
搞混了。尝试修复下面的问题

mysqli_connect("localhost","user","password");
mysqli_select_db("towerroa_TRA", $con);
mysqli_query($con, "DELETE FROM `itsnb_phocaguestbook_items` WHERE `content` LIKE '%<a%'")or die ("Couldn't execute query: ".mysqli_error());
mysqli_connect(“本地主机”、“用户”、“密码”); mysqli_select_db(“towerroa_TRA”$con);
mysqli_query($con,“从`itsnb_phocaguestbook_items`中删除`content`如'%问题是您将
mysql\u和
mysqli\u
混为一谈。请尝试修复以下问题

mysqli_connect("localhost","user","password");
mysqli_select_db("towerroa_TRA", $con);
mysqli_query($con, "DELETE FROM `itsnb_phocaguestbook_items` WHERE `content` LIKE '%<a%'")or die ("Couldn't execute query: ".mysqli_error());
mysqli_connect(“本地主机”、“用户”、“密码”); mysqli_select_db(“towerroa_TRA”$con);
mysqli_query($con),从'itsnb_phocaguestbook_items'中删除'content',如“%用
mysqli.*
替换所有
mysqli.*
函数

mysqli_select_db("towerroa_TRA", $con);
应该是

mysqli_select_db($con,"towerroa_TRA");
应该是

mysqli_select_db($con,"towerroa_TRA");
试试这个

<?php
// Checks to see if the key value is set
if (isset($_GET['key'])) {
    $key = $_GET['key'];
}
// If the key value isnt set give it a value of nothing
else
{$key = '';}

// Checks to see if the key value is valid to authenticate the user
if ($key == 'keycode'){
// If the key value is correct the user is granted access
$con = mysql_connect("localhost","user","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Select mysql db
mysql_select_db("towerroa_TRA", $con);
mysql_query($con, "DELETE FROM `itsnb_phocaguestbook_items` WHERE `content` LIKE '%<a%'")or die ("Couldn't execute query: ".mysql_error());

echo 'Spam Purged !';
}
else {
// Denies the user access if the key value isnt correct 
echo '<h1>Access Denied !</h1>';}
试试这个

<?php
// Checks to see if the key value is set
if (isset($_GET['key'])) {
    $key = $_GET['key'];
}
// If the key value isnt set give it a value of nothing
else
{$key = '';}

// Checks to see if the key value is valid to authenticate the user
if ($key == 'keycode'){
// If the key value is correct the user is granted access
$con = mysql_connect("localhost","user","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Select mysql db
mysql_select_db("towerroa_TRA", $con);
mysql_query($con, "DELETE FROM `itsnb_phocaguestbook_items` WHERE `content` LIKE '%<a%'")or die ("Couldn't execute query: ".mysql_error());

echo 'Spam Purged !';
}
else {
// Denies the user access if the key value isnt correct 
echo '<h1>Access Denied !</h1>';}

那么您不能执行查询的错误是什么呢?另外,您到处都在使用不推荐使用的
mysql\uu
函数,除了
mysqli\u查询
部分。将所有内容都更改为
mysql\u*
查询或
mysqli\u*
查询。强烈建议使用
mysqli\u
函数!有趣的是没有错误,只要t它无法执行查询。请尝试使用$con=mysql\u connect(“localhost”、“user”、“password”)代替$con=mysql\u connect(“localhost”、“user”、“password”)或die(mysql\u error())-这会给您带来任何错误吗?您的代码中的mysqli_查询是要成为mysql_查询吗?您不能执行查询中的错误是什么?此外,您到处都在使用不推荐使用的
mysql_
函数,除了
mysqli_查询
部分。将所有内容更改为
mysql_*
查询或
mysqli
查询。强烈建议使用
mysqli\u
。有趣的是,没有错误,只是它无法执行查询。请使用$con=mysql\u connect(“localhost”、“user”、“password”);而不是$con=mysql\u connect(“localhost”、“user”、“password”)或die(mysql\u error())-这是否会给您带来任何错误?您的代码中的mysqli_查询是否打算成为mysql_查询?Iv尝试了这一点,但仍然得到“无法执行查询:”错误消息:-(您是否已三次检查了所有数据库名称、表名和用户/密码等?以及
之后错误消息的部分是什么?Iv尝试了这一点,仍然得到了错误消息“无法执行查询:”错误消息:-(您是否已三次检查了所有数据库名称、表名和用户/密码等?在
)之后,错误消息的部分是什么?Iv尝试了此操作,但仍然得到了“无法执行查询:”错误消息:-(Iv尝试了此操作,仍然得到了“无法执行查询:”错误消息:-(