Re: calling function from function?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rick Fletcher wrote:
function db( $host, $user, $pass, $dbnam ) {
 $db = @mysql_pconnect( $host, $user, $pass )or die( mysql_error( $db ));
       @mysql_select_db( $dbnam )or die( mysql_error( $db ) );
 return $db;
}

function logs() {
 global $defined;

 db( $defined[9], $defined[1], $defined[2], $defined[3] );
 ... do some processing ...

}

what am i missing here? i get errors if i try to pass $db to logs. i.e. logs( $db );


What's missing? The error message. Include it, and the offending line(s) of code, and ask again.

--Rick
There isnt an error at all. According to the die() functions at the end of the mysql() functions it should give it there, instead I get blank as if the function has not successfully completed. The reason I say this is if you try to access the mysql resource pointer ( $db, in this case ) I get nothing, a return code of 0. Example in point...

function db( $host, $user, $pass, $dbnam ) {
$db = @mysql_pconnect( $host, $user, $pass )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( $dbnam )or die( "<font face=\"arial\"><b>Could not connect to database: $defined[3]</b><br>Error Message: " . @mysql_error( $db ) . "<br>" . "Error Number: " . @mysql_errno( $db ) . "<br>Email Administrator: <a href=\"mailto:$defined[5]\";>$defined[5]</a></font>" );
return $db;
}


function logs() {
 global $defined;

db( $defined[9], $defined[1], $defined[2], $defined[3] );
$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 Message: " . @mysql_error( $db ) . "<br>" . "Error Number: " . @mysql_errno( $db ) . "<br>Email Administrator: <a href=\"mailto:$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,\".:||:.$_SERVER[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]\";>$defined[5]</a></font>" );
} else {
call_user_func( "exit_app" );
}
} else {
call_user_func( "exit_app" );
}
}


when called with
logs();
returns this:
Error occured when searching logs for session id: 82a831c4190f6e929032c0a9512c3657
Error Message:
Error Number:
Email Administrator: jason.gerfen@xxxxxxxxxxxx


--
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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux