In php4 i used this for a simple function function totProducts(){ global $database_connDB, $connDB; mysql_select_db($database_connDB, $connDB); $sql = "SELECT COUNT(*) as total FROM table"; $res = mysql_query($sql, $connDB) or die(mysql_error()); $row = mysql_fetch_assoc($res); return $row['total']; } PHP: but now with php5 installed i get errors: Warning: mysql_select_db(): supplied argument is not a valid MySQL Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in how do i fix this?? regards edit: where can i find a common php4<->php5 list of differences?
check in your php.ini if you have succesfully installed the mysql extension/dll this link could help http://forums.techguy.org/web-design-development/694647-solved-phps-mysql-functions-not.html
tx genius, can't check my php.ini but i know the mysql extension works. I see the value on my homepage, but i include the file (header.php) in other files. So that might be it. i added if (!function_exists("totProducts")) { } PHP: but still i get the errors
hmm i think it has to do with global and require_once('connDB.php'), perhaps global $database_connDB, $connDB; PHP:
ok think i found a solution if (!function_exists("totProducts")) { function totProducts(){ @require('connDB.php'); //global $database_connDB, $connDB; mysql_select_db($database_connDB, $connDB); $sql = "SELECT COUNT(*) as total FROM table"; $res = mysql_query($sql, $connDB) or die(mysql_error()); $row = mysql_fetch_assoc($res); return $row['total']; } } PHP: any feedback?
Try setting this in the PHP5 script: ini_set('register_globals', 'on'); PHP5 turns globals off. Make sure that is at the top.