• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

website houses probleme

Trevorr

New Member
Joined
Feb 8, 2012
Messages
1
Reaction score
0
hola

i have a probleme with house script and i wonder if somebody can help?:D

LUA:
Warning: Invalid argument supplied for foreach() in houses.php on line 539 Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY `name`' at line 1' in houses.php:546 Stack trace: #0 houses.php(546): PDO->query('SELECT * FROM `...') #1 index.php(158): include('houses...') #2 index.php(4): include('index....') #3 {main} thrown in houses.php on line 546




Warning: Invalid argument supplied for foreach() in houses.php on line 539 Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY `rent`' at line 1' in houses.php:550 Stack trace: #0 houses.php(550): PDO->query('SELECT * FROM `...') #1 index.php(158): include('houses...') #2 index.php(4): include('index....') #3 {main} thrown in houses.php on line 550 [/code]

i have this bug when i try to sleect the rent or size or name for houses.

thx for helping my

bb
 
for modern try change house.php, other version modern acc
or try using for modern acc:
LUA:
<?php 

	class Houses extends Controller {
		
		public function index() {
			$ide = new IDE;
			$ide->redirect(WEBSITE."/index.php/houses/main");
		}
		
		public function main($action = 0) {
			require("config.php");
			$ide = new IDE;
			$this->load->model("house_model");
			$data = array();
			$this->load->helper("form_helper");
			$this->load->library('pagination');
			$config['base_url'] = WEBSITE.'/index.php/houses/main/';
			$config['total_rows'] = $this->house_model->getHousesAmount();
			$config['per_page'] = $config['housesLimit']; 
			$this->pagination->initialize($config); 
			$data['pages'] = $this->pagination->create_links();
			$data['houses'] = $this->house_model->getHouses();
			$this->load->view("house_list", $data);
		}
		
		public function view($id) {
			$ide = new IDE;
			$id = (int)$id;
			if(empty($id)) $ide->goPrevious();
			$this->load->model("house_model");
			$data = array();
			$data['house'] = $this->house_model->loadHouse($id);
			if(empty($data['house'])) $ide->goPrevious();
				if($ide->isLogged())
					$data['characters'] = $this->house_model->getCharactersName();
			$data['id'] = $id;
			$this->load->view("view_house", $data);
		}
		
		function _checkCharacter($id) {
			$id = (int)$id;
			$this->load->model("house_model");
			$this->load->helper("url");
			$house = (int)$this->uri->segment(3);
			$data = $this->house_model->loadHouse($house);
			$character = $this->house_model->loadCharacter($id);
				if(empty($character)) {
					$this->form_validation->set_message('_checkCharacter', 'Character could not be found.');
					return false;
				}
				else if(!empty($character[0]['owner'])) {
					$this->form_validation->set_message('_checkCharacter', 'This character is already owning a house.');
					return false;
				}
				else if(!empty($character[0]['player_id'])) {
					$this->form_validation->set_message('_checkCharacter', 'This character is already bidding on house.');
					return false;
				}
				else if($_REQUEST['bid'] > $character[0]['balance']) {
					$this->form_validation->set_message('_checkCharacter', 'This character does not have enough money. The money must be in the bank.');
					return false;
				}
				else if($character[0]['world_id'] != $data[0]['world_id']) {
					$this->form_validation->set_message('_checkCharacter', 'The character must be on the same world as the house.');
					return false;
				}
				else
					return true;
		}
		
		function _checkBid($bid) {
			$bid = (int)$bid;
			$this->load->model("house_model");
			$this->load->helper("url");
			$house = (int)$this->uri->segment(3);
			$data = $this->house_model->getBids($house);
				if($data[0]['endtime'] > time()) {
					$this->form_validation->set_message('_checkBid', 'This auction has already finished.');
					return false;
				}
				elseif($bid <= $data[0]['bid']) {
					$this->form_validation->set_message('_checkBid', 'The bid must be higher than the minimum bid.');
					return false;
				}
				elseif($bid <= $data[0]['limit']) {
					$this->form_validation->set_message('_checkBid', 'You have been outbided! The current bid is '.$bid.'.');
					$this->house_model->setBid($house, $bid);
					return false;
				}
				else
					return true;
		}
		
		function _checkStartingBid($bid) {
			if($bid < 1) {
				$this->form_validation->set_message('_checkStartingBid', 'The big must be atleast 1 gold.');
				return false;
			}
			else
				return true;
		}
		
		public function start_auction($id) {
			$ide = new IDE;
			$id = (int)$id;
			$ide->requireLogin();
			if(empty($id)) $ide->goPrevious();
			$this->load->model("house_model");
			$data = array();
			$data['house'] = $this->house_model->loadHouse($id);
			if(empty($data['house'])) $ide->goPrevious();
			if(!empty($data['house'][0]['owner'])) $ide->goPrevious();
			if($data['house'][0]['bid'] > 0) $ide->redirect(WEBSITE."/index.php/houses/join_auction/".$id);
			if($data['house'][0]['guild'] == 0) 
				$data['characters'] = $this->house_model->getAllowedCharacters($data['house'][0]['world_id']);
			else
				$data['characters'] = $this->house_model->getAllowedGuildCharacters($data['house'][0]['world_id']);
			$data['id'] = $id;
			$this->load->helper("form_helper");
				if($_POST) {
					$this->load->library("form_validation");
					$this->form_validation->set_rules('bid', 'Bid', 'required|integer|callback__checkStartingBid');
					$this->form_validation->set_rules('character', 'Character', 'required|integer|callback__checkCharacter');
					if($this->form_validation->run() == true) {
						$this->house_model->createAuction($id, $_POST['character'], $_POST['bid'], $data['house'][0]['world_id']);
						$ide->redirect(WEBSITE."/index.php/houses/view/".$id);
					}
				}
			$this->load->view("start_house_auction", $data);
		}
		
		public function join_auction($id) {
			$ide = new IDE;
			$id = (int)$id;
			$ide->requireLogin();
			if(empty($id)) $ide->goPrevious();
			$this->load->model("house_model");
			$data = array();
			$data['house'] = $this->house_model->loadHouse($id);
			if(empty($data['house'])) $ide->goPrevious();
			if(!empty($data['house'][0]['owner'])) $ide->goPrevious();
			if(empty($data['house'][0]['bid'])) $ide->redirect(WEBSITE."/index.php/houses/start_auction/".$id);
			if($data['house'][0]['guild'] == 0) 
				$data['characters'] = $this->house_model->getAllowedCharacters($data['house'][0]['world_id']);
			else
				$data['characters'] = $this->house_model->getAllowedGuildCharacters($data['house'][0]['world_id']);
			if($data['house'][0]['endtime'] > time()) $ide->redirect(WEBSITE."/houses/view/".$id);
			$data['id'] = $id;
			$this->load->helper("form_helper");
				if($_POST) {
					$this->load->library("form_validation");
					$this->form_validation->set_rules('bid', 'Bid', 'required|integer|callback__checkBid');
					$this->form_validation->set_rules('character', 'Character', 'required|integer|callback__checkCharacter');
					if($this->form_validation->run() == true) {
						$new = $data['house'][0]['limit']+1;
						$this->house_model->newBid($id, $_POST['character'], $_POST['bid'], $new, $data['house'][0]['world_id']);
						$ide->redirect(WEBSITE."/index.php/houses/view/".$id);
					}
				}
			$this->load->view("join_house_auction", $data);
			
		}
		
		public function abandon($id) {
			$ide = new IDE;
			$id = (int)$id;
			$ide->requireLogin();
			if(empty($id)) $ide->goPrevious();
			$this->load->model("house_model");
			$house = $this->house_model->loadHouse($id);
			if(empty($house)) $ide->goPrevious();
			$characters = $this->house_model->getCharactersName();
			if(in_multiarray($house[0]['owner'], $characters)) {
				$this->house_model->abandon($id);
				$ide->goPrevious();
			}
			else
				$ide->goPrevious();
		}
		
		
		
	}

?>
and
gesior:
houses.php

LUA:
<?PHP
    $main_content .= '<form method="post" action=""><table>';
    if(count($config['site']['worlds']) > 1)
    {
        if(isset($_POST['world']) and is_numeric($_POST['world']))
        {
            $wid = (int) $_POST['world'];
            $wid = '<option value='.$wid.'>'.$config['site']['worlds'][$wid].'</option>';
        }
        $select_w .= '<tr><td>Select World:</td><td><select name="world" onchange="submit()">'.$wid.'';
        $i=1;
        foreach($config['site']['worlds'] as $id => $world_n)
        {
            if($_POST['world'] != $id)
            {
                $worlds[$i] .= '<option value="'.$id.'">'.$world_n.'</option>';
            }
            if($id == (int) $_POST['world'])
            {
                $world_id = $id;
                $world_name = $world_n;
            }
            $i++;
        }
        
        $main_content .= ''.$select_w.'';
        for($i=0;$i <= count($config['site']['worlds']); $i++)
        {
            $main_content .= ''.$worlds[$i].'';
        }
        $main_content .= '</td></tr></select>';
    }

    if(!isset($world_id))
    {
        $world_id = 0;
        $world_name = $config['server']['serverName'];
    }
    
    if(count($towns_list) > 1)
    {
        if(isset($_POST['town']) and is_numeric($_POST['town']))
        {
            $pid = (int) $_POST['town'];
            $pid = '<option value='.$pid.'>'.$towns_list[$world_id][$pid].'</option>';
        }
        else
        {
            $pid = '<option value="all">All</option>';
            $all=true;
        }
        $select .= '<tr><td>Select City:</td><td><select name="town" onchange="submit()">'.$pid.'';
        $i=1;
        foreach($towns_list[$world_id] as $id => $town_n)
        {
            if($_POST['town'] != $id)
            {
                $towns[$i] .= '<option value="'.$id.'">'.$town_n.'</option>';
            }
            if($id == (int) $_POST['town'])
            {
                $town_id = $id;
                $town_name = $town_n;
            }
            $i++;
        }

        $main_content .= ''.$select.'';
        for($i=1;$i <= count($towns_list[$world_id]); $i++)
        {
            $main_content .= ''.$towns[$i].'';
        }
        if(!$all)
            $main_content .= '<option value="all">All</option>';
            
        $main_content .= '</td></tr></select>';
    }
    if(isset($town_id))
    {
        $a_status = array(1 => "Empty", "Rented", "All");
        
        if(isset($_POST['status']) and is_numeric($_POST['status']))
        {
            $sid = (int) $_POST['status'];
            $sid = '<option value='.$sid.'>'.$a_status[$sid].'</option>';
            if($_POST['status'] == 1)
                $s[1] = true;
            elseif($_POST['status'] == 2)
                $s[2] = true;
            elseif($_POST['status'] == 3)
                $s[3] = true;
        }
        $main_content .= '<tr><td>Select by status:</td><td><select name="status" onchange="submit()">'.$sid.'';
        if(!$s[3])
            $main_content .= '<option value="3">All</opyion>';
        if(!$s[2])
            $main_content .= '<option value="2">Rented</option>';
        if(!$s[1])
            $main_content .= '<option value="1">Empty</option>';
        $main_content .= '</td></tr></select>';
        
    }
        
    $main_content .= '</table></form>';
    
    if(isset($_POST['status']))
    {
        if($_POST['status'] == 1)
            $stat = "and `owner` = ''";
        elseif($_POST['status'] == 2)
            $stat = "and `owner` > 0";
    }
    
    if(!isset($town_id))
    {
        $houses_info = $SQL->query("SELECT * FROM `houses` WHERE `world_id` = ".$world_id." ORDER BY `town` , `name`");
        $towns_all = true;
    }
    
    $main_content .= '<h2><center>Houses on '.$config['site']['worlds'][(int) $_GET['world']].'</h2></center>';
    $main_content .= '<center><table WIDTH=90%><tr bgcolor="'.$config['site']['vdarkborder'].'"><td><font color="white"><b>Address</b></font></td><td><font color="white"><b>Size</b></font></td><td><font color="white"><b>Price</b></font></td><td><font color="white"><b>City</b></font></td><td><font color="white"><b>Status</b></font></td></tr>';
    $number_of_rows = 1;
    if(!$towns_all)
        $houses_info = $SQL->query("SELECT * FROM `houses` WHERE `world_id` = ".$world_id." and `town` = ".$town_id." ".$stat." ORDER BY `name`");
    $players_info = $SQL->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` , `accounts`.`premdays` AS `premdays` , `accounts`.`lastday` AS `lastlogin` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`");
    $players = array();
    foreach($players_info->fetchAll() as $player)
        $players[$player['houseid']] = array('name' => $player['ownername'], 'days' => $player['premdays'], 'last' => $player['lastlogin']);
    foreach($houses_info->fetchAll() as $house)
    {
        $owner = $players[$house['id']];
        if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
        $main_content .= '<tr bgcolor="'.$bgcolor.'"><td>'.$house['name'].'</td><td align="right" width="35">'.$house['size'].'</td><td align="right" width="65">'.($house['price'] / 1000).'k gp</td><td>'.$towns_list[(int) $house['world_id']][(int) $house['town']].'</td><td>';
        if(!empty($owner['name']))
        {    
            if($owner['deleted'] > 0)
                $status='<font color=red><b>[DELETED]</b></font>';
                
            if(isPremium($owner['days'], $owner['last']))
            {
                $main_content .= 'Rented by <a href="?subtopic=characters&name='.urlencode($owner['name']).'">'.$owner['name'].'</a>'.$status.'';
            }
            else
            {
                $main_content .= 'Rented by <a href="?subtopic=characters&name='.urlencode($owner['name']).'">'.$owner['name'].'</a>'.$status.' (FACC)';
            }
        }
        else
        {
            $main_content .= 'Empty';
        }
        $main_content .= '</td></tr>';
    }
    $main_content .= '</TABLE></center>';
?>
 
Back
Top