I hate to bother you guys but I have a problem that has me stumped. When I test it on my local server it works fine, but then I uploaded the files to the web server and it doesn't work and I get the following errors:
Warning: fwrite(): supplied argument is not a valid stream resource in /DISK3/WWW/conway.cz/www/quizzes/XML/XML_doc_processing.php on line 69
Warning: fclose(): supplied argument is not a valid stream resource in /DISK3/WWW/conway.cz/www/quizzes/XML/XML_doc_processing.php on line 70
The web hosting guy tells me there's a problem with my code because I shouldn't have any problem creating an XML file in my directory, but it's just not working. Please take a look at my code and tell me if you can find a mistake that would cause such an error:
$page_sel = mysql_prep($_GET['page_sel']);
$quiz_id = mysql_prep($_GET['quiz_id']);
$quiz_id = mysql_real_escape_string($quiz_id);
$quiz_title = mysql_prep($_GET['quiz_title']);
$quiz_title = mysql_real_escape_string($quiz_title);
$dir = 'http://www.conway.cz/quizzes/XML';
$quiz_file = getNextFilename_file($dir, 'quiz', 'xml');
echo $quiz_file;
$link = "http://www.conway.cz/quizzes/quiz1.php";
$sql_quiz_id = "INSERT INTO quizzes (id, quiz_id, quiz_file, title, link) VALUES (NULL, '$quiz_id', '$quiz_file', '$quiz_title', '$link')";
$result2 = mysql_query($sql_quiz_id, $connection);
if(!is_empty_dir($dir)){
$file = getNextFilename($dir, 'quiz', 'xml');
} else {
$file = "http://www.conway.cz/quizzes/XML/quiz001.xml";
}
$query = "SELECT * FROM xml_docs WHERE quiz_id=\"$quiz_id\"";
$result = mysql_query($query, $connection);
if($result) {
$file_handle = fopen($file,'x');
$xmlPacket = "<?xml version='1.0'?>\n";
//----
$xmlPacket .="<StevesQuiz>\n";
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
$xmlPacket .= "\n<problem type=\"";
$xmlPacket .= $row['type_of_question']."\" questionText=\"".$row['question']."\" correctAnswers=\"";
$xmlPacket .= $row['correct_answers']."\" quizTitle=\"".$row['quiz_title']."\" quizID=\"".$row['quiz_id']."\" quizIDTaken=\"".$row['quiz_id_taken']."\">
<possible label=\"".$row['possible1']."\" />
<possible label=\"".$row['possible2']."\" />
<possible label=\"".$row['possible3']."\" />
<possible label=\"".$row['possible4']."\" />
</problem>\n";
}
$xmlPacket .= "\n</StevesQuiz>";
}
else{
$xmlPacket = "<?xml version='1.0'?><StevesQuiz></StevesQuiz>";
}
//here are the two lines that are returning errors
fwrite($file_handle,$xmlPacket);
fclose($file_handle);
die(redirect_to('../../content_management.php?page_sel=content_management'));
Thanks for the help! It's so frustrating.
Dan