Re: Function passed as argument to function

From: Date: Mon, 02 Dec 2002 00:31:35 +0000
Subject: Re: Function passed as argument to function
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-126650@lists.php.net to get a copy of this message
> > For reference, see > > http://autocracy.homelinux.org/template.php and > > http://autocracy.homelinux.org/error.php > > Unless you have a good reason to do otherwise please post your code here. > People would be less inclined to help if they have to go about clicking on > links to see what your problem is. Noted > 1) Do you really mean list_writings(poetry), or did you in fact mean > list_writings($poetry)? list_writings(poetry); or more accurately std_layout("Recent Writings", list_writings(poetry)); I've also tried that using various methods of quoting for the list_writings(poetry) and also doing strange things like making anonymous functions and defining the function as a variable and what-not. > 2) How did you conclude that? Did you check that > list_writings(poetry)/list_writings($poetry) gives the correct result? IE > echo list_writings(poetry)/list_writings($poetry) ? list_writings(poetry) simply spits out the output. 'echo list_writings(poetry)' was not designed as the proper way to use the command. Here is the current code for the function (in its half-complete but working state with mysql_connect() and mysql_select_db replaced with generic variables for public consumption), and also the std_layout function following: function list_writings($table) { $db_link = mysql_connect($host, $user, $pw) or die("DB connect failure"); mysql_select_db ($db_name) ; $query = "SELECT wid, title, description FROM $table ORDER BY wid DESC LIMIT 15"; $result = mysql_query($query, $db_link); while ($row = mysql_fetch_row ($result)) { print "<a href=\"/poetry.php?wid=$row[0]\">$row[1]</a><br>"; }; }; function std_layout($ltitle, $ltext) { echo " <table width=\"100%\" align=\"top\"> <tr> <td valign=\"top\"> <table style=\"border-top: 1px solid #000000; border-right: 1px solid #000000\" width=\"175\"> <tr> <td bgcolor=#B0C4DE valign=\"top\"> &nbsp; $ltitle </td> </tr> <tr> <td> $ltext </td> </tr> </table> </td> <td valign=\"top\">" ; } ; Basically, I want std_layout to be able to take either straight text as an argument or the output of a function (even if it's through a mid-point such as a variable). That failing I'm going to have to admit a design flaw to myself and re-work the code... -Jeff SIG: HUP

« previous php.general (#126650) next »