Kein Eintrag in der DB

  • Themenstarter Themenstarter BlackLove2005
  • Beginndatum Beginndatum
B

BlackLove2005

Hallo und guten Abend,

so hab nun mein Forum fast fertig geschreiben nur es hat sich wo der Teufel eingeschlichen und ich weiß nicht wo :suspekt: :suspekt:

Alos das hier ist mein Code:

PHP:
<?PHP
$f = trim(stripslashes($_POST['f']));
$t = trim(stripslashes($_POST['t']));

$variablen = array('name','topic','subtopic','icq','email','website','icon','content');

foreach($variablen as $var)
  $$var = str_replace( array('&','\''), array('&','\\''), htmlentities(trim(stripslashes($_POST[$var]))));



if($icon < 0 || $icon > 35) $icon = 0;
if($website != '' && substr($website, 0, 7) != 'http://') $website = 'http://'.$website;

$error = array();

if($name == '') $error[] = 'Kein Name angegeben';
if($topic == '') $error[] = 'Kein Thema angegeben';
if($content == '') $error[] = 'Keine Nachricht angegeben';

include_once('inc/db.con.inc.php');
if(isset($_COOKIE['uniq_id']) && !empty($_COOKIE['uniq_id']))
  include 'inc/auth.inc.php';

if(array_shift($db->fetch_row($db->query('select count(id) from 006_user where name = "'.$name.'"'))) > 0 && !(AUTH == OK) && $user_name != $name)
  $error[] = 'Dieser Name ist registriert';

if(count($error) > 0) {
  include 'forumn.php';
  exit;
}

if(!isset($t) || empty($t)) {
  list($t) = $db->fetch_row($db->query('select max(tid) + 1 as t from 006_data where fid = "'.$f.'"'));
  if(empty($t)) $t = 1;
}
//echo "Test";
//if(defined('AUTH')) echo "ok"; else echo "no";
//ob_start();
include_once 'inc/header.inc.php';
ob_end_clean();
if(defined('AUTH'))
  $query = 'insert into 006_data(tid, fid, uid, topic, subtopic, icon, date, content, ip) values ("'.$t.'", "'.$f.'", "'.$user_id.'", "'.$topic.'", "'.$subtopic.'", "'.$icon.'", unix_timestamp(now()), "'.$content.'", "'.getenv('REMOTE_ADDR').'")';
else
  $query = 'insert into 006_data (tid, fid, topic, subtopic, icon, name, email, icq, website, date, content, ip) values ("'.$t.'", "'.$f.'", "'.$topic.'", "'.$subtopic.'", "'.$icon.'", "'.$name.'", "'.$email.'", "'.$icq.'", "'.$website.'", unix_timestamp(now()), "'.$content.'", "'.getenv('REMOTE_ADDR').'")';
echo $query;
if($db->query($query)) {
  ob_end_clean();

  $id = $db->insert_id();

  header('location: forum.php?f='.$f.'&t='.$t.'&i='.$id.'#i'.$id);
  exit;

} else {
  ob_end_flush();

  $pid = $f;

  $feld = array();
  echo '<a href="./">'.$title.'</a> » <a href="forum.php">Foren</a>';
  do {
    list($id, $pid, $forum, $is_forum) = $db->fetch_row($db->query('select id, pid, name, is_forum from 006_foren where id = "'.$pid.'"'));
    if($id == $f) $forum_name = $forum;
    $feld[] = ' » '.($is_forum ? '<a href="forum.php?f='.$id.'">'.$forum.'</a>' : $forum);
  } while($pid != 0);

  echo implode('', array_reverse($feld));

  $rechts2 = new nav;
  $rechts2->item('Übersicht','./forum.php');
  $rechts2->item('Forum','./forum.php?f='.$f);

  echo '<div class="rechts" style="float:right"><img alt="" src="./img/rechts_top.gif">'.$rechts2->nav.'<img alt="" src="./img/rechts_bot.gif"></div>';

  headline($_POST['t'] ? 'Antworten' : 'Neues Thema');

  echo '<div style="height:200px;padding:40px"><img src="./img/smiley/4.gif" style="vertical-align:middle"> <b>Fehler beim Einfügen des Beitrags!</b><br><a href="javascript:history.back(1)">Zurück</a></div>';

// foot();

}
?>

Aber komisch er trägt nichts in die DB ein. Könnt Ihr mal schauen?

Gruß BlackLove2005
 
Ich sehe die berühmte [phpf]mysql_error[/phpf]-Ausgabe nicht.
Es könnte ja durchaus ein Fehler im Query sein.

Gruß hpvw
 
omg...was denn das fürn Code. Der steckt ja nahezu voll mit Fehlern. Mom ich arbeite mich da mal eben durch :-)

Also irgendwie versteh ich nicht, was du da angestellt hast.

z.B. das

PHP:
if($icon < 0 || $icon > 35) $icon = 0; 
if($website != '' && substr($website, 0, 7) != 'http://') $website = 'http://'.$website;

kann doch rein vom Syntax her nicht stimmen, ebenso wenig wie das:

PHP:
foreach($variablen as $var) 
  $$var = str_replace( array('&','\''), array('&','\\''), htmlentities(trim(stripslashes($_POST[$var]))));
 
Zuletzt bearbeitet von einem Moderator:
Hallo,

der Code ging bei mir Lokal ohne wenn und aber also komm du mir nicht so dass das nicht stimmt usw.

das mit mysql_error() habe ich gemacht da kommt aber keine Fehlermeldung

Gruß BlackLove2005
 
Das scheint mir noch etwas merkwürdig:
PHP:
&& !(AUTH == OK) &&
Vergleichst Du da wirklich 2 Konstanten?

Und
PHP:
'\\''
könnte durchaus Probleme verursachen.

Ansonsten hilft nur, an verschiedensten Stellen des Skripts per Ausgabe jede einzelne Variable zu prüfen, ob denn das enthalten ist, was Du erwartest.

Gruß hpvw
 
Guten Morgen,

so hab nun die ganze Nacht fast dran gesessen und versucht das zum laufen zu bringen aber leider OHNE erfolg. Na ja wenn euch noch was einfällt dann sagt es bitte!

Gruß BlackLove2005
 
Zurück