Re: calling function from function?
| From: | Sebastian Mendel | Date: | Fri, 12 Nov 2004 09:58:25 +0000 |
| Subject: | Re: calling function from function? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201836@lists.php.net to get a copy of this message | ||
Jason wrote:
Rick Fletcher wrote:$db is not defined, $db is not required, at least if you want to use $db you have to ctach the return from db() in $db: $db = db( $defined[9], $defined[1], $defined[2], $defined[3] ); as i assume, logs() does nothing more than update one row with session data in the DB? if you have a primary key onThere 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>" );function db( $host, $user, $pass, $dbnam ) { $db = @mysql_pconnect( $host, $user, $pass )or die( mysql_error( $db ));What's missing? The error message. Include it, and the offending line(s) of code, and ask again. --Rick@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 );@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 )
session you can just user REPLACE instead of
"if SELECT INSERT ELSE UPDATE"
logs()
{
db( $defined[9], $defined[1], $defined[2], $defined[3] );
$sql = 'REPLACE INTO logs VALUES ( ... )';
mysql_query( $sql ) or die( '...' );
}
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet