我使用Dreamweaver创建了一个基本的mysql查询(我的php和mysql知识非常有限):
这是代码:
<?php require_once('../Connections/ahbvc.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;
}
}
mysql_select_db($database_ahbvc, $ahbvc);
$query_Recordset1 = "SELECT saida, DataRegisto, VIATURA, KMSAIDA, codigo, MORADA, OpServiço FROM registo WHERE HORAENTRADA IS NULL ORDER BY saida";
$Recordset1 = mysql_query($query_Recordset1, $ahbvc) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<?php do { ?>
<?php echo $row_Recordset1['']; ?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
但是当我尝试加载页面时,我收到此错误:
您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以便在'§oINV注册表附近使用正确的语法WHERE HORAENTRADA在第1行的说法是否为NULL
可以请一些人帮帮我吗?我搜索了每一段代码,但我找不到错误。韩国社交协会!
答案 0 :(得分:0)
你的问题是
“OpServiço”
表中的字段名称,您可以尝试使用反引号“OpServiço”来转义表名,但一般情况下建议仅使用小写字符abcdefghijklmnopqrstuvxyz
和下划线_表示数据库,表和字段名称