Jump to content


Photo

Question: How to continue the script to run?


  • Please log in to reply
2 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 13 August 2006 - 02:58 PM

hi guys, I've got a problem:
I want to check if the user is banned or not (ip addresses are stored in db). here is the script, but I want the script to continue if the banned ip and user ip do not match, but in my case the scripts stops... hope someone can help, thanks in advance.


<?php

$conban = mysql_connect("localhost","3d","pass"); // check for bannedip
if (!$conban)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("3d", $conban);

$resultban = mysql_query("SELECT * FROM ip");

while($rowban = mysql_fetch_array($resultban))
  {
  $rowban['bannedip'];
  }
mysql_close($conban);



$con = mysql_connect("localhost","3d","pass"); // check for userip
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("3d", $con);

$result = mysql_query("SELECT * FROM ip");

while($row = mysql_fetch_array($result))
  {
  $row['userip'];
  }
mysql_close($con);



//Set banned IP
$banned  = $rowban;

//Set user IP address
$userip = $row;

//check
if($userip == $banned){ 
    echo "<BR>This IP address has been banned";
}
else{
  continue;
  }
exit();
?>

I don't need your script, I'll try to write it myself

#2 whare

whare
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 13 August 2006 - 03:04 PM

maybe try changing the code around abit like

//check
if($userip != $banned){ 
        [Your other code here so that the "echo "<BR>This IP address has been banned";" goes to the end of the file]
}
else{
       echo "<BR>This IP address has been banned";
   }
exit();
?>

some times if the change code around like that it seems to work give it a try at least you never no :)

sorry I carnt give you any more

#3 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 13 August 2006 - 03:15 PM

Ummm.....what are these statements supposed to do?
$rowban['bannedip'];

and

$row['userip'];

and why do you close the connection to the database and immediately re-open it?
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users