Jump to content

[SOLVED] why wont this work?


Sesquipedalian

Recommended Posts

Why won't this display anything? There is a POST, but it doesn't work?

 

class.php:

function delete_game($type) {
 if ($type == 'do_action') {
	$filename = '../games/games/'.$_GET['game'].'.php';
	if (file_exists($filename)) {
		unlink($filename) or die ('COULD NOT DELETE FILE!');
		$_SESSION['view'] == 'echo_off';
		$linksfilename = '../games/links.php';
		include($linksfilename);
		$newcontent = str_replace(' | <a href="?act=games/'.$_GET['game'].'">'.strtoupper($_GET['game']).'</a>', '', $content);
		if ($handle = fopen('linksfilename', 'w')) {
			if (fwrite($handle, $newcontent)) {
				echo '<h1>Game Deleted</h1><center>Success, <b>'.$_GET['game'].'</b> has been deleted.</center>';
				include('links.php');
			} else {
				echo '<h1>Error</h1><Center>Could not write to links.php</center>';
				include('links.php');
			}
		} else {
			echo '<h1>Error</h1><center>Could not open links.php</center>';
			include('links.php');
		}
	} else {
		echo '<h1>Error</h1><Center>File does not exist.</center>';
	}
}	
}

 

 

and in homepage.php:

if ($_POST) {
$login->delete_game('do_action');
}

Link to comment
Share on other sites

you are using variables in your function that

are not defined in the function, try making

them globals, example:

 

<?php
$variable = 'test';

function willWork(){
global $variable;

echo $variable;
}

function wontWork(){

echo $variable;
}

willWork();
echo '<br><br><br>';
wontWork();

// See the difference?
?>

Link to comment
Share on other sites

what variables aren't being defined?

 

I realized i accidentally did $_SESSION['view'] == 'echo_off' instead of $_SESSION['view'] = 'echo_off'...

 

also, $content is located inside of the file.

 

the thing is, if i put an echo 'this'; in the function, it doesn't even echo it... so i think it has something to do with the part in homepage.php.. but it doesn't make sense.

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.