Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.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-MySQL_error():提供的参数不是有效的MySQL链接资源_Php_Mysql_Phpmyadmin - Fatal编程技术网

PHP/MySQL-MySQL_error():提供的参数不是有效的MySQL链接资源

PHP/MySQL-MySQL_error():提供的参数不是有效的MySQL链接资源,php,mysql,phpmyadmin,Php,Mysql,Phpmyadmin,有上百个问题都与这个错误有关。每一个我都经历过…两次 在过去的一年里,我一直在用PHP和MySQL开发一个非常健壮的客户机管理系统,我已经接近尾声了。这个错误时不时出现,让我发疯 我还有另外三个例子,说明这段代码在我的网站的其他部分可以完美地工作。我复制并发布到一个新页面,更改了一些变量,MySQL毫无疑问地说要检查引号,我的版本可能是错误的。我在拔头发……请帮帮我 // Update existing contact list if(count($_POST['existing_contact

有上百个问题都与这个错误有关。每一个我都经历过…两次

在过去的一年里,我一直在用PHP和MySQL开发一个非常健壮的客户机管理系统,我已经接近尾声了。这个错误时不时出现,让我发疯

我还有另外三个例子,说明这段代码在我的网站的其他部分可以完美地工作。我复制并发布到一个新页面,更改了一些变量,MySQL毫无疑问地说要检查引号,我的版本可能是错误的。我在拔头发……请帮帮我

// Update existing contact list
if(count($_POST['existing_contact']) > 0){
    foreach ($_POST['existing_contact'] as $exist_contact) {
        mysql_query("UPDATE `contact_lists` SET
            contact_lists.sequence = '".mysql_real_escape_string($exist_contact['sequence'])."' ,
            contact_lists.name = '".mysql_real_escape_string($exist_contact['name'])."' ,
            contact_lists.primary_phone = '".mysql_real_escape_string($exist_contact['primary_type'])."' ,
            contact_lists.primary_type = '".mysql_real_escape_string($exist_contact['primary_type'])."' ,
            contact_lists.secondary_phone = '".mysql_real_escape_string($exist_contact['secondary_phone'])."' ,
            contact_lists.secondary_type = '".mysql_real_escape_string($exist_contact['secondary_type'])."' ,
            contact_lists.panel_code = '".mysql_real_escape_string($exist_contact['panel_code'])."' ,
            contact_lists.password = '".mysql_real_escape_string($exist_contact['contact_password'])."' 
            WHERE `id` = ".mysql_real_escape_string($exist_contact['contact_identifier'])."")
            or die(mysql_error("<font size='-1' face='Verdana, Geneva, sans-serif'>Can't connect to MySQL. Please try again.</font>"));
    };
};
我发誓,这段带有不同变量的代码在我整个站点的其他两三个位置运行。如果你能在这里看到任何不寻常的东西,请给我指出正确的方向。谢谢

编辑------

这是复制和粘贴的原始代码。(当然,有可变的变化)

//更新现有区域列表
如果(计数($_POST['existing_zone'])>0){
foreach($\u POST['existing\u zone']作为$exist\u zone){
如果($exist_zone['zone_exists']==TRUE){$zone_exists_checked=“1”}否则{$zone_exists_checked=“0”};
mysql_查询(“更新`zone_列表`SET
zone_lists.zone_number='”.mysql_real_escape_string($exist_zone['zone_number'])。“,
zone_lists.zone_description='”.mysql_real_escape_string($exist_zone['zone_description'])。“,
zone_lists.zone_existing='.mysql_real_escape_string($zone_exists\u checked)。“'
其中`id`=”.mysql\u real\u escape\u string($exist\u zone['zone\u list\u identifier'])。“”)
或者死亡(mysql_错误(“无法连接到mysql。请重试”);
};
};
仅将资源作为其参数(使用
mysql\u connect()
创建的资源)。您试图提供一个字符串

你可能在其他地方工作过:


或死亡(“无法连接到MySQL,请重试”)

已解决。

好吧,就这样吧


这段代码中的一切都很好。原来,
WHERE
子句中的变量是空的,因为有一个字母输入错误。我在上一页的表格中用了“接触”而不是“接触”。我开始用静态信息替换所有变量,并在每次重新插入变量时运行代码。

从什么时候开始,phpmyadmin允许您在其查询控制台中运行PHP?我取出所有额外的内容,并从UPDATE或我试图运行的任何命令开始。我去掉了mysql\u错误,但问题仍然存在。现在所不同的是,这是我的通用“无法连接”消息,它告诉我一些错误,而不是以前发布的MySQL错误。@那么,打印实际的MySQL\u错误而不是通用的“无法连接”如何?
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以了解第10行“”附近使用的正确语法您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以了解第10行“”附近使用的正确语法您的SQL语法有错误;查看与MySQL服务器版本相对应的手册,了解第10行“”附近要使用的正确语法。。。我用静态信息替换了所有变量,并尝试运行它,结果成功了。这可能是因为某些特定的数据吗?数据类型还是什么?是的,它肯定是。自从我使用了
ext/mysql
(或者
Mysqli
)以来,这已经是一段漫长的时间了,尽管我可能不是最好的详细说明。
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sequence']).&quot;' ,
                                     contact_lists.name = '&quot;.mysql_real_escape_string($ex' at line 2
// Update existing zone list
if(count($_POST['existing_zone']) > 0){
    foreach ($_POST['existing_zone'] as $exist_zone) {
        if($exist_zone['zone_exists'] == TRUE) { $zone_exists_checked = "1"; } else { $zone_exists_checked = "0"; };
        mysql_query("UPDATE `zone_lists` SET
                                    zone_lists.zone_number = '".mysql_real_escape_string($exist_zone['zone_number'])."' ,
                                    zone_lists.zone_description = '".mysql_real_escape_string($exist_zone['zone_description'])."' ,
                                    zone_lists.zone_existing = '".mysql_real_escape_string($zone_exists_checked)."'
                                    WHERE `id` = ".mysql_real_escape_string($exist_zone['zone_list_identifier'])."")
            or die(mysql_error("<font size='-1' face='Verdana, Geneva, sans-serif'>Can't connect to MySQL. Please try again.</font>"));
    };
};