2012-10-23 51 views
1

我有一个查询,我已经在phpMyAdmin中运行,并且它返回结果,但是如果我将查询剪切并粘贴到网页上的php脚本中,查询似乎运行但没有任何结果显示在页面上。它也没有完成加载页面。该页面在我的查询开始的地方结束。基于Web的查询的执行时间是否可能与通过phpMyAdmin运行的查询相比耗时过长?下面是查询:MySQL查询在phpMyAdmin中可用,但不在php脚本中

$query = "SELECT DISTINCT tblCertificates.WebReportedDt, tblInsHeader.name1, tblInsHeader.name2, tblQuotes.certnum, tblQBalloons.regnum 
FROM ((`tblQuotes` 
INNER JOIN `tblInsHeader` ON tblQuotes.insuredid = tblInsHeader.insuredid) 
INNER JOIN `tblQBalloons` ON tblQuotes.quoteid = tblQBalloons.quoteid) 
INNER JOIN `tblCertificates` ON tblQuotes.quoteid = tblCertificates.QuoteID 
WHERE (((tblCertificates.WebReportedDt) IS NOT NULL)AND ((tblCertificates.web) = True) AND tblCertificates.WebReportedDt >= '".$MyDate."') 
ORDER BY tblCertificates.WebReportedDt DESC , tblInsHeader.name1, tblQuotes.certnum, tblQBalloons.regnum"; 
$results = mysql_query($query) or die("Query Timed out"); 
    while ($r = mysql_fetch_array($results)) { 
extract ($r); 
echo $WebReportedDt." - ".$name1." ".$name2." - ".$certnum." - ".$regnum."<br>"; 
} 

的数值指明MyDate var为当前日期(YYYY-MM-DD HH:SS:ii)以DATETIME格式。

任何想法都会有所帮助。

谢谢!

+1

显示您的确切PHP代码。你提供的是不完整的。 –

+0

错误报告?如果没有,你可能只是无法连接到数据库... – Jasper

+1

你可能是打破你的PHP代码的引号,并必须逃避你的报价或用反斜杠单引号 –

回答

0

感谢您的建议。 原来我需要增加执行时间。 查询时间过长,php超时。

相关问题