SQL in Function
| From: | Oosten, Sjoerd van | Date: | Thu, 22 Nov 2001 08:00:49 +0000 |
| Subject: | SQL in Function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-75479@lists.php.net to get a copy of this message | ||
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?
Sjoerd
________________________________________
Sjoerd van Oosten
Digitaal vormgever svoosten@esites.nl
Datamex E-sites B.V.
http://www.esites.nl
Minervum 7368 Telefoon: (076) 5 730 730
4817 ZH BREDA Telefax: (076) 5 877 757
_______________________________________