Re: calling function from function?
| From: | Jason | Date: | Thu, 11 Nov 2004 19:56:43 +0000 |
| Subject: | Re: calling function from function? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201790@lists.php.net to get a copy of this message | ||
Greg Donald wrote:
On Thu, 11 Nov 2004 12:42:44 -0700, Jason <jason.gerfen@scl.utah.edu> wrote: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 ) );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...
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@scl.utah.edu
"And remember... If the ladies
don't find you handsome, they
should at least find you handy..."
~The Red Green show