On Wed, 10 Nov 2004 10:10:37 -0700, Jason <jason.gerfen@xxxxxxxxxxxx> wrote:
Yeah the global stuff I understand and can use fine. What I would like more information about is the use of arguments to functions i.e. function( $user, $pass, $db ) { $db = @mysql_connect( $user, $pass, $db ); }
I understand parts but googling for the proper use of functions in php hasn't gotten me anywhere...
Looks like you understand already. Did you have some broken code you wanted help with?
yeah.. I should have posted it first. Here it is:
/* User Defined Variables */ $defined = array( "0" => "localhost", "1" => "user", "2" => "password" );
/* Database connection */
function db() {
global $defined;
if( connection_status() != 0 ) {
$db = @mysql_pconnect( $defined[9], $defined[1], $defined[2] )or die( "<font face=\"arial\"><b>phpDHCPAdmin currently not active, is under repair or is not configured correctly.</b><br><br>Error Number: " . mysql_errno( $db ) . <br>Error Message: " . mysql_error( $db ) . "<br>Email Administrator: <a href=\"mailto:$defined[5]\">$defined[5]</a></font>" );
@mysql_select_db( $defined[3] )or die( "<font face=\"arial\"><b>Could not connect to database: $defined[3]</b><br>Error Me\
ssage: " . @mysql_error( $db ) . "<br>" . "Error Number: " . @mysql_errno( $db ) . "<br>Email Administrator: <a href=\"mailt\
o:$defined[5]\">$defined[5]</a></font>" );
}
}
/* Logging function */ function logs() { global $defined;
call_user_func( "db" );
$pagecount = "1";
$tble = "logs";
$sql = @mysql_query( "SELECT * FROM $tble WHERE session = \"$_SESSION[hash]\"", $db )or die( "<font face=\"arial\"><b>Error\
occured when searching logs for session id:</b> $_SESSION[hash]<br>Error Message: " . @mysql_error( $db ) . "<br>" . "Error\
Number: " . @mysql_errno( $db ) . "<br>Email Administrator: <a href=\"mailto:$defined[5]\">$defined[5]</a></font>" );
while( $row = @mysql_fetch_array( $sql ) ) {
$id = $row["session"]; }
if( @mysql_num_rows( $sql ) == 0 ) {
$insert = @mysql_query( "INSERT INTO $tble VALUES (\"\",\"$_SESSION[date]\",\"$_SESSION[hour]\",\"$_SESSION[ipaddy]\",\\
"$_SESSION[host]\",\"$_SESSION[ref]\",\"$_SERVER[HTTP_USER_AGENT]\",\"$_SERVER[PHP_SELF]\",\"$pagecount\",\"$_SESSION[msg]\"\
,\"$_SESSION[hash]\")", $db )or die( "<font face=\"arial\"><b>Error occured creating logs for $_SESSION[hash]</b><br>Error M\
essage: " . @mysql_error( $db ) . "<br>" . "Error Number: " . @mysql_errno( $db ) . "<br>Email Administrator: <a href=\"mail\
to:$defined[5]\">$defined[5]</a></font>" );
} elseif( @mysql_num_rows( $sql ) != 0 ) {
if( ( $_SESSION['hash'] == $id ) || ( empty( $pagecount ) ) ) {
$pagecount++;
$update = @mysql_query( "UPDATE $tble SET date=\"$_SESSION[date]\", time=\"$_SESSION[hour]\", ip=\"$_SESSION[ipaddy]\"\
, host=\"$_SESSION[host]\", referer=\"$_SESSION[ref]\", agent=\"$_SERVER[HTTP_USER_AGENT]\", page=CONCAT(page,\".:||:.$_SERV\
ER[PHP_SELF]\"), pagecount=\"$pagecount\", message=\"$_SESSION[msg]\", session=\"$_SESSION[hash]\" WHERE session=\"$id\"", $\
db )or die( "<font face=\"arial\"><b>Error occured while updating logs for $_SESSION[hash]</b><br>Error Message: " . @mysql_\
error( $db ) . "<br>" . "Error Number: " . @mysql_errno( $db ) . "<br>Email Administrator: <a href=\"mailto:$defined[5]\">$d\
efined[5]</a></font>" );
} else {
call_user_func( "exit_app" ); }
} else {
call_user_func( "exit_app" ); }
}
the result is that trying to call a function from within a function seems to be giving me problems. I get no error message or code. Any help is appreciated
-- Jason Gerfen jason.gerfen@xxxxxxxxxxxx
"And remember... If the ladies don't find you handsome, they should at least find you handy..." ~The Red Green show
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php