samoi Posted September 25, 2009 Share Posted September 25, 2009 Hello guys, I have bought a clone of a game and it wasn't completed! the develop broke the contract as I discovered many bugs and I usually send 2 email a day for reporting bugs. then he couldn't handle all that amount of bugs so he broke the contract and left somewhere where I cannot find him. so I wanted to develop it myself. in the login.php an HTML code to get the values and transfer it over to the town1.php for verification and handling. So login.php is not important! but here is the "Freaking" query for the login in the town1.php if($_POST['login']){ session_destroy(); session_start(); $errorp="(Incorrect account information)"; $name=cleand($_POST['nick']); $pass=MD5($_POST['pass']); //[1] Query checks if the user is activated from users table! //[2] Query gets coords of the village x and y from village table $SQL="SELECT u.regcode as regcode, v.x as x, v.y as y, v.owner, v.valleytype as valley, v.building1 as building1, v.building2 as building2, v.building3 as building3, v.demolish, v.downgrade, u.uid as id, u.pw as pass, u.name as user, u.email as mail, v.tribe as species, u.notes as note, u.reg as regd, u.alliance as allies, u.newmail as numail, u.deletedon as del, UNIX_TIMESTAMP(u.plusuntil)-UNIX_TIMESTAMP(NOW()) as plus, UNIX_TIMESTAMP(u.luminc)-UNIX_TIMESTAMP(NOW()) as lum, UNIX_TIMESTAMP(u.clainc)-UNIX_TIMESTAMP(NOW()) as cla, UNIX_TIMESTAMP(u.iroinc)-UNIX_TIMESTAMP(NOW()) as iro, UNIX_TIMESTAMP(u.croinc)-UNIX_TIMESTAMP(NOW()) as cro, UNIX_TIMESTAMP(u.attinc)-UNIX_TIMESTAMP(NOW()) as att, UNIX_TIMESTAMP(u.definc)-UNIX_TIMESTAMP(NOW()) as def, (UNIX_TIMESTAMP(u.deletedon)-UNIX_TIMESTAMP(NOW()) + ".PROFILE_DELETE.") as del, v.vid FROM users u, villages v WHERE (v.owner=u.uid) AND (u.deletedon is null OR TIMEDIFF(u.latest, NOW() + INTERVAL 3 DAY)<0) AND UCASE(u.name) = UCASE(".$name.") AND (u.pw = '".$pass."') AND v.capital=1"; $result=mysql_query($SQL) or die("li: ".mysql_error()."<br>Q: ".$SQL); while($row=mysql_fetch_array($result)){ //A match has been found for this password $errorp=""; $errorn=""; //Therefore, no error here... if($pass != $row['pass']) $_SESSION['sitter']=1; $_SESSION['uid']=$row['id']; $_SESSION['name']=$row['user']; $_SESSION['email']=$row['mail']; $_SESSION['tribe']=$row['species']; $_SESSION['notes']=$row['note']; $_SESSION['reg']=$row['regd']; $_SESSION['alliance']=$row['allies']; $_SESSION['newmail']=$row['numail']; $_SESSION['x']=$row['x']; $_SESSION['y']=$row['y']; $_SESSION['valley']=$row['valley']; $_SESSION['building1']=0+$row['building1']; $_SESSION['building2']=0+$row['building2']; $_SESSION['building3']=0+$row['building3']; $_SESSION['owner']=$row['owner']; $_SESSION['del']=$row['del']; $_SESSION['plus']=0+$row['plus']; //Seconds of plus left... $_SESSION['resbonus1']=0+$row['lum']; $_SESSION['resbonus2']=0+$row['cla']; $_SESSION['resbonus3']=0+$row['iro']; $_SESSION['resbonus4']=0+$row['cro']; $_SESSION['attbonus']=0+$row['att']; $_SESSION['defbonus']=0+$row['def']; for($r=2;$r<10;$r++){ $_SESSION['researched'.$r]=0+$row['research'.$r]; $_SESSION['rtime'.$r]=$row['rtime'.$r]; } $_SESSION['demo']=$row['demolish']; $_SESSION['demotime']=$row['downgrade']; if(strlen($row['regcode'])>0) //if not active; $errorn="(User is not <a href='activate.php'>activated</a>)"; //error! } //End SQL query for user information $name=cleand($_POST['nick']); $pass=cleand($_POST['pass']); } //End login post The problem here is that it takes very long time to return true ! but little time to return false ! any help to narrow it down a little bit so it can be fast ! Link to comment https://forums.phpfreaks.com/topic/175447-help-narrowing-down-a-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.