Is having a function to do querys good or bad? Like the following
<?php
// functions.php - All needed functions
function processQuery($sql)
{
require_once("config.php");
if(!$result = mysql_query($sql, $conn))
{
die(mysql_error());
}
}
?>
Incase you need it - config.php
<?php
// config.php - Database configurations
// Hostname exp: localhost, www.somesite.com
$db_hostname = "some_domain_name";
// User for database
$db_username = "some_user";
// Password for database
$db_password = "some_password";
// Database
$db_database = "some_databadr";
$conn = mysql_connect($db_hostname, $db_username, $db_password);
if (!$conn)
{
die("Couldn't connect to database");
}
else
{
mysql_select_db($db_database, $conn);
}
?>
Main questions i have is will that work if i use like require_once(); functions [for other pages like login.php] , and will that ork or have you spoted an error? =/
Thanx in advance!