PHP/mysql problem
<?php include 'sitetop.inc'; ?>
<div id="content">
<?php include 'menu.inc'; ?>
<div id="rightColumn">
<?php
if(!$logged_in){
echo "<h3>ERROR</h3>";
echo "<p>Please log in to use the editor.</p>";
} else {
include 'treemenu.inc';
$allowedTags='<p><strong><em><u><h1><h2><h3><h4><h5><h6><img>';
$allowedTags.='<li><ol><ul><span><div><br><ins><del>';
if($_POST['elm1'] != '') {
$sContent = strip_tags($_POST['elm1'],$allowedTags);
} else {
$username = $_SESSION[username];
mysql_real_escape_string($username);
$doc_id = $_GET['id'];
mysql_real_escape_string($doc_id);
$query = "SELECT * FROM docs WHERE id='$doc_id' LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$sContent = $row['content'];
$proj_id = $row['project_id'];
$title = $row['title'];
$length = strlen($sContent);
$index = 1; //temp
}
echo "<h3>Editing: ".$title."</h3>";
?>
<form method="post" action="editor.php">
<textarea id="elm1" name="elm1" rows="15" cols="80">
<?php
echo $sContent;
if($_POST['elm1'] != '') {
$q = "INSERT INTO docs VALUES ('', '$username', '$proj_id', '$title', '$sContent', '$index', 'NOW()', '$length')";
$result = mysql_query($q);
}
?>
</textarea>
<br />
<input type="submit" name="save" value="Save" />
</form>
<?php } ?>
</div>
<div id="clear"></div>
</div>
<?php include 'sitebottom.inc'; ?>
Problemet jag har är att INSERT inte sätter in rätt värden, tex så är project_id fel, NOW() ger bara nollor, etc. Kan inte hitta felet och det är väl antingen för jag är trött eller för nybörjare.
EDIT: ser felet lol! Ska ändra lite och återkomma.
EDIT2: eller det var inte felet. Hmm.