GhostDZ9 Posted August 7, 2010 Share Posted August 7, 2010 I don't know why I'm getting these errors located on the link below can you please advise me how to fix it, also i want to add a redirect to that file so that after it executes the php file i redirects to another page regards Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 I don't know why I'm getting these errors located on the link below can you please advise me how to fix it, also i want to add a redirect to that file so that after it executes the php file i redirects to another page regards Errors? Code? Quote Link to comment Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 Warning: fopen(course1results.xml) [function.fopen]: failed to open stream: Permission denied in /home/mccrankr/public_html/majorassignment/course1info.php on line 22 Warning: fwrite(): supplied argument is not a valid stream resource in /home/mccrankr/public_html/majorassignment/course1info.php on line 35 Warning: fclose(): supplied argument is not a valid stream resource in /home/mccrankr/public_html/majorassignment/course1info.php on line 36 those are the errors and this is the code <html> <body> <?php $dbName = "mccrankr"; $host = "localhost"; $user = "mccrankr"; $pass = "991138310"; $course1Table = 'mccrankr.Course1'; $studentcourse = 'Course1.studentid'; $studentid = $_POST['studentid']; $connection = mysql_connect($host, $user, $pass) or die("Could not connect."); if ($studentid != $studentcourse){ $query = 'SELECT * FROM ' . $course1Table . ' WHERE ' . $studentcourse . ' = ' . '\'' . $studentid .'\''; } else { $wrong = "<meta http-equiv=\"REFRESH\" content=\"2;url=http://mobile.sheridanc.on.ca/~mccrankr/majorassignment/test.php\"><br>" . "<p>Page will redirect in 2 seconds </p><a href=\"http://mobile.sheridanc.on.ca/~mccrankr/majorassignment/test.html\">Click Here</a>"; echo $wrong; } $resultSet = mysql_query($query, $connection) or die("Data not found."); $file= fopen("course1results.xml", "w"); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<course>\n"; for($x = 0 ; $x < mysql_num_rows($resultSet) ; $x++){ $row = mysql_fetch_assoc($resultSet); $xml_output .= "\t<courses>\n"; $xml_output .= "\t\t<course1>" . $row['course'] . "</course1>\n"; $xml_output .= "\t\t<studentid>" . $row['studentid'] . "</studentid>\n"; $xml_output .= "\t\t<name>" . $row['name'] . "</name>\n"; $xml_output .= "\t\t<grade>" . $row['grade'] . "</grade>\n"; $xml_output .= "\t</courses>\n"; } $xml_output .= "</course>"; fwrite($file, $xml_output); fclose($file); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 What file permissions have you applied to course1results.xml? PHP cannot open/write to the file due to the file permissions. If you are creating the file you'll also need to apply the necessary write permissions to the parent directory too Also when you post code could you wrap it within code tags ( or ). Quote Link to comment Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 i changed the permissions on the xml file Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 i changed the permissions on the xml file To what? Quote Link to comment Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 777 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 And you're still getting the error? What permission is the parent directory (majorassignment) set to? Quote Link to comment Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 yup Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 What permission is the parent directory (majorassignment) set to? Quote Link to comment Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 777 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 7, 2010 Share Posted August 7, 2010 Then it should be able to write the xml file then. Quote Link to comment Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 ok now how do i do the redirect? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.