tekrscom Posted February 21, 2010 Share Posted February 21, 2010 MySQL 5.0.32 Hi everyone... It's been a while... But anyway, I am having problems with a multiple condition query... It keeps giving me an error... "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource" The query is as follows... $query = mysql_query("SELECT EndClients.EndClientBusinessName, Quotes.QuoteID, Quotes.QuoteTitle FROM Quotes LEFT JOIN EndClients ON Quotes.EndClientID = EndClients.EndClientID WHERE Quotes.QuoteID = '$_GET[quoteid]' AND Quotes.ITCompanyID = '$_SESSION[userID]' AND Quotes.QuoteStatus = 'Generation'") or die(mysql_error()); I know, you're probably wondering why I would be adding more conditions after already defining the ID of the row in which I am wanting,... it's merely added protection to ensure the right person is making the query and also that they're not trying to pull a row maliciously that is no longer in 'Generation' status... The whole code is as follows: <? session_start(); if ($_SESSION['Condition'] !== 'Logged' || $_SESSION['UserType'] !== 'ITCo') { header("Location: login.php"); } else { include_once "connection.php"; include_once "emailnotification.php"; $query = mysql_query("SELECT EndClients.EndClientBusinessName, Quotes.QuoteID, Quotes.QuoteTitle FROM Quotes LEFT JOIN EndClients ON Quotes.EndClientID = EndClients.EndClientID WHERE Quotes.QuoteID = '$_GET[quoteid]' AND Quotes.ITCompanyID = '$_SESSION[userID]' AND Quotes.QuoteStatus = 'Generation'") or die(mysql_error()); while ($row = mysql_fetch_assoc($query)) { $TheCurrentDate = date("Y-m-d"); $query = mysql_query("UPDATE Quotes SET QuoteDate = '$TheCurrentDate', QuoteStatus = 'Pending Admin Approval' WHERE QuoteID = '$row[QuoteID]'"); ITCoSubmittedQuote_EmailAdmin($_SESSION['UserName'], $row['EndClientBusinessName'], $row['QuoteTitle']); header("itcoclientquotes.php?function=continueincompletequote&status=quotesubmitted"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/192828-multiple-conditions-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2010 Share Posted February 21, 2010 Your code inside of your while() {} loop is reusing the $query variable, so when the while loop condition is evaluated after the first UPDATE query is executed you get an error because $query no longer contains the result resource from the first query. Quote Link to comment https://forums.phpfreaks.com/topic/192828-multiple-conditions-problem/#findComment-1015718 Share on other sites More sharing options...
tekrscom Posted February 21, 2010 Author Share Posted February 21, 2010 *Dote* Yeah, I just seen that just about the time you replied... Now I feel stupid... Thank you very much for your reply and sorry for wasting your time... Quote Link to comment https://forums.phpfreaks.com/topic/192828-multiple-conditions-problem/#findComment-1015720 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.