Re: calling function from function?

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

 



Greg Donald wrote:
On Thu, 11 Nov 2004 12:42:44 -0700, Jason <jason.gerfen@xxxxxxxxxxxx> wrote:

There isnt an error at all.


How could there be an error?  You're using @ to suppress nearly every
mysql function call.  Makes it kind of hard to debug that way.

yep, you are right... I removed the @ for each of mysql functions and here is my error...
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /path/to/script.php on line 43
which tells me that the $db handle is not being returned when called from the db() function from within the logs() function and I am not sure why?


$defined = array( 0=> "localhost", 1 => "user", 2 => "pass" );

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[0], $defined[1], $defined[2], $defined[3] );

$pagecount = "1";
$tble = "logs";
$sql = mysql_query( "SELECT * FROM $tble WHERE session = \"$_SESSION[hash]\"", $db )or die( mysql_error( $db ));
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( mysql_error( $db ) );
} 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( mysql_error( $db ) );
} else {
call_user_func( "exit_app" );
}
} else {
call_user_func( "exit_app" );
}
}



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