查询在phpmyadmin中工作正常但在mysql_query php函数中没有

时间:2009-08-21 20:14:16

标签: php sql mysql

我有这个SQL查询:

SELECT DISTINCT r.uri uri
FROM resource r
INNER JOIN object o ON o.idResource = r.idResource
WHERE r.type = 2
AND r.idResource IN (
  SELECT DISTINCT r1.idResource
  FROM object o1
  INNER JOIN resource r1 ON r1.idResource = o1.idResource
  INNER JOIN class c1 ON c1.idClass = o1.idClass
  INNER JOIN property p2 ON p2.idResource = c1.idResource
  INNER JOIN object_value ov2 ON ov2.idProperty = p2.idProperty
                             AND ov2.idObject = o1.idObject
  WHERE c1.idResource = 364
  AND (p2.idProperty = 4 AND ov2.value LIKE '%dave%')
)

在phpmyadmin(mysql)中正常工作,但在PHP代码中没有,它会给出超时。

$result = mysql_query('$gquery') or die(mysql_error());

知道为什么吗?

2 个答案:

答案 0 :(得分:5)

你不应该在引号中加$gquery。你应该使用

$result = mysql_query($gquery) or die(mysql_error()); 

答案 1 :(得分:0)

已解决:超时问题。有必要延长超时期限。遗憾