mysql_fecth_array() and function call as parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I have wriiten a function that determines whether tomorrows date is
the first of the month or not then returns a SQL string based on
whether its the first of the month or not.  According to my apache
error logs I get an error that says:

[Sun Mar 26 21:43:14 2006] [error] [client 192.168.0.2] PHP Warning: 
mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\validation.php on line 331

I understand that this is a warning but I believe that it has
something to do with the fact that no output is being displayed.  All
other mysql database outputs work fine.

This is the code that sets the query in the mysql_query parameter

$Month_query = mysql_query($this->determineMonth());

this is the code for determineMonth ()

function determineMonth()
	{
		$return = "";
		$query1 = mysql_query("SELECT months FROM Month WHERE m_id =
month(curdate())");
		$query2 = mysql_query("SELECT dayNum FROM Days WHERE dayNum =
day(curdate())");
		$query3 = mysql_query("SELECT year FROM Year WHERE year = year(curdate())");
		
		switch ($query1)
		{
			case "January":
			case "March":
			case "May":
			case "July":
			case "August":
			case "October":
			case "December":
				if($query2 == 31)
					$return = "SELECT m_id, months FROM Month WHERE m_id >=
month(curdate())+1";
				else
					$return = "SELECT m_id, months FROM Month WHERE m_id >= month(curdate())";
			break;
			case "February":
				if ($query2 == 28 || $query2 == 29)
					$return = "SELECT m_id, months FROM Month WHERE m_id >=
month(curdate())+1";
				else
					$return = "SELECT m_id, months FROM Month WHERE m_id >= month(curdate())";
			break;
			case "April":
			case "June":
			case "September":
			case "November":
				if ($query2 == 30)
					$return = "SELECT m_id, months FROM Month WHERE m_id >=
month(curdate())+1";
				else
					$return = "SELECT m_id, months FROM Month WHERE m_id >= month(curdate())";
			break;
		}
		return $return;
	}

I hope I included everything.  If not let me know and I'll post it

Paul

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux