> -----Original Message----- > From: Oosten, Sjoerd van [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 22, 2001 2:01 AM > To: '[EMAIL PROTECTED]' > Subject: [PHP] SQL in Function > > > 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"; } > } > > 1. Is it possible to make a sql connection in my function
Yes. > 2. did i do something wrong? Yes. The thing you have to remember is that your database link identifiers, etc., follow the same rules of scope as any other variable (and thus, need to either be passed into your function as parameters or declared as global). Specifically, in your case, the $db variable referenced in your mysql_query() call doesn't appear to have a value that's local to this function. --- Mark Roedel | "Blessed is he who has learned to laugh Systems Programmer | at himself, for he shall never cease LeTourneau University | to be entertained." Longview, Texas, USA | -- John Powell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]