Account Maker problem z account.php

mafa123

User
Zarejestrowany
Dołączył
Luty 16, 2015
Posty
48
Liczba reakcji
0
witam na php znam si? s?abo mo?e kto? pomo?e mi naprawi? ten b??d
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\account.php on line 168
PHP:
<?php 
/*
    Copyright (C) 2007 - 2009  Nicaw

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
include ("include.inc.php");

try {
    $account = new Account();
    $account->load($_SESSION['account']);
} catch(AccountNotFoundException $e) {
    $_SESSION['account'] = '';
    header('location: login.php?redirect=account.php');
    die();
}
$ptitle="Account - $cfg[server_name]";
include ("header.inc.php");
?>
<div id="content">
<div class="top">Account</div>
<div class="mid">
<table style="width: 100%">
<tr style="vertical-align: top"><td style="width: 200px;">
<h3>Pick a Task</h3>
<ul class="task-menu">
<li onclick="ajax('ajax','modules/character_create.php','',true)" style="background-image: url(resource/user_add.png);">Create Character</li>
<li onclick="self.window.location.href='add_player.php'" style=" background-image: url(resource/add.png);">Add Character to shop</li>
<li onclick="self.window.location.href='remove_player.php'" style=" background-image: url(resource/cross.png);">Remove Character from shop</li>
 
<li onclick="ajax('ajax','modules/character_delete.php','',true)" style="background-image: url(resource/user_delete.png);">Delete Character</li>
<?php if ($cfg['char_repair']){?>
<li onclick="ajax('ajax','modules/character_repair.php','',true)" style="background-image: url(resource/user_edit.png);">Repair Character</li>
<?php }?>
<li onclick="ajax('ajax','modules/account_password.php','',true)" style="background-image: url(resource/key.png);">Change Password</li>
<li onclick="ajax('ajax','modules/account_email.php','',true)" style="background-image: url(resource/email.png);">Change Email</li>
<li onclick="ajax('ajax','modules/account_comments.php','',true)" style="background-image: url(resource/page_edit.png);">Edit Comments</li>
<li onclick="ajax('ajax','modules/account_options.php','',true)" style="background-image: url(resource/wrench.png);">Account Options</li>
<li onclick="ajax('ajax','modules/guild_create.php','',true)" style="background-image: url(resource/group_add.png);">Create Guild</li>
<li onclick="window.location.href='login.php?logout&redirect=account.php'" style="background-image: url(resource/resultset_previous.png);">Logout</li>
</ul>
</td><td style="width: 130px;">
<?php 
if ($account->players){
	echo '<h3>Characters</h3>'."\n";
	echo '<ul class="task-menu">';
	foreach ($account->players as $player){
		echo '<li style="background-image: url(resource/user.png);" onclick="window.location.href=\'characters.php?player_id='.htmlspecialchars($player['id']).'\'">'.htmlspecialchars($player['name']).'</li>';
	}
	echo '</ul>';
}
if ($account->guilds){
	echo '<h3>Guilds</h3>'."\n";
	echo '<ul class="task-menu">';
	foreach ($account->guilds as $guild){
		echo '<li style="background-image: url(resource/group.png);" onclick="window.location.href=\'guilds.php?guild_id='.htmlspecialchars($guild['id']).'\'">'.htmlspecialchars($guild['name']).'</li>';
	}
	echo '</ul>';
}
?>
</td></tr>
</table>
<?php
if(isset($account->attrs['premend']) && $account->attrs['premend'] > time()) {
    echo '<b>Premium status:</b> You have ';
    $days = ceil(($account->attrs['premend'] - time())/(3600*24));
    if($days <= 5) echo '<b style="color: red">';
        else echo '<b>';
    echo $days.'</b> day(s) left';
}
?>

</br>
 
<?php
if ($account->attrs['points']) {
    echo '<b>Shop points status:</b> You have ';
    $points = ceil(($account->attrs['points']));
    if($points <= 5) echo '<b style="color: red">';
        else echo '<b>';
   echo $points.'</b> point(s)';
}
$acc = $account->attrs['accno'];
 
    echo '<h3>Characters in Shop</h3>'."\n";
   
    $wynik44 = mysql_query("SELECT id, name, level, vocation, price FROM players WHERE shop = 1 AND account_id = $acc")
    or die('query error');
   
    if(mysql_num_rows($wynik44) > 0) {
 
        echo "<table class=color2 bordercolor=#FFFFFF width=100% cellpadding=4 cellspacing=0 border=1>";
 
        echo "<th class=color0>Name:</th>    <th class=color0>Level:</th>     <th class=color0>Vocation:</th>  <th class=color0>Points:</th></th>";
 
        echo "<tr>";
       
        while($r = mysql_fetch_assoc($wynik44))
        {
            $id_player = $r['id'];
   
            echo ' <td><center><a href="characters.php?player_name='.($r['name']).'">'.$r['name'].'</a></center></td>';
       
            echo "<td><center> ".$r['level']."</center></td>";
           
            if ($r['vocation'] == 1)
                {
                echo "<td><center> Sorcerer</center></td>";
                }
                elseif ($r['vocation'] == 2)
                {
                echo "<td><center> Druid</center></td>";
                }
                elseif ($r['vocation'] == 3)
                {
                echo "<td><center> Paladin</center></td>";
                }
                elseif ($r['vocation'] == 4)
                {
                echo "<td><center> Knight</center></td>";
                }
                elseif ($r['vocation'] == 5)
                {
                echo "<td><center> Master Sorcerer</center></td>";
                }
                elseif ($r['vocation'] == 6)
                {
                echo "<td><center> Elder Druid</center></td>";
                }
                elseif ($r['vocation'] == 7)
                {
                echo "<td><center> Royal Paladin</center></td>";
                }
                elseif ($r['vocation'] == 8)
                {
                echo "<td><center> Elite Knight</center></td>";
                }
 
           
                echo "<td><center>".$r['price']."</center></td>";
             
                echo "</tr>";
        }
        echo "</table>";
   
    }
    else
    {
    echo '<img src="resource/user_red.png"/>';
    echo " You don't have player in shop";
    }
 



<div id="ajax"></div>
</div>
<div class="bot"></div>
</div>
<?php 
include ("footer.inc.php");
?>
 
Odp: problem z account.php

jeszcze taki b??d tworzeniu nowego konta


Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in C:\xampp\htdocs\class\sql.php on line 174

Fatal error: Uncaught exception 'DatabaseQueryException'
Message: Error #1054:Unknown column 'premend' in 'field list'
SQL query: INSERT INTO `accounts` (`name`,`password`,`premend`,`points`,`email`) VALUES (2442523,'xxxxxx',1517498450,50,'xxxx@wp.pl' );
File: sql.php on line: 94
Script was terminated because something unexpected happened. You can report this, if you think it's a bug.

Debug Backtrace:Disabled


PHP:
<?php
/*
     Copyright (C) 2007 - 2009  Nicaw

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
class SQL {
    private
    $sql_connection,
    $schema_version,
    $sql_tables,
    $last_query,
    $last_insert_id;

    //creates new connection
    public function __construct($server, $user, $password, $database) {

        //warn if MySQL extension is not installed
        if(!extension_loaded('mysql'))
            throw new LibraryMissingException('MySQL library is not installed. Database access is impossible.', 0);

        //establish a link to MySQL
        $con = [MENTION=17684]mysql[/MENTION]_connect($server,$user,$password);
        if ($con === false)
            throw new DatabaseConnectException('Unable to connect to mysql server. Please make sure it is up and running and you have correct user/password in config.inc.php.', 1);

        //select otserv database
        if (!mysql_select_db($database))
            throw new DatabaseSelectException('Unable to select database: '.$database.'. Make sure it exists.', 2);

        //retrieve table list
        $result = mysql_query('SHOW TABLES');
        if ($result === false)
            DatabaseQueryException('Failed to retrieve a table list.');

        while ($a = mysql_fetch_array($result))
            $this->sql_tables[] = $a[0];

        //retrieve schema version
        $result = mysql_query('SELECT value FROM schema_info WHERE name = \'version\'');
        if ($result === false) {
            $this->schema_version = false;
        } else {
            $a = mysql_fetch_array($result);
            $this->schema_version = $a['value'];
        }

        //assign the connection
        $this->sql_connection = $con;

        return true;
    }

    public function getSchemaVersion() {
        return $this->schema_version;
    }

    public function isTable($mixed) {
        return in_array($mixed, $this->sql_tables);
    }

    public function __destruct() {
        if(is_resource($this->last_query))
            mysql_free_result($this->last_query);
        mysql_close($this->sql_connection);
    }

    //Creates tables
    public function setup() {
        $tables = explode(';', file_get_contents('documents/shema.mysql'));
        foreach ($tables as $table) mysql_query($table);
    }

    //Perform simple SQL query
    public function myQuery($q) {
        if(is_resource($this->last_query))
            mysql_free_result($this->last_query);
        $this->last_query = mysql_query($q, $this->sql_connection);
        $this->last_insert_id = mysql_insert_id();
        if ($this->last_query === false) {
            $this->analyze();
            throw new DatabaseQueryException('Error #'.mysql_errno().':'.mysql_error(), $q);
        }
        return $this->last_query;
    }

    //True is last query failed
    public function failed() {
        if ($this->last_query === false) return true;
        return false;
    }

    //Returns current array with data values
    public function fetch_array() {
        if (!$this->failed())
            if (isset($this->last_query))
                return mysql_fetch_array($this->last_query);
            else
                throw new ClassException('Attempt to fetch a null query.');
        else
            throw new ClassException('Attempt to fetch failed query.');
    }

    //Returns the last insert id
    public function insert_id() {
        return $this->last_insert_id;
    }

    //Returns the number of rows affected
    public function num_rows() {
        if (!$this->failed())
            return mysql_num_rows($this->last_query);
        else
            throw new ClassException('Attempt to count failed query.');
    }

    //Quotes a string
    public function escape_string($string) {
        return mysql_real_escape_string($string);
    }

    //Quotes a value so it's safe to use in SQL statement
    public function quote($value) {
        if(is_numeric($value) && $value[0] != '0')
            return (int) $value;
        else
            return '\''.$this->escape_string($value).'\'';
    }

    public function analyze() {
    //determine database type, try to perform autosetup
        $is_aac_db = in_array('nicaw_accounts',$this->sql_tables);
        $is_server_db = in_array('accounts',$this->sql_tables) && in_array('players',$this->sql_tables);
        $is_svn = in_array('player_depotitems',$this->sql_tables) && in_array('groups',$this->sql_tables);
        $is_cvs = in_array('playerstorage',$this->sql_tables) && in_array('skills',$this->sql_tables);
        if (!$is_aac_db) {
            $this->setup();
            throw new DatabaseException('Notice: AutoSetup has attempted to create missing tables for you. Please create MySQL tables manually from "database.sql" if you are still getting this message.', 3);
        }elseif (!$is_server_db) {
            throw new DatabaseException('It appears you don\'t have SQL sample imported for OT server or it is not supported.', 4);
        }elseif ($is_cvs && !$is_svn) {
            throw new DatabaseException('This AAC version does not support your server. Consider using SQL v1.5.', 5);
        }
        return true;
    }

    public function repairTables() {
        if (isset($this->sql_tables))
            foreach($this->sql_tables as $table)
                mysql_query('REPAIR TABLE '.$table);
        return true;
    }

    ######################################
    # Methods for simple  data access    #
    ######################################

    //Insert data
    public function myInsert($table,$data) {global $cfg;
        $fields = array_keys($data);
        $values = array_values($data);
        $query = 'INSERT INTO `'.mysql_escape_string($table).'` (';
        foreach ($fields as $field)
            $query.= '`'.mysql_real_escape_string($field).'`,';
        $query = substr($query, 0, strlen($query)-1);
        $query.= ') VALUES (';
        foreach ($values as $value)
            if ($value === null)
                $query.= 'NULL,';
            else
                $query.= $this->quote($value).',';
        $query = substr($query, 0, strlen($query)-1);
        $query.= ');';
        $this->myQuery($query);
        return true;
    }

    //Replace data
    public function myReplace($table,$data) {global $cfg;
        $fields = array_keys($data);
        $values = array_values($data);
        $query = 'REPLACE INTO `'.mysql_escape_string($table).'` (';
        foreach ($fields as $field)
            $query.= '`'.mysql_escape_string($field).'`,';
        $query = substr($query, 0, strlen($query)-1);
        $query.= ') VALUES (';
        foreach ($values as $value)
            if ($value === null)
                $query.= 'NULL,';
            else
                $query.= $this->quote($value).',';
        $query = substr($query, 0, strlen($query)-1);
        $query.= ');';
        $this->myQuery($query);
        return true;
    }

    //Retrieve single row
    public function myRetrieve($table,$data) {
        $fields = array_keys($data);
        $values = array_values($data);
        $query = 'SELECT * FROM `'.mysql_real_escape_string($table).'` WHERE (';
        for ($i = 0; $i < count($fields); $i++)
            $query.= '`'.mysql_real_escape_string($fields[$i]).'` = '.$this->quote($values[$i]).' AND ';
        $query = substr($query, 0, strlen($query)-4);
        $query.=');';
        $this->myQuery($query);
        if ($this->num_rows() != 1) return false;
        return $this->fetch_array();
    }

    //Update data
    public function myUpdate($table,$data,$where,$limit=1) {
        $fields = array_keys($data);
        $values = array_values($data);
        $query = 'UPDATE `'.mysql_escape_string($table).'` SET ';
        for ($i = 0; $i < count($fields); $i++)
            $query.= '`'.mysql_escape_string($fields[$i]).'` = '.$this->quote($values[$i]).', ';
        $query = substr($query, 0, strlen($query)-2);
        $query.=' WHERE (';
        $fields = array_keys($where);
        $values = array_values($where);
        for ($i = 0; $i < count($fields); $i++)
            $query.= '`'.mysql_escape_string($fields[$i]).'` = '.$this->quote($values[$i]).' AND ';
        $query = substr($query, 0, strlen($query)-4);
        if (isset($limit))
            $query.=') LIMIT '.$limit.';';
        else
            $query.=');';
        $this->myQuery($query);
        return true;
    }

    //Delete data
    public function myDelete($table,$data,$limit = 1) {
        $fields = array_keys($data);
        $values = array_values($data);
        $query = 'DELETE FROM `'.mysql_escape_string($table).'` WHERE (';
        for ($i = 0; $i < count($fields); $i++)
            $query.= '`'.mysql_escape_string($fields[$i]).'` = '.$this->quote($values[$i]).' AND ';
        $query = substr($query, 0, strlen($query)-4);
        if ($limit > 0)
            $query.=') LIMIT '.$limit.';';
        else
            $query.=');';
        $this->myQuery($query);
        return true;
    }
}
?>
 
Ostatnia edycja:
Odp: problem z account.php

Nie masz kolumny 'premend' w bazie danych.
 
Odp: problem z account.php

w accounts mam doda? ? bo nie wiem za bardzo

ALTER TABLE `accounts` ADD `premend` int(11) NOT NULL
 
Back
Do góry