Jump to content

[SOLVED] Query Page screws up my html


thefollower

Recommended Posts

I have an include with all the query's needed for the page but for some reason with the include in the page the page goes completely white and the layout screws up and just goes all over the place for no reason..... but if i take out the include php file its perfectly back to normal :S

 

can any one see what i got wrong, its never happened to me before so i don't know what i need to look for to fix it... no errors are produced either. heres my script:

 

<?

//first query to obtain house info from user
$GetHouseInfo = mysql_query("SELECT * FROM houses WHERE UserID='{$_SESSION['Current_User']}'") 
			or die(mysql_error());

// Fetch the row from the database
if (!($houserow = mysql_fetch_assoc($GetHouseInfo))) {
    echo "User not found!";
    exit;
}	

//second query to 
$GetHouses = mysql_query("SELECT houses.*, cities.*, countries.* FROM houses, cities, countries 
		WHERE houses.UserID ='{$_SESSION['Current_User']}' AND cities.CityID = houses.CityID AND cities.CountryID = countries.CountryID")
		or die(mysql_error());
// Fetch the row from the database
if (!($gethouserow = mysql_fetch_assoc($GetHouses))) {
    echo "Houses Not found!";
    exit;
}
$HouseTotals = mysql_num_rows($GetHouses);

$GetHouseLodgers = mysql_query("SELECT * FROM userregistration , houses 
			   WHERE userregistration.HouseID = houses.HouseID")
			   or die(mysql_error());

$HouseLoderTotals = mysql_num_rows($GetHouseLodgers);
?>

Link to comment
https://forums.phpfreaks.com/topic/66750-solved-query-page-screws-up-my-html/
Share on other sites

well, I had to re-write my code in a way that when an error occured, it would still 'fall-though' the script, instead of dying. or exiting.

 

E.G:

 

<?

//first query to obtain house info from user
if ($GetHouseInfo = mysql_query("SELECT * FROM houses WHERE UserID='{$_SESSION['Current_User']}'")) {

// Fetch the row from the database
if (($houserow = mysql_fetch_assoc($GetHouseInfo))) {

$GetHouses = mysql_query("SELECT houses.*, cities.*, countries.* FROM houses, cities, countries WHERE houses.UserID ='{$_SESSION['Current_User']}' AND cities.CityID = houses.CityID AND cities.CountryID = countries.CountryID") or die(mysql_error());

if (($gethouserow = mysql_fetch_assoc($GetHouses))) {

$HouseTotals = mysql_num_rows($GetHouses);

$GetHouseLodgers = mysql_query("SELECT * FROM userregistration , houses WHERE userregistration.HouseID = houses.HouseID") or die(mysql_error());

$HouseLoderTotals = mysql_num_rows($GetHouseLodgers);

} else {
echo "house not found";
}

} else {
echo "usr not found";
}

}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.