passing args to function?

From: Date: Mon, 10 Sep 2001 16:34:54 +0000
Subject: passing args to function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66777@lists.php.net to get a copy of this message
Hi, I'm having a bit of a hard time passing in a constant to a user-defined function. the calling page - index.php: <html> <?php include define_foo.php; function_foo(bar); ?> </html> define_foo.php: <?php function foo($value) { global $value, $page_id, $usr, $pass, $database, $host; //pull info from info table specific to type $sql="select text, link from info where page_id = $page_id and value = $value"; $link_id = mysql_pconnect($host, $usr, $pass) or die (mysql_error()); mysql_select_db($database, $link_id); $result = mysql_query ($sql, $link_id) or die (mysql_error()); //set titleblock specific to type of info being output if ($value == "bar") {$titleblock = "Bar Items"; } if ($value == "eek") {$titleblock = "Eek Items"; } echo "value is $value"; //this is printing as "value is" with no $value. echo "<h2>$titleblock</h2><br>"; if (is_null($result)) break; //iterate through array, outputting info based on value type if ($value != "bar") { while (list ($text, $link) = mysql_fetch_row ($result)) { echo "<a href=\"$link\">$text</a><br>"; } } elseif ($value ="eek") { while (list ($text, $link) = mysql_fetch_row ($result)) { echo "$text<br>"; } } } ?> any pointers much appreciated!!! cheers, jaxon

« previous php.general (#66777) next »