0

i ve tried all possible solutions for solving this error , but couldnt fix it.please fix it

<?php
 session_start();
include('databaseconnect.php');
$qno='';
$todisplay='';
$uploadedfile='';
$filename='';
$answer='';
$toolspec='';
//$uploadvar='';
$qno=isset($_REQUEST['qno'])?$_REQUEST['qno']:"";
if(isset($_SESSION['username'])&&(isset($_SESSION['id'])))
{

$username=$_SESSION['username'];
$idno=$_SESSION['id'];
$mquery2=mysql_query("SELECT * FROM student WHERE id ='$idno'");
$row2=mysql_fetch_array($mquery2);
$year=$row2['year'];
$mquery=mysql_query("SELECT * FROM questiontable WHERE qno='$qno'");
$numrows=mysql_num_rows($mquery);
if($numrows==0)
{
exit();
}
else
{
$row=mysql_fetch_array($mquery);
$qno=$row['qno'];
$question=$row['question'];
$startdate=$row['startdate'];
$enddate=$row['enddate'];
$comment=$row['comment'];
if(strlen($comment)==0)
$comment="<i>No comment's Provided</i>";
$submittedby=$row['submittedby'];
$image=$row['image'];
$title=$row['title'];
$tool=$row['tool'];
if($tool!=0)
$toolspec='<a href=http://www.diagram.ly target="_new">Click here for DrawTool</a>';
$todisplay.='
<tr >
<td>
'.$question.'</p><b>Posted by:'.$submittedby.'</b>     |  StartDate:'.$startdate .'
      |      endsby:'.$enddate.'&nbsp;&nbsp;&nbsp;
|  Comments:'.$comment.'&nbsp;&nbsp;&nbsp;</br>

</td>
';
if(strcmp($image,"questionimages/default.jpg")!=0)
{
$todisplay.='<td width="33%"><a href="'.$image.'"  id="questions"><img src="'.$image.'" height="200" width="200" align="left"></a></td>
';
}
$todisplay.='</tr>';

}
/*********************ANSWER AND FILE INSERTION***************************/
if(isset($_POST['answer']))
{
$answer=$_POST['answer'];

$filename=$_FILES['answerfile']['name'];
$filesize=$_FILES['answerfile']['size'];
$file=$_FILES['answerfile']['name'];
$filetype=substr(strchr($file,'.'),1);
if(!(empty($filename)))
{
if(($filetype=='doc')||($filetype=='pdf'||$filetype=='txt' ||$filetype=='jpg')&& ($filesize< 20000000000))
{
if($_FILES['answerfile']['error'] > 0)
{
$msgtouser=$_FILES['answerfile']['error'];

include('msgtouser.php');
exit();
}
else
{
$_FILES['answerfile']['tmp_name']=str_replace(' ','' ,$_FILES['answerfile']['tmp_name']);

move_uploaded_file($_FILES['answerfile']["tmp_name"],"questionimages/" .$qno);

/* if(!move_uploaded_file($_FILES['answerfile']["tmp_name"] , "questionimages/" .$qno ))
{
$msgtouser='not uploaded';
include('msgtouser.php');
exit();
} */

$uploadedfile="answers/".$qno.'-'.$idno.'-'.$username.'-'.$_FILES['answerfile']['name'];
$uploadedfile=str_replace(' ','' ,$uploadedfile);
}
}

elseif(($_FILES['answerfile']['size']> 20000000000))
{
unlink($_FILES['answerfile']['tmp_name']);
$msgtouser="The File Size Too Big to Upload";
include('msgtouser.php');
exit();
}
else
{
unlink($_FILES['answerfile']['tmp_name']);
$msgtouser='File Format    '. $_FILES['answerfile']['type'].'   Not Supported';
$msgtouser .='&nbsp &nbsp <a href="toanswer.php?qno='.$qno.'">Go back</a>';
include('msgtouser.php');
exit();
}

}
if((empty($answer))&&(empty($filename)))
{
$msgtouser='Answer fields left Empty ! </br><a href="toanswer.php?qno='.$qno. '">Go Back</a>';
include('msgtouser.php');
exit();
}
else
{
$answer=$_POST['answer'];
$mquery=mysql_query("INSERT INTO answers (answer, studentname, idno, qno, year, rating,uploadedfile,date,title) VALUES ('$answer', '$username', '$idno', '$qno', '$year',' ','$uploadedfile',now(),'$title')");
if($mquery)
{

$msgtouser='Answer Successfully uploaded</br>
</br>
<a href="#"  onclick="parent.$.fancybox.close();" class="button-2">Close</a>
';
include('msgtouser.php');
exit();



}
else
	echo"Failed to insert";

}
}
/*********************ANSWER INSERTION***************************/
}
else
{
$continue=$_SERVER['PHP_SELF'].'?qno='.$qno;
$msgtouser='Login To Enter Your Answer</br>
</br>
<a href="login.php?continue='.$continue.'">Login</a>';
include('msgtouser.php');
exit();
}
unset($answer,$_FILES['answerfile']['tmp_name'],$uploadedfile);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Question :<?php echo $question?></title>
<?php include('includefancybox.php'); ?>
<link href="styles/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
 <div class="clr"></div>
  <div class="content">
    <div class="content_resize">
      <div class="mainbar">
        <div class="article">
&nbsp;&nbsp;&nbsp;&nbsp;<h2 class="star"><?php echo"$title";?></h2>







<?php
echo '<form action="toanswer.php?qno='.$qno.' " method="post" enctype="multipart/form-data">';
 ?>

<table  border="0">
  <tr>
    <td><?php //echo $todisplay; ?></td>
  </tr>
</table>

<table border="0">
<tr></tr>
<tr>
  <td><h2><font color="#0099CC">Answer:</font></h2>
    <textarea name="answer" cols="50" rows="5"></textarea>
<p>((Or))You can  Upload a file of PDF(Recommended) or docx Format</br>
<input type="file" name="answerfile" class="button-2"/>
  <input type="hidden" name="hiddenvar" /></p></td>
 </tr>
 <tr>
 <td><?php echo"$toolspec";?></td>
 </tr>
 <tr> <td>
  
</td>
</tr>
</table>
<p>
 <input type="submit" class="button-2" value="Upload my answer"/>
</p>
 </form>
</div>       
      </div>  
      <div class="clr"></div>
    </div>
  </div>

</body>
</html>
2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by diafol
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.