Re: SQL in Function

From: Date: Fri, 23 Nov 2001 02:24:48 +0000
Subject: Re: SQL in Function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75552@lists.php.net to get a copy of this message
On Thu, 22 Nov 2001 18:30, Oosten, Sjoerd van wrote: > Hello, im a newbie in writing functions but right now im trying to. > > I have made the following function > > // FUNCTION TO DECIDE WHETHER A PROJECT IS IN BETWEEN PROJECTBEGIN AND > PROJECTEND , YES OR NO > > function Activeyesno($month,$day,$year,$Project_id){ > $dayactief = mktime(0, 0, 0, $month, $day, $year); > $daytemp = date("Y-m-d", $dayactief); > $resultactive = mysql_query("SELECT * FROM EIAProjecten WHERE > ((Project_begindatum >= '$daytemp' AND Project_id = '$Project_id') OR > (Project_einddatum <= '$daytemp' AND Project_id = > '$Project_id'))",$db); > > $num_rows = mysql_num_rows($resultactive); > if ($num_rows == '1'){ > return "red"; } > } > > > AND i'm calling this function in an while loop > > <? echo Activeyesno($month,$day,$year,$Project_id); ?> > > (I translated it into english so maybe some mistakes!) > > When i try to call the function i get a mysql error every time, even > when i make $resultactive ("SELECT * FROM EIAProjecten") // NO DATE > > 1. Is it possible to make a sql connection in my function > 2. did i do something wrong? > > Can somebody help me? > What is the error? -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA (((((This tagline in Stereo where available)))))

« previous php.general (#75552) next »