mcerveni Posted March 30, 2009 Share Posted March 30, 2009 When i upload my script to my hosting web server, it gives me this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/u5/mcerveni/html/agentstats/include/lookup.php on line 20 My code runs fine on my local host though. Here it is: $sql = "SELECT * FROM table WHERE EmpID = '$searchreq' || AgentName = '$searchreq' || AvayaID = '$searchreq' ORDER BY date"; $result = mysql_query($sql); $sql2 = "SELECT TeamLeader, AgentName, EmpID, AvayaID, date, StaffedTime, AHT , ACDCalls, ACDTime , AvgACDTime, sum(ACWTime), sum(AvgACWTime), HoldCalls, HoldTime, AvgHoldTime, OutboundCalls , OutboundTime , AvailTime, RingTime, AvgRingTime, AVG(utilization) FROM table WHERE EmpID = '$searchreq' || AgentName = '$searchreq' || AvayaID = '$searchreq'"; $result2 = mysql_query($sql2); $row2= mysql_fetch_array($result2); $utilization = $row2['AVG(utilization)']; $acwTime = $row2['sum(ACWTime)']; $avg_acwTime = $row2['sum(AvgACWTime)']; if(mysql_num_rows($result) == 0) { echo 'No records found for: <font color="blue"> '.$_GET['req']; ' </font>'; } else { any help please? Link to comment https://forums.phpfreaks.com/topic/151703-solved-not-a-valid-mysql-result-resource-error/ Share on other sites More sharing options...
ratcateme Posted March 30, 2009 Share Posted March 30, 2009 try running your query like $result2 = mysql_query($sql2) or die(mysql_error()); it should display any errors you are having. Scott. Link to comment https://forums.phpfreaks.com/topic/151703-solved-not-a-valid-mysql-result-resource-error/#findComment-796646 Share on other sites More sharing options...
Yesideez Posted March 30, 2009 Share Posted March 30, 2009 $sql = "SELECT * FROM table WHERE EmpID = '$searchreq' || AgentName = '$searchreq' || AvayaID = '$searchreq' ORDER BY date"; $result = mysql_query($sql); || is for PHP OR is FOR MySQL $sql = "SELECT * FROM table WHERE EmpID = '$searchreq' OR AgentName = '$searchreq' OR AvayaID = '$searchreq' ORDER BY date"; $result = mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/151703-solved-not-a-valid-mysql-result-resource-error/#findComment-796652 Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2009 Share Posted March 30, 2009 OR and || are the same in mysql - http://dev.mysql.com/doc/refman/5.0/en/logical-operators.html Link to comment https://forums.phpfreaks.com/topic/151703-solved-not-a-valid-mysql-result-resource-error/#findComment-796761 Share on other sites More sharing options...
mcerveni Posted March 31, 2009 Author Share Posted March 31, 2009 Well, it shows this message: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause When i add GROUP BY date. It will not show the avg(utilization) at all. It will just show the first record. If i have ORDER BY date, it will add all the utilization and show the avg properly. here's my code again: $sql = "SELECT * FROM import_stats WHERE EmpID = '$searchreq' || AgentName = '$searchreq' || AvayaID = '$searchreq' ORDER BY date"; $result = mysql_query($sql); $sql2 = "SELECT TeamLeader, AgentName, EmpID, AvayaID, date, StaffedTime, AHT , ACDCalls, ACDTime , AvgACDTime, sum(ACWTime), sum(AvgACWTime), HoldCalls, HoldTime, AvgHoldTime, OutboundCalls , OutboundTime , AvailTime, RingTime, AvgRingTime, AVG(utilization) FROM import_stats WHERE EmpID = '$searchreq' || AgentName = '$searchreq' || AvayaID = '$searchreq' ORDER BY date"; $result2 = mysql_query($sql2) or die(mysql_error()); $row2= mysql_fetch_array($result2); $utilization = $row2['AVG(utilization)']; $acwTime = $row2['sum(ACWTime)']; $avg_acwTime = $row2['sum(AvgACWTime)']; if(mysql_num_rows($result) == 0) { echo 'No records found for: <font color="blue"> '.$_GET['req']; ' </font>'; } else { Link to comment https://forums.phpfreaks.com/topic/151703-solved-not-a-valid-mysql-result-resource-error/#findComment-797482 Share on other sites More sharing options...
mcerveni Posted March 31, 2009 Author Share Posted March 31, 2009 nevermind..i got it. i had to Group by agentName, and it all worked lol. Thanks anyways. Link to comment https://forums.phpfreaks.com/topic/151703-solved-not-a-valid-mysql-result-resource-error/#findComment-797541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.