I have had this line of code in my site for a while now
$rentaldetails = mysql_query("SELECT * FROM rental ORDER by town",$link_id);
while($query_data = mysql_fetch_row($rentaldetails))
{
echo "test";
}
Above the headers of the page I have the link opener
$link_id=db_connect
Where db_connect is a regularly used function to connect to the general site database ....>
function db_connect()
{
global $dbhost, $dbusername, $dbuserpassword, $default_dbname;
global $MYSQL_ERRNO, $MYSQL_ERROR;
$link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
if(!link_id)
{
$MYSQL_ERRNO = 0;
$MYSQL_ERROR = "Connection failed to the host $dbhost.";
return 0;
}
else if(empty($dbname) && !mysql_select_db($default_dbname))
{
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();
return 0;
}
else return $link_id;
}
This has worked fine for months ... until I tried to use the following function
function members_count()
{
$link_id_members_count = forum_db_connect();
global $dbhost, $dbusername, $dbuserpassword, $default_dbname2;
$result2 = mysql_query("SELECT * FROM users",$link_id_members_count);
$n=0;
while ($query_data = mysql_fetch_row($result2))
{
$n++;
}
mysql_close($link_id_members_count);
return $n;
}
forum_db_connect connects to a different database.
The function is working fine and displaying the data but for some reason it breaks the first code.
Funnily enough, the line
$rentaldetails = mysql_query("SELECT * FROM rental ORDER by town",$link_id);
is valid, but the
while($query_data = mysql_fetch_row($rentaldetails))
displays invalid sql resource
I'm lost .... any clues?
Thanks ... Fizz