PHP script voor quiz

  • Onderwerp starter Onderwerp starter Erat
  • Startdatum Startdatum
Status
Niet open voor verdere reacties.

Erat

Gebruiker
Lid geworden
12 jan 2010
Berichten
45
Hai,

Ik wil een quiz op m'n site hebben en ik heb de Easy Personality Quiz Maker 1.0.
Ik heb alles geinstalleerd maar als ik de test wil opslaan, krijg ik deze melding:

Warning: fopen("1265812877.qz", "w") - Permission denied in /home/httpd/vhosts/mywebsite.nl/httpdocs/quiz/quizmakewrite.php on line 42
unable to open file

dat gaat dus om deze regel:

$fp = fopen("$name.qz", 'w') or die("unable to open file");

en dit is de file:
PHP:
<?
// This script writes the quiz to a file

include('config.php');

// Retrieve the user entered data
$name = $_POST['name'];
$title = $_POST['title'];
$types = $_POST['types'];
$questions = $_POST['questions'];
$formpass = $_POST['formpass'];

if($formpass != $password)
{
	echo "<BR><font color=FF0000>ERROR: Incorrect Password</font><BR><BR>";
	die();
}

$name = stripslashes($name);
$title = stripslashes($title);
settype($types, 'integer');
settype($questions, 'integer');

// Retrieve the numbered variables
for($i=0; $i<$types; $i++)
{
	$type[$i] = $_POST["type$i"];
	$type[$i] = stripslashes($type[$i]);
}
for($i=0; $i<$questions; $i++)
{
	$question[$i] = $_POST["question$i"];
	$question[$i] = stripslashes($question[$i]);
	for($j=0; $j<$types; $j++)
	{
		$answer[$i][$j] = $_POST["$i-$j"];
		$answer[$i][$j] = stripslashes($answer[$i][$j]);
	}
}

// Open the file for writing
$fp = fopen("$name.qz", 'w') or die("unable to open file");

// Write the data to the file
fwrite($fp, "<?\n\$title=\"$title\";\n\n\$types=\"$types\";\n\$questions=\"$questions\";\n\n");
for ($i=0; $i<$types; $i++)
{
	fwrite($fp, "\$type[$i] = \"".$type[$i]."\";\n");
}
for($i=0; $i<$questions; $i++)
{
	fwrite($fp, "\n\$question[$i] = \"".$question[$i]."\";\n");
	for($j=0; $j<$types; $j++)
	{
		fwrite($fp, "\$answer[$i][$j] = \"".$answer[$i][$j]."\";\n");
	}
}
fwrite($fp, "?>");
fclose($fp);

// Inform the user
echo "Your quiz has been saved.  You may access it through: http://www.yoururl.com/yourpath/quiz.php?quiz=$name<BR><BR>(replace yoururl and yourpath with the URL and path of the quiz script on your server)"
?>
Iemand enig idee waar de fout zit? De properties staan op 755, dus hij moet hem gewoon kunnen overschrijven.
 
Laatst bewerkt door een moderator:
Dank je wel voor je snelle antwoord! :D

Hij doet het echter nog steeds niet. Ik krijg dezelfde melding.
 
Bij 777 doet hij het wel. :)

Maar direct weer een probleem, want nu krijg ik deze melding:

Warning: open_basedir restriction in effect. File is in wrong directory in /home/httpd/vhosts/mijnwebsite/httpdocs/quiz/quiz.php on line 5

Ik begrijp dat de quiz.php dus geen toegang krijgt maar hoe zorg ik ervoor dat hij dat wel krijgt?

Edit: Ik kreeg het weg door de header en footer te uploaden. Werkt nu prima!
 
Laatst bewerkt:
Haha sorry ik bedoelde ook 777:o
Maar mooi dat ie het doet:thumb:
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan