ich habe mal wieder ein kleines Problemchen ^^
Also folgenes:
Ich habe ein eigenes Modul geschrieben, indem unsere Member bis zu fünf Charaktere eintragen können. Diese werden in der Tabelle prefix_user gespeichert. Das funktioniert soweit auch wunderbar (*freu*).
Nun möchte ich zusätzlich, dass in den Datensätzen von prefix_warmember ein paar zusätzliche Daten, auf Grundlage der neuen Tabellen/Datensätze (bzw. Charakter Daten) ein paar weitere Informationen als nur uid,wid,aktion,kom gespeichert werden. Dafür habe ich zu Testzwecken die Tabelle "char" in der prefix_warmember.
Abschließend frage ich mit folgenem Zeilen in wars.php die Daten aus prefix_user ab:
Ab Zeile: 159
<?php [.....] #Charakter-Informer $abf2 = 'SELECT nchar1,cchar1,hchar1,gchar1,achar1,nchar2,cchar2,hchar2,gchar2,achar2,nchar3,cchar3,hchar3,gchar3,achar3,nchar4,cchar4,hchar4,gchar4,achar4,nchar5,cchar5,hchar5,gchar5,achar5 FROM `prefix_user` WHERE id = "'.$_SESSION['authid'].'"'; $erg2 = db_query($abf2); $row2 = db_fetch_assoc($erg2); $tpl->set_ar_out($row2,5);
In der wars_next.htm wird dann noch folgenes hinzugefügt (natürlich noch nicht fertig, erstmal nur aus Testzwecken, damit ich weiß wie das Script drauf reagiert):
<select name="char"> <option value="1">{nchar1} - {cchar1}</option> <option value="2">{nchar2} - {cchar2}</option> <option value="3">{nchar3} - {cchar3}</option> <option value="4">{nchar4} - {cchar4}</option> <option value="2">{nchar5} - {cchar5}</option> </select>
Ich werd die Daten für nchar1 etc. später natürlich noch andersweitig einbringen, erstmal will ich, dass in der "char"-Tabelle (prefix_warmember) die Zahlen von 1 bis 5 (je nach Auswahl) gespeichert werden.
Nun füge ich in die wars.php folgenes ein:
Ab Zeile 195
<?php [.....] $char = escape($_POST['char'],'string'); $aktion = ( $_POST['sub'] == 'zusagen' ? 1 : 0 ); #so schon vorhanden $kom = escape($_POST['kom'],'string'); #so schon vorhanden db_query("INSERT INTO prefix_warmember (uid,wid,char,aktion,kom) VALUES (".$_SESSION['authid'].",".$_GET['mehr'].",".$char.",".$aktion.",'".$kom."')");
Will ich (oder ein Member) mich zu einem War/Raid anmelden, erhalte ich folgenen Fehler:
MySQL Error:
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 'char,aktion,kom) VALUES (24,30,1,1,'ws')' at line 1
in Query:
INSERT INTO `ic1_warmember` (uid,wid,char,aktion,kom) VALUES (24,30,1,1,'ws')
Debug backtrace:
@ mysql.php:32 -- debug_bt()
@ mysql.php:50 -- db_check_error(...)
@ wars.php:199 -- db_query(...)
@ index.php:25 -- require_once(...)
Soweit scheint ja schon alles gut zu funktionieren (immerhin wird die Zahl 1 bei dem Test übertragen ^^)
Eine Goolge Suche nach dem Fehler hat leider ziemlich nicht viel gebracht, da dieser Fehler wohl ganz viele verschiedene Fehlerquellen haben könnte. Scheinbar wurde von mir aber irgendwas vergessen, daher meine Frage: Gibt es vielleicht noch andere Stellen wo ich den char-wert irgendeiner Abfrage hinzufügen muss oder habe ich einfach nur einen dämmlichen Fehler gemacht?
Bin über jede Hilfe dankbar.
Zu guter letzt noch:
wars.php
<?php # Copyright by: Manuel # Support: www.ilch.de defined ('main') or die ( 'no direct access' ); function get_erg_liste($wid) { $list = ''; $enar = array ( 'jpg', 'gif', 'png', 'jpeg'); $erg = db_query("SELECT * FROM prefix_warmaps WHERE wid = ".$wid); while($row = db_fetch_assoc($erg) ) { if ( $row['opp'] == $row['owp'] ) { $farbe = 'FDFBB7'; #pat } elseif ( $row['opp'] < $row['owp'] ) { $farbe = 'C8E1B8'; #win } elseif ( $row['opp'] > $row['owp'] ) { $farbe = 'D8B9B9'; #los } foreach($enar as $v) { if ( file_exists ( 'include/images/wars/'.$wid.'_'.$row['mnr'].'.'.$v ) ) { $size=getimagesize('include/images/wars/'.$wid.'_'.$row['mnr'].'.'.$v); $breite=$size[0]; $hoehe=$size[1]; $row['map'] = '<a href="#" onClick="javascript:window.open(\'include/images/wars/'.$wid.'_'.$row['mnr'].'.'.$v.'\',\'bild\',\'height='.$hoehe.',width='.$breite.'\')">'.$row['map'].'</a>'; break; } } $list .= '<tr bgcolor="#'.$farbe.'">'; $list .= '<td><font color="#000000">'.$row['map'].'</font></td>'; $list .= '<td><font color="#000000">'.$row['opp'].'</font></td>'; $list .= '<td><font color="#000000">'.$row['owp'].'</font></td>'; $list .= '</tr>'; } return ($list); } function lastwars_get_memberlist ( $id ) { $l = ''; $erg = db_query("SELECT prefix_user.id,prefix_user.name FROM prefix_user LEFT JOIN prefix_warmember ON prefix_warmember.uid = prefix_user.id AND prefix_warmember.wid = ".$id." WHERE wid = ".$id." ORDER BY prefix_user.name ASC"); while($r = db_fetch_assoc($erg)) { $l .= '<a href="index.php?user-details-'.$r['id'].'">'.$r['name'].'</a>, '; } return (substr($l,0,-2)); } if ( $menu->get(2) == '' OR $menu->getA(2) == 'p' ) { $title = $allgAr['title'].' :: Wars'; $hmenu = 'Wars'; $design = new design ( $title , $hmenu ); $design->header(); $ergWin = db_query('SELECT COUNT(id) FROM `prefix_wars` WHERE wlp = "1"'); $anzWin = db_result($ergWin,0); $ergLos = db_query('SELECT COUNT(id) FROM `prefix_wars` WHERE wlp = "2"'); $anzLos = db_result($ergLos,0); $ergPat = db_query('SELECT COUNT(id) FROM `prefix_wars` WHERE wlp = "3"'); $anzPat = db_result($ergPat,0); $ergGes = db_query('SELECT COUNT(id) FROM `prefix_wars` WHERE status= "3"'); $anzGes = db_result($ergGes,0); $tpl = new tpl ( 'wars.htm' ); $tpl->set_ar_out ( array('PAT' => $anzPat, 'WIN' => $anzWin, 'LOS' => $anzLos, 'GES' => $anzGes, 'TITLE'=> $allgAr['title'] ) , 0 ); $akttime = date('Y-m-d'); $class = ''; $erg = db_query("SELECT a.id,a.gegner,a.page,a.game,b.name as team,DATE_FORMAT(datime,'%d.%m.%Y - %H:%i:%s') as time FROM prefix_wars a left join prefix_groups b ON a.tid = b.id WHERE status = 2 AND a.datime >= '".$akttime."' ORDER BY a.datime"); if ( db_num_rows ( $erg ) == 0 ) { echo '<tr class="Cmite"><td colspan="4"><strong>kein Next War vorhanden</strong></td></tr>'; } else { while ($row = db_fetch_assoc($erg) ) { if ( $class == 'Cmite' ) { $class = 'Cnorm'; } else { $class = 'Cmite'; } $row['page'] = get_homepage($row['page']); $row['team'] = get_wargameimg($row['game']).' '.$row['team']; $row['class'] = $class; $tpl->set_ar_out($row,1); } } $tpl->out(2); $class = ''; if ( $menu->get(1) == '' ) { $teams = dblistee ( '', "SELECT id,name FROM prefix_groups ORDER BY name"); $game= dblistee ('', "SELECT DISTINCT `game`,`game` FROM prefix_wars ORDER BY `game`" ); $mtype= dblistee ( '', "SELECT DISTINCT `mtyp`,`mtyp` FROM prefix_wars ORDER BY `mtyp`" ); $tpl->set_ar_out ( array('tid' => $teams, 'game' => $game, 'typ' => $mtype ) , 3 ); } elseif ($menu->get(1) == 'last') { $tpl->out(4); $sqla='WHERE status = 3 '; if(!empty($_POST['tid'])){ $sqla.= 'AND tid="'.$_POST['tid'].'" '; } if(!empty($_POST['wpl'])){ $sqla.= 'AND wlp="'.$_POST['wpl'].'" '; } if(!empty($_POST['spiel'])){ $sqla.= 'AND game="'.$_POST['spiel'].'" '; } if(!empty($_POST['typ'])){ $sqla.= 'AND mtyp="'.$_POST['typ'].'" '; } # seiten funktion $limit = $allgAr['wars_last_limit']; // Limit $page = ( $menu->getA(2) == 'p' ? $menu->getE(2) : 1 ); $MPL = db_make_sites ($page , "WHERE status = 3" , $limit , "?wars-last" , 'wars' ); $anfang = ($page - 1) * $limit; # seiten funktion $farbe1wlpar = array(1=>'C8E1B8',2=>'D8B9B9',3=>'FDFBB7'); $farbe2wlpar = array(1=>'00FF00',2=>'FF0000',3=>'FFFF00'); $erg = db_query("SELECT a.owp,a.opp,a.wlp,a.land,a.mtyp,a.game,a.id,a.gegner,a.page,b.name as team,DATE_FORMAT(datime,'%d.%m.%Y') as time FROM prefix_wars a left join prefix_groups b ON a.tid = b.id ".$sqla." ORDER BY a.datime DESC, id DESC LIMIT ".$anfang.",".$limit); while ($row = db_fetch_assoc($erg) ) { $row['erg'] = $row['opp'].':'.$row['owp']; $row['farbe'] = $farbe1wlpar[$row['wlp']]; $row['farbe2'] = $farbe2wlpar[$row['wlp']]; if ( $class == 'Cmite' ) { $class = 'Cnorm'; } else { $class = 'Cmite'; } $row['page'] = get_homepage($row['page']); $row['team'] = get_wargameimg($row['game']).' '.$row['team']; $row['class'] = $class; $tpl->set_ar_out($row,5); } $tpl->out(6); echo $MPL; } $design->footer(); } elseif ( is_numeric($menu->get(2)) ) { $_GET['mehr'] = escape($menu->get(2),'integer'); $erg = @db_query("SELECT DATE_FORMAT(datime,'%d.%m.%Y') as datum, tid, status, owp, opp, wlp, DATE_FORMAT(datime,'%H:%i:%s') as zeit, gegner, tag, page, mail, icq, wo, prefix_wars.`mod`, mtyp, game, land, txt, prefix_wars.id, name as team FROM prefix_wars left join prefix_groups ON prefix_wars.tid = prefix_groups.id WHERE prefix_wars.id = ".$_GET['mehr']); db_check_erg ($erg); $row = db_fetch_assoc($erg); $row['page'] = get_homepage($row['page']); $row['txt'] = bbcode($row['txt']); if ( $row['status'] == 2 ) { # nextwars $title = $allgAr['title'].' :: Wars :: Nextwars'; $hmenu = '<a href="?wars" class="smalfont">Wars</a><b> » </b>Nextwars'; $design = new design ( $title , $hmenu ); $design->header(); $tpl = new tpl ('wars_next'); $row['tag'] = ( empty($row['tag']) ? $row['gegner'] : $row['tag'] ); if ( $_SESSION['authright'] <= -3 ) { $row['mail']=$row['mail']; $row['icq']=$row['icq']; $row['wo']=$row['wo']; $row['txt']=$row['txt']; } else{ $row['icq']='locked'; $row['mail']='locked'; $row['wo']='locked'; $row['txt']='locked'; } $tpl->set_ar_out($row,0); #Charakter-Informer $abf2 = 'SELECT nchar1,cchar1,hchar1,gchar1,achar1,nchar2,cchar2,hchar2,gchar2,achar2,nchar3,cchar3,hchar3,gchar3,achar3,nchar4,cchar4,hchar4,gchar4,achar4,nchar5,cchar5,hchar5,gchar5,achar5 FROM `prefix_user` WHERE id = "'.$_SESSION['authid'].'"'; $erg2 = db_query($abf2); $row2 = db_fetch_assoc($erg2); $tpl->set_ar_out($row2,5); if ( $_SESSION['authright'] <= -2 ) { # get benoetige member $bm = substr($row['mod'],0,3); $needed = ''; for($i=0;$i<strlen($bm);$i++) { if ( is_numeric($bm{$i}) ) { $needed .= $bm{$i}; } } $uid = $_SESSION['authid']; if ($menu->get(3) == 'delete') { $uid = $menu->get(4); } $ck = db_count_query("SELECT COUNT(wid) FROM prefix_warmember WHERE wid = ".$_GET['mehr']." AND uid = ".$uid); # eine zu bzw. absage loeschen if ( $menu->get(3) == 'delete' AND ((has_right(array($row['tid'])) === true AND $uid == $_SESSION['authid']) OR is_siteadmin('wars')) AND $ck == 1) { db_query("DELETE FROM prefix_warmember WHERE wid = ".$_GET['mehr']." AND uid = ".$uid ); $ck = 0; } $available = db_count_query("SELECT COUNT(uid) FROM prefix_warmember WHERE wid = ".$_GET['mehr']." AND aktion = 1"); $aout1 = array ( 'needed' => $needed, 'available' => $available, 'id' => $_GET['mehr'] ); $tpl->set_ar_out($aout1,1); if ( $ck == 0 AND has_right(array($row['tid'])) === true) { if ( isset ($_POST['sub']) ) { $char = escape($_POST['char'],'string'); $aktion = ( $_POST['sub'] == 'zusagen' ? 1 : 0 ); $kom = escape($_POST['kom'],'string'); db_query("INSERT INTO prefix_warmember (uid,wid,char,aktion,kom) VALUES (".$_SESSION['authid'].",".$_GET['mehr'].",".$char.",".$aktion.",'".$kom."')"); } else { $tpl->out(2); } } $class = ''; $aktionar = array ('<font style="color:#FF0000; background:#666666; font-weight:bold;">abgesagt</font>','<font style="font-weight:bold; color:#00FF00; background:#666666;">zugesagt</font>'); $erg1 = db_query("SELECT b.id as uid, b.name, a.aktion, a.kom FROM prefix_warmember a left join prefix_user b ON b.id = a.uid WHERE a.wid = ".$_GET['mehr']); while ($row1 = db_fetch_assoc($erg1) ) { if ( $class == 'Cmite' ) { $class = 'Cnorm'; } else { $class = 'Cmite'; } $row1['class'] = $class; $row1['aktion'] = $aktionar[$row1['aktion']]; if ( $row1['uid'] == $_SESSION['authid'] OR is_siteadmin('wars')) { $row1['name'] = '<a href="index.php?wars-more-'.$_GET['mehr'].'-delete-'.$row1['uid'].'"><img src="include/images/icons/del.gif" border="0" title="löschen" /></a> '.$row1['name']; } $tpl->set_ar_out($row1,3); } } $tpl->out(4); } elseif ($row['status'] == 3) { # lastwars $row['memberliste'] = lastwars_get_memberlist($_GET['mehr']); $wlpar = array(1=>'gewonnen',2=>'verloren',3=>'unentschieden'); $row['erg'] = $row['owp'].' zu '.$row['opp']; $row['ergliste'] = get_erg_liste($_GET['mehr']); $row['wlp'] = $wlpar[$row['wlp']]; $title = $allgAr['title'].' :: Wars :: Lastwars'; $hmenu = '<a href="?wars" class="smalfont">Wars</a><b> » </b>Lastwars'; $design = new design ( $title , $hmenu ); $design->header(); $tpl = new tpl ('wars_last'); $row['tag'] = ( empty($row['tag']) ? $row['gegner'] : $row['tag'] ); $tpl->set_ar_out($row,0); # kommentare fuer lastwars if ($allgAr['wars_last_komms'] < 0 AND has_right ($allgAr['wars_last_komms'])) { # aktion if (isset ($_POST['kommentar_fuer_last_wars'])) { $name = $_SESSION['authname']; $text = escape($_POST['text'],'textarea'); db_query("INSERT INTO prefix_koms (name,cat,text,uid) VALUES ('".$name."','WARSLAST', '".$text."', ".$_GET['mehr']." )"); } if (isset ($_GET['kommentar_fuer_last_wars_loeschen']) AND is_siteadmin('wars')) { db_query("DELETE FROM prefix_koms WHERE cat = 'WARSLAST' AND uid = ".$_GET['mehr']." AND id = ".$_GET['kommentar_fuer_last_wars_loeschen']); } # anzeigen $tpl->out(1); $class = ''; $erg = db_query("SELECT name,text,id FROM prefix_koms WHERE cat = 'WARSLAST' AND uid = ".$_GET['mehr']." ORDER BY id DESC"); while($r = db_fetch_assoc($erg)) { $class = ( $class == 'Cmite' ? 'Cnorm' : 'Cmite' ); $r['text'] = bbcode($r['text']); if (is_siteadmin('wars')) { $r['text'] .= '<a href="index.php?wars-more-'.$_GET['mehr'].'=0&kommentar_fuer_last_wars_loeschen='.$r['id'].'"><img src="include/images/icons/del.gif" title="löschen" alt="löschen" border="0"></a>'; } $r['class'] = $class; $tpl->set_ar_out($r,2); } $tpl->out(3); } } $design->footer(); } ?>
Und die wars_next.htm
<table width="100%" border="0" cellpadding="5" cellspacing="1" class="border"> <tr class="Chead"> <td colspan="2"><b>Raid-Termin: {tag} | <strong>{datum} {_lang_at} {zeit} {_lang_oclock}</strong></b></td> </tr><tr> <td class="Cdark" colspan="2" align="left"><b>Basis Informationen</b></td> </tr><tr> <td width="15%" class="Cmite">Raid Typ:</td> <td width="85%" class="Cnorm">{gegner}</td> </tr><tr> <td class="Cmite">Raid Leiter:</td> <td class="Cnorm">{game}</td> </tr><tr> <td class="Cmite">ICQ:</td> <td class="Cnorm">{icq}</td> </tr><tr> <td class="Cdark" colspan="2" align="left"><b> {_lang_match} {_lang_info}</b></td> </tr><tr> <td class="Cmite">{_lang_date}</td> <td class="Cnorm"><strong>{_lang_On} {datum} {_lang_at} {zeit} {_lang_oclock}</strong></td> </tr><tr> <td class="Cmite">{_lang_meetingplace}</td> <td class="Cnorm">{wo}</td> </tr><tr> <td class="Cmite">{_lang_squad}</td> <td class="Cnorm"><u><i><b>{team}</b></i></u></td> </tr><tr> <td class="Cmite">{_lang_xonx}</td> <td class="Cnorm">{mod}</td> </tr><tr> <td class="Cmite">{_lang_remark}:</td> <td class="Cnorm">{txt}</td> </tr> </table> <br/> <table width="100%" border="0" cellspacing="1" cellpadding="5" class="border"> {EXPLODE} <tr class="Cdark"> <td>{_lang_present} / {_lang_away} - ( {_lang_promise}: {available} {_lang_from} {_lang_needed}: {needed} ) </td> </tr> {EXPLODE} <tr class="Cnorm"> <td> <form action="index.php?wars-more-{id}" method="POST"><table><tr><td colspan="3"><input name="kom" size="65" /><select name="char"> <option value="1">{nchar1} - {cchar1}</option> <option value="2">{nchar2} - {cchar2}</option> <option value="3">{nchar3} - {cchar3}</option> <option value="4">{nchar4} - {cchar4}</option> <option value="2">{nchar5} - {cchar5}</option> </select></td></tr> <tr><td><input type="radio" id="zusage" value="zusagen" name="sub" checked /><label for="zusage" style="cursor: pointer;"> {_lang_promise}</label></td> <td><input type="radio" id="absage" value="absagen" name="sub" /><label for="absage" style="cursor: pointer;"> {_lang_cancellation}</label></td> <td align="right"><input type="submit" value="{_lang_formsub}" /></td></tr></table> <br /> Debug Mode: <br /> <br /> </form> </td> </tr> {EXPLODE} <tr class="{class}"> <td><b>{name}</b> {_lang_had} {aktion} <u>{_lang_comment}:</u> {kom}</td> </tr> {EXPLODE} </table>
betroffene Homepage: externer Link