Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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
mysql中的动态php变量,sql-vars得到集,但结果集是空的?_Php_Mysql - Fatal编程技术网

mysql中的动态php变量,sql-vars得到集,但结果集是空的?

mysql中的动态php变量,sql-vars得到集,但结果集是空的?,php,mysql,Php,Mysql,我有以下由其他人创建的代码,虽然看起来变量已经传递,但结果集中没有返回任何内容; 页面: ... 然后进行搜索。 下面是结果页面上的代码(略为编辑长度)。我有一种感觉,它的语录之类的,但一直忽略了一些东西 <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue =

我有以下由其他人创建的代码,虽然看起来变量已经传递,但结果集中没有返回任何内容; 页面: ... 然后进行搜索。 下面是结果页面上的代码(略为编辑长度)。我有一种感觉,它的语录之类的,但一直忽略了一些东西

<?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;
}
}
if (isset($_GET['stval'])) {
  $stval_Recordset1 = (get_magic_quotes_gpc()) ? $_Get['stval'] : addslashes($_Get['stval']);
}


if (isset($_GET['stval'])) {
  $stval_Recordset1 = $_GET['stval'];
}

if (isset($_GET['sq'])) {
  $sq_Recordset1 = $_GET['sq'];
}
mysql_select_db($database_daap_photo, $daap_photo);
$query_Recordset1 = sprintf("SELECT * FROM main WHERE %s = %s ", GetSQLValueString($stval_Recordset1, "text"),GetSQLValueString($sq_Recordset1, "text"));
 $Recordset1 = mysql_query($query_limit_Recordset1, $daap_photo) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

?>
尝试将查询更改为

SELECT * FROM main WHERE %s = '%s'

你能打印出:$query\u Recordset1(查询)吗?我认为你没有在查询中包含这个值,这导致了:你的SQL语法有一个错误;请查看与MySQL服务器版本对应的手册,以了解第1Hm行“Eddie”“LIMIT 0,0”附近使用的正确语法。。这个极限可能有问题(0,0?=)我就是这么想的!现在就试试吧,我想这和引用有关。sprintf返回“您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解在第1行“printf返回SELECT*FROM main WHERE main.”FIRST_NAME'='Eddie'附近使用的正确语法,其中main.'FIRST_NAME'='Eddie'您的SQL语法有错误;检查与MySQL服务器版本对应的手册,了解在第1行“52”附近使用的正确语法——在这个测试页面上,我做了:FIRST_NAME是字段名,不应该被引用,这就是为什么我要求您尝试从我的答案中查询。但我看你已经解决了()
SELECT * FROM main WHERE %s = '%s'