Can I put a function in the file config.php ?
config.php :
<?php
$dbhost="localhost";
$dbusername="user1";
$dbpassword="123456";
$dbname="dbname1";
$table_name="table1";
$db=mysql_connect($dbhost,$dbusername,$dbpassword) or die (mysql_error());
@mysql_select_db($dbname) or die (mysql_error());
function next_auto_increment(){
$Result_auto_increment= mysql_query("SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '$dbname' AND TABLE_NAME = '$table_name' ");
$row_auto_increment=mysql_fetch_array($Result_auto_increment);
$auto_increment = $row_auto_increment['AUTO_INCREMENT'];
return $auto_increment;
}
?>
then I call the func from other php like this :
require_once "config.php";
$the_next_auto_increment = next_auto_increment();
but the function does not work !
if i put the function in the same php file, it works but in config.php not