Jump to content

Help


GhostDZ9

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.