Autor Zpráva
jullin
Profil
Dobrý den mám takový problém. když vyplním pole v této této registraci a potvrdím vypíše mi to hlášku UPDATE alts SET char_name = 'xxx', char_class = 'xxx', char_use = 'xxx' WHERE user_id = 'xxx' AND ord = '1': Unknown column 'char_use' in 'field list' a doopravdy nevím v čem je chyba.

<?
session_start();
include "global.cfg." .$_SERVER['SERVER_NAME']. ".php";
include $incPath."db.php";
include $incPath."misc.php";

 if ($_REQUEST['ac'] == "edit") authorize("", true);

if ($_REQUEST['sent']){
    
    if (!$_REQUEST['username'] || !$_REQUEST['password'] || !$_REQUEST['guild']){
        $err = "Musis vyplnit nickname, heslo a guildu.";
    }
    
    if ($_REQUEST['ac'] == "insert"){
        $q = "SELECT username FROM users WHERE username = '".$_REQUEST['username']."'";
        $r = dbquery($q);
        if (dbnumrows($r)) $err .= "<br>Tuto prezdivku (".$_REQUEST['username'].") uz nekdo pouziva.";
    }
    
    for ($i = 1; $i < 6; $i++){
        if ($_REQUEST['char_name_'.$i] && !$_REQUEST['char_class_'.$i]){
            $err .= "<br>Ke kazde postave musis vyplnit jeji classu.";
            break;
        }
        if ($_REQUEST['char_name_'.$i] && !$_REQUEST['char_use_'.$i]){
            $err .= "<br>Ke kazde postave musis vyplnit jeji vyuziti.";
            break;
        }
    }

    if (!$err){
        switch ($_REQUEST['ac']){
            case "insert":
                $q = "INSERT INTO users (username, reg_date, rights) VALUES ('".$_REQUEST['username']."','".date("Y-m-d H:i:s")."','2')";
                $r = dbquery($q);
                $q_print.="$q<br><br>";
                $id = dblastid($r);
                
                if (!$id) $id = $_SESSION['user']['id'];
                
                for ($i = 1; $i < 6; $i++){
                    $q = "INSERT INTO alts (ord, user_id) VALUES ('$i', '$id')";
                    dbquery($q);
                }
                
                //zalozeni uzivatele i v tabulce prav
                $q = "INSERT INTO rights (user_id) VALUES ('$id')";
                dbquery($q);
                
            case "edit":
                if (!$id) $id = $_SESSION['user']['id'];
                if (!$_REQUEST['email_use']) $_REQUEST['email_use'] = 0;
                
                $q = "UPDATE users SET password = '".$_REQUEST['password']."', guild = '".$_REQUEST['guild']."', email = '".$_REQUEST['email']."', email_use = '".$_REQUEST['email_use']."' WHERE id = '$id'";
                $r = dbquery($q);
                
                for ($i = 1; $i < 6; $i++){
                    $q = "UPDATE alts SET char_name = '".$_REQUEST['char_name_'.$i]."', char_class = '".$_REQUEST['char_class_'.$i]."', char_use = '".$_REQUEST['char_use_'.$i]."' WHERE user_id = '$id' AND ord = '$i'";
                    $q_print.="$q<br><br>";
                    dbquery($q);
                }
                
        }
        
        switch ($_REQUEST['ac']){
            case "insert":
                header("Location: index.php?error=2");
                break;
            case "edit":
                $err = "Data zmenena.";
                break;
        }
    }
}

if ($_REQUEST['sent']){
    $data['username'] = $_REQUEST['username'];
    $data['password'] = $_REQUEST['password'];
    $data['guild'] = $_REQUEST['guild'];
    $data['email'] = $_REQUEST['email'];
    $data['email_use'] = $_REQUEST['email_use'];
    for ($i = 1; $i < 6; $i++){
        $data['char_name_'.$i] = $_REQUEST['char_name_'.$i];
        $data['char_class_'.$i] = $_REQUEST['char_class_'.$i];
        $data['char_use_'.$i] = $_REQUEST['char_use_'.$i];
    }
}else if ($_REQUEST['ac'] == "edit"){
    $q = "SELECT * FROM users LEFT OUTER JOIN alts ON users.id = alts.user_id WHERE users.id = '".$_SESSION['user']['id']."' ORDER BY alts.ord ASC";
    $r = dbquery($q);
    $q_print.="$q<br><br>";

    $dataSelect = dbarray($r);
    $data['username'] = $dataSelect['username'];
    $data['password'] = $dataSelect['password'];
    $data['guild'] = $dataSelect['guild'];
    $data['email'] = $dataSelect['email'];
    $data['email_use'] = $dataSelect['email_use'];
    $data['char_name_1'] = $dataSelect['char_name'];
    $data['char_class_1'] = $dataSelect['char_class'];
    $data['char_use_1'] = $dataSelect['char_use'];
    $i = 2;
    while ($dataSelect = dbarray($r)){
        $data['char_name_'.$i] = $dataSelect['char_name'];
        $data['char_class_'.$i] = $dataSelect['char_class'];
        $data['char_use_'.$i] = $dataSelect['char_use'];
        $i++;
    }
}

?>
Joker
Profil
jullin:
V dotazu se používá sloupec jménem char_use, který v tabulce neexistuje.
jullin
Profil
No jo :) bylo to tak => vyřešeno přidáním tabulky.

Děkuji
Toto téma je uzamčeno. Odpověď nelze zaslat.