I would recomend for sanity and clean code that you define your functions outside of the file you will be calling it from and include that file in any file you need to call a function from. Here's a function that I defined in my db.php file. /*********************************************************** * FUNCTION: DBCheckByMin($min) * DESCRIPTION: Checks to see if the user's min already exists * RETURNED: exist (1 or 0) **********************************************************/ function DBCheckByMin($min) { $record = mysql_query( "SELECT `min` FROM `user` WHERE `min` LIKE '$min'" ); for($i=0; $holder[$i]=mysql_fetch_array( $record ); $i++); if($min==$holder[0][0]) { $exist=1; } else { $exist=0; } return $exist; } The first line of the file I call this function in includes my function list: include "db.php"; And my call to the function itself: $check=DBCheckByMin($min); Let's say my user is entering his MIN as "1234567890" What the function does is catch the value of the variable $min which is 1234567890 when it's called and pass it to the function. Then DBCheckByMin takes the value 1234567890 and assignes it to the variable $min. (I've named both variables the same so I know what they are) Now that the function has it's own variable, $min that has a value of "1234567890" It then does some basic SQL work to find if that MIN already exists in my databse. Then it sets $exist to either 1 or 0. It sets it to 1 if this is a duplicate entry and 0 if it's not a duplicate. And let's just say that it did indeed find a duplicate record so $exist will have the value of 1. Next on the return line, the function sends back the value of $exist which is 1. Please remember when I called the function I had a variable before the function was called "$check=DBCheckByMin($min);" This way $check will catch whatever value the function returns, in this case, that value is 1. Now that check has a value which indicates that this user already exists I can send a message to the user saying that it already exists and to try again. Did that make a bit more sense about how variables are passed between functions? It's all in the call and definition. Andrew Darrow Kronos1 Productions www.pudlz.com ----- Original Message ----- From: "Tom Chubb" <tomchubb@xxxxxxxxx> To: <php-general@xxxxxxxxxxxxx> Sent: Saturday, July 30, 2005 9:23 AM Subject: Help with Functions I am trying to start using functions on some pages to layout a header row in a table. I have defined the function as below... <?php function (headerrow) { ?> <table width="750" border="0" cellpadding="0" cellspacing="0" bgcolor="#FF0066"> <tr> <td class="table_head"><?php echo $tablehead; ?></td> <td width="20"><img src="/nav/images/pspromo_table_rhs.gif" width="20" height="20"></td> </tr> </table> <?php } ?> What I can't seem to work out is a way to set the text. Here I've echoed the $tablehead value, but it I was to use more than one table on the same page then it wouldn't work. Can I do something like headerrow(text goes here) or something? I can't understand the use of arguments and it's really confusing me! Any help would be really appreciated. Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php