Menu
Hi all,
I’ve written a SQL function for use in my PHP pages, as follows:
[code=php]
function sql($query)
{
include(“config.common.php”);
global $dbName;
@mysql_select_db($dbName) or die(“<h1>Database Error</h1>Unable to connect to database”);
$sql = “” . $query . “”;
$result = mysql_query($sql);
define(“result”,$result);
unset($sql,$query);
}
for use in pages as follows:
[code=php]sql(“SELECT * FROM table”);
while($row = mysql_fetch_array(result))
{
…
}
My issue is this. If I try and use it twice in a page, then the first query works but the second does not. I cannot work out why this is happening?