- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
首先祝大家有美好的一天,抱歉,如果这个问题可能非常简单,但我对 php 的了解很少。
我在页面中收到此错误:
*您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“WHERE compagni_id=NULL”附近使用的正确语法*
这是我的代码,它很长,所以我只把开始部分放在我认为可能出现错误的地方。我知道这肯定是一个非常愚蠢的错误,比如缺少逗号或类似的错误,但即使在一些 PHP 代码检查器网站上我也找不到任何东西。
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form_compagni")) {
$updateSQL = sprintf("UPDATE compagni SET av_compagni_numero=%s, av_compagni_tipo01=%s, av_livello_01=%s, av_nome01=%s, av_compagni_tipo02=%s, av_livello_02=%s, av_nome02=%s, anim_taglia01=%s, anim_tipo01=%s, anim_iniz01=%s, anim_velo01=%s, anim_pf01=%s, anim_ca01=%s, anim_ca_sprov01=%s, anim_ca_cont01=%s, anim_atta01=%s, anim_lotta01=%s, anim_spazi01=%s, anim_porta01=%s, anim_atsp01=%s, anim_quali01=%s, anim_temp01=%s, anim_rifl01=%s, anim_volo01=%s, anim_forz01=%s, anim_dest01=%s, anim_cost01=%s, anim_inte01=%s, anim_sagg01=%s, anim_cari01=%s, anim_abil01=%s, anim_tale01=%s, anim_coma01=%s, anim_ogge01=%s, cava_taglia01=%s, cava_tipo01=%s, cava_iniz01=%s, cava_velo01=%s, cava_pf01=%s, cava_ca01=%s, cava_ca_sprov01=%s, cava_ca_cont01=%s, cava_atta01=%s, cava_lotta01=%s, cava_spazi01=%s, cava_porta01=%s, cava_atsp01=%s, cava_quali01=%s, cava_temp01=%s, cava_rifl01=%s, cava_volo01=%s, cava_forz01=%s, cava_dest01=%s, cava_cost01=%s, cava_inte01=%s, cava_sagg01=%s, cava_cari01=%s, cava_abil01=%s, cava_tale01=%s, cava_ogge01=%s, comd_taglia01=%s, comd_tipo01=%s, comd_iniz01=%s, comd_velo01=%s, comd_pf01=%s, comd_ca01=%s, comd_ca_sprov01=%s, comd_ca_cont01=%s, comd_atta01=%s, comd_lotta01=%s, comd_spazi01=%s, comd_porta01=%s, comd_atsp01=%s, comd_quali01=%s, comd_temp01=%s, comd_rifl01=%s, comd_volo01=%s, comd_forz01=%s, comd_dest01=%s, comd_cost01=%s, comd_inte01=%s, comd_sagg01=%s, comd_cari01=%s, comd_abil01=%s, comd_tale01=%s, comd_coma01=%s, comd_ogge01=%s, comr_taglia01=%s, comr_tipo01=%s, comr_iniz01=%s, comr_velo01=%s, comr_pf01=%s, comr_ca01=%s, comr_ca_sprov01=%s, comr_ca_cont01=%s, comr_atta01=%s, comr_lotta01=%s, comr_spazi01=%s, comr_porta01=%s, comr_atsp01=%s, comr_quali01=%s, comr_temp01=%s, comr_rifl01=%s, comr_volo01=%s, comr_forz01=%s, comr_dest01=%s, comr_cost01=%s, comr_inte01=%s, comr_sagg01=%s, comr_cari01=%s, comr_abil01=%s, comr_tale01=%s, comr_coma01=%s, comr_ogge01=%s, fami_taglia01=%s, fami_tipo01=%s, fami_iniz01=%s, fami_velo01=%s, fami_pf01=%s, fami_ca01=%s, fami_ca_sprov01=%s, fami_ca_cont01=%s, fami_atta01=%s, fami_bab01=%s, fami_lotta01=%s, fami_spazi01=%s, fami_porta01=%s, fami_atsp01=%s, fami_quali01=%s, fami_temp01=%s, fami_rifl01=%s, fami_volo01=%s, fami_forz01=%s, fami_dest01=%s, fami_cost01=%s, fami_inte01=%s, fami_sagg01=%s, fami_cari01=%s, fami_abil01=%s, fami_tale01=%s, fami_ogge01=%s, greg_classe01=%s, greg_liv01=%s, greg_razza01=%s, greg_taglia01=%s, greg_iniz01=%s, greg_velo01=%s, greg_pf01=%s, greg_ca01=%s, greg_ca_sprov01=%s, greg_ca_cont01=%s, greg_atta01=%s, greg_bab01=%s, greg_lotta01=%s, greg_spazi01=%s, greg_porta01=%s, greg_atsp01=%s, greg_inca01=%s, greg_inca_classe01=%s, greg_inca_classe01_descr=%s, greg_quali01=%s, greg_temp01=%s, greg_rifl01=%s, greg_volo01=%s, greg_forz01=%s, greg_dest01=%s, greg_cost01=%s, greg_inte01=%s, greg_sagg01=%s, greg_cari01=%s, greg_abil01=%s, greg_tale01=%s, greg_ogge01=%s, greg_descr01=%s, anim_taglia02=%s, anim_tipo02=%s, anim_iniz02=%s, anim_velo02=%s, anim_pf02=%s, anim_ca02=%s, anim_ca_sprov02=%s, anim_ca_cont02=%s, anim_atta02=%s, anim_lotta02=%s, anim_spazi02=%s, anim_porta02=%s, anim_atsp02=%s, anim_quali02=%s, anim_temp02=%s, anim_rifl02=%s, anim_volo02=%s, anim_forz02=%s, anim_dest02=%s, anim_cost02=%s, anim_inte02=%s, anim_sagg02=%s, anim_cari02=%s, anim_abil02=%s, anim_tale02=%s, anim_coma02=%s, anim_ogge02=%s, cava_taglia02=%s, cava_tipo02=%s, cava_iniz02=%s, cava_velo02=%s, cava_pf02=%s, cava_ca02=%s, cava_ca_sprov02=%s, cava_ca_cont02=%s, cava_atta02=%s, cava_lotta02=%s, cava_spazi02=%s, cava_porta02=%s, cava_atsp02=%s, cava_quali02=%s, cava_temp02=%s, cava_rifl02=%s, cava_volo02=%s, cava_forz02=%s, cava_dest02=%s, cava_cost02=%s, cava_inte02=%s, cava_sagg02=%s, cava_cari02=%s, cava_abil02=%s, cava_tale02=%s, cava_ogge02=%s, comd_taglia02=%s, comd_tipo02=%s, comd_iniz02=%s, comd_velo02=%s, comd_pf02=%s, comd_ca02=%s, comd_ca_sprov02=%s, comd_ca_cont02=%s, comd_atta02=%s, comd_lotta02=%s, comd_spazi02=%s, comd_porta02=%s, comd_atsp02=%s, comd_quali02=%s, comd_temp02=%s, comd_rifl02=%s, comd_volo02=%s, comd_forz02=%s, comd_dest02=%s, comd_cost02=%s, comd_inte02=%s, comd_sagg02=%s, comd_cari02=%s, comd_abil02=%s, comd_tale02=%s, comd_coma02=%s, comd_ogge02=%s, comr_taglia02=%s, comr_tipo02=%s, comr_iniz02=%s, comr_velo02=%s, comr_pf02=%s, comr_ca02=%s, comr_ca_sprov02=%s, comr_ca_cont02=%s, comr_atta02=%s, comr_lotta02=%s, comr_spazi02=%s, comr_porta02=%s, comr_atsp02=%s, comr_quali02=%s, comr_temp02=%s, comr_rifl02=%s, comr_volo02=%s, comr_forz02=%s, comr_dest02=%s, comr_cost02=%s, comr_inte02=%s, comr_sagg02=%s, comr_cari02=%s, comr_abil02=%s, comr_tale02=%s, comr_coma02=%s, comr_ogge02=%s, fami_taglia02=%s, fami_tipo02=%s, fami_iniz02=%s, fami_velo02=%s, fami_pf02=%s, fami_ca02=%s, fami_ca_sprov02=%s, fami_ca_cont02=%s, fami_atta02=%s, fami_bab02=%s, fami_lotta02=%s, fami_spazi02=%s, fami_porta02=%s, fami_atsp02=%s, fami_quali02=%s, fami_temp02=%s, fami_rifl02=%s, fami_volo02=%s, fami_forz02=%s, fami_dest02=%s, fami_cost02=%s, fami_inte02=%s, fami_sagg02=%s, fami_cari02=%s, fami_abil02=%s, fami_tale02=%s, fami_ogge02=%s, greg_classe02=%s, greg_liv02=%s, greg_razza02=%s, greg_taglia02=%s, greg_iniz02=%s, greg_velo02=%s, greg_pf02=%s, greg_ca02=%s, greg_ca_sprov02=%s, greg_ca_cont02=%s, greg_atta02=%s, greg_bab02=%s, greg_lotta02=%s, greg_spazi02=%s, greg_porta02=%s, greg_atsp02=%s, greg_inca02=%s, greg_inca_classe02=%s, greg_inca_classe02_descr=%s, greg_quali02=%s, greg_temp02=%s, greg_rifl02=%s, greg_volo02=%s, greg_forz02=%s, greg_dest02=%s, greg_cost02=%s, greg_inte02=%s, greg_sagg02=%s, greg_cari02=%s, greg_abil02=%s, greg_tale02=%s, greg_ogge02=%s, greg_descr02 WHERE compagni_id=%s",
GetSQLValueString($_POST['av_compagni_numero'], "text"),
GetSQLValueString($_POST['av_compagni_tipo01'], "text"),
[...这里继续所有发布信息..]
GetSQLValueString($_POST['greg_ogge02'], "text"),
GetSQLValueString($_POST['greg_descr02'], "text"),
GetSQLValueString($_POST['compagni_id'], "int"));
mysql_select_db($database_Database, $Database);
$Result1 = mysql_query($updateSQL, $Database) or die(mysql_error());
$updateGoTo = "compagni.php?" . $row_compagni['compagni_id'] . "=" . $row_compagni['compagni_id'] . "";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_compagni = "1";
if (isset($_GET['compagni_id'])) {
$colname_compagni = $_GET['compagni_id'];
}
mysql_select_db($database_Database, $Database);
$query_compagni = sprintf("SELECT * FROM compagni WHERE compagni_id = %s", GetSQLValueString($colname_compagni, "int"));
$compagni = mysql_query($query_compagni, $Database) or die(mysql_error());
$row_compagni = mysql_fetch_assoc($compagni);
$totalRows_compagni = mysql_num_rows($compagni);
$colname_compagni = "1";
if (isset($_GET['compagni_id'])) {
$colname_compagni = $_GET['compagni_id'];
}
mysql_select_db($database_Database, $Database);
$query_compagni = sprintf("SELECT * FROM compagni WHERE compagni_id = %s", GetSQLValueString($colname_compagni, "int"));
$compagni = mysql_query($query_compagni, $Database) or die(mysql_error());
$row_compagni = mysql_fetch_assoc($compagni);
?>
我知道代码有点困惑,但我正在使用 Dreamweaver(不幸的是),而他正在编写 php 代码。
哪里出错了?
感谢您耐心阅读所有代码的建议!
最佳答案
追踪 mysql 错误的最佳方法是查看实际错误。在这种情况下:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“WHERE compagni_id=NULL”附近使用的正确语法
因此,我们发现 WHERE ...
附近有一个语法错误,因此我们将查看紧邻字符串之前的内容。如果这对于具有多个联合或联接的长查询不明确,请尝试添加换行符并再次运行查询以获取行号。
因此,错误之前的查询部分是 greg_descr02
。
接下来要做的是look for what the syntax should be以及你实际拥有的东西。
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
哦,我们看到在 WHERE
之前唯一应该出现的是列名,后跟等号,然后是表达式或 DEFAULT。您错过了等号和值。
希望这对您将来有所帮助。
Give a man a fish and he eats for a day, teach a man to fish and he will eat for the rest of his life.
关于php - 我找不到 SQL 和 PHP 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22251361/
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
您好,我正在尝试使用 python 库 pytesseract 从图像中提取文本。请找到代码: from PIL import Image from pytesseract import image_
我的错误 /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference
我已经训练了一个模型,我正在尝试使用 predict函数但它返回以下错误。 Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]])
根据Microsoft DataConnectors的信息我想通过 this ODBC driver 创建一个从 PowerBi 到 PostgreSQL 的连接器使用直接查询。我重用了 Micros
我已经为 SoundManagement 创建了一个包,其中有一个扩展 MediaPlayer 的类。我希望全局控制这个变量。这是我的代码: package soundmanagement; impo
我在Heroku上部署了一个应用程序。我正在使用免费服务。 我经常收到以下错误消息。 PG::Error: ERROR: out of memory 如果刷新浏览器,就可以了。但是随后,它又随机发生
我正在运行 LAMP 服务器,这个 .htaccess 给我一个 500 错误。其作用是过滤关键字并重定向到相应的域名。 Options +FollowSymLinks RewriteEngine
我有两个驱动器 A 和 B。使用 python 脚本,我在“A”驱动器中创建一些文件,并运行 powerscript,该脚本以 1 秒的间隔将驱动器 A 中的所有文件复制到驱动器 B。 我在 powe
下面的函数一直返回这个错误信息。我认为可能是 double_precision 字段类型导致了这种情况,我尝试使用 CAST,但要么不是这样,要么我没有做对...帮助? 这是错误: ERROR: i
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
我的数据库有这个小问题。 我创建了一个表“articoli”,其中包含商品的品牌、型号和价格。 每篇文章都由一个 id (ID_ARTICOLO)` 定义,它是一个自动递增字段。 好吧,现在当我尝试插
我是新来的。我目前正在 DeVry 在线学习中级 C++ 编程。我们正在使用 C++ Primer Plus 这本书,到目前为止我一直做得很好。我的老师最近向我们扔了一个曲线球。我目前的任务是这样的:
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我的网站中有一段代码有问题;此错误仅发生在 Internet Explorer 7 中。 我没有在这里发布我所有的 HTML/CSS 标记,而是发布了网站的一个版本 here . 如您所见,我在列中有
如果尝试在 USB 设备上构建 node.js 应用程序时在我的树莓派上使用 npm 时遇到一些问题。 package.json 看起来像这样: { "name" : "node-todo",
在 Python 中,您有 None单例,在某些情况下表现得很奇怪: >>> a = None >>> type(a) >>> isinstance(a,None) Traceback (most
这是我的 build.gradle (Module:app) 文件: apply plugin: 'com.android.application' android { compileSdkV
我是 android 的新手,我的项目刚才编译和运行正常,但在我尝试实现抽屉导航后,它给了我这个错误 FAILURE: Build failed with an exception. What wen
谁能解释一下?我想我正在做一些非常愚蠢的事情,并且急切地等待着启蒙。 我得到这个输出: phpversion() == 7.2.25-1+0~20191128.32+debian8~1.gbp108
我是一名优秀的程序员,十分优秀!