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 Link to comment https://forums.phpfreaks.com/topic/210077-help/ 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? Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096373 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> Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096374 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 ). Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096375 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 Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096376 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? Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096379 Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 777 Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096380 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? Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096383 Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 yup Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096384 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? Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096385 Share on other sites More sharing options...
GhostDZ9 Posted August 7, 2010 Author Share Posted August 7, 2010 777 Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096388 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. Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096390 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? Link to comment https://forums.phpfreaks.com/topic/210077-help/#findComment-1096391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.