Jump to content

Internet Explorer goes into hyper refresh when this script is ran....


Recommended Posts

This is always an ordeal with me.  I use firefox and get something working and ie comes along and ends my fun.  If anyone knows a problem in the script that could cause this please tell me.

 

When the following script is ran on Internet Explorer 8 its works but keeps refreshing continuously.

 

<?$con = mysql_connect("localhost","bmvybfbk_master","74SAc194G");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("bmvybfbk_website", $con);

$result = mysql_query("SELECT * FROM comments WHERE flagged = '1'");

while($row = mysql_fetch_array($result))

  {$cnumber = $row['id'];
  echo $row['writer'] . " wrote:<br>" . $row['comment'];
  echo "<br><a href='mod2.php?action=ignore&cnumber=$cnumber'>[ignore]</a>";
  echo " <a href='mod2.php?action=delcomment&cnumber=$cnumber'>[Delete]</a>";
  echo "<br>----------------------------------------------------------------------------------------------------<br>";}

  if ($action == ignore) {
mysql_query("UPDATE comments SET flagged = '0' WHERE id = '$cnumber' LIMIT 1");?>
<meta http-equiv="refresh" content="0;mod2.php"><?}

if ($action == delcomment) {mysql_query("DELETE FROM comments WHERE id='$cnumber' LIMIT1");?>
<meta http-equiv="refresh" content="0;url=mod2.php"><?}

else {echo " ";}
  
}else{ echo "*You Don't Have any rights to View this page*'";}?>

 

Sorry, codes a bit messy but functions perfect in firefox.....

unless you have globals set to on, there's no such thing as $action.  You should be using $_GET['action'] And you don't have quotes around the stuff it is supposed to be compared against (ignore, delcomment).  I'm assuming you also have error reporting turned off, otherwise you would have gotten a warning about both of those things.  Anyhow, seeing as how false == false, your conditions that are outputting the meta tags set to refresh over and over, are being output.  Since you say it is being refreshed over and over, either mod2.php is the name of this script, or else mod2.php is redirecting to this script.  The reason why it works "perfectly" in FF is probably because it's detecting something is amiss and preventing it from doing it, as opposed to IE happily doing it for you.

when you compare a variable to a string, you SHOULD surround the string with quotes. IE instead of

if ($action == ignore) {

 

it should be

if ($action == 'ignore') {

 

when you have a string without quotes, PHP thinks you are using a global variable. IE

define("globalVar", "value");
//now I can just use globalVar like so
echo globalVar;

 

However, PHP is smart enough to realize when you messed up, and meant a string (as PHP will assume you meant a string, when no global variable of that name is found)

 

As CV said, you should turn error reporting on, so PHP can give you some feedback to why your script isn't working.

error_reporting(E_ALL);
ini_set("display_errors", 1);

 

you say action is defined above? echo $action and post what its value is. Or better yet, post the code where $action is defined

I believe I forgot to mention the address is initially http://gamepage101.com/mod2.php but when buttons are clicked more is added to the address.  I get action with this: $action = ($_GET['action']);  Which is apparently working.  I made any changes above but still does same thing...

ok, when you echo action, what value does it have? It would seem that you keep passing the same value for that $_GET variable every time you refresh the page, and gets locked into an infinite refresh loop

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.