PCHomepage
Programmer
I am trying to create a basic PHP function for retrieving MySQL values which seems easier than repeating several lines of code on each page but it does not pull up results for some reason. Is this even possible and if so, does anyone see what I am doing wrong?
The included common.php contains all the database values except for the query itself.
The included common.php contains all the database values except for the query itself.
Code:
<?php
include_once $_SERVER ['DOCUMENT_ROOT'] . "/functions/config.php";
function DBConnect($query, $dbname) {
$connection = mysql_connect($dbhost, $dbusername, $dbpass);
$resultCat = mysql_db_query($dbname, $query);
if (!$query) {
echo "No Query was entered";
exit;
}
return mysql_fetch_array($resultCat);
}
?>