boionfire81 Posted June 14, 2016 Share Posted June 14, 2016 ok, php code check said no errors found. But yet the page displays an error. <?php require_once('globals.php'); if($ir['jail'] == 0 && $ir['hospital'] == 0) { include ('access.php'); } global $ir,$db,$h; if($ir['gang'] == 0) { echo "You're not in a Gang."; $h->endpage(); } $requireSettings = true; $gq = $db->query("SELECT `g`.*, `oc`.*, `gs`.* " . "FROM `gangs` AS `g` " . "LEFT JOIN `orgcrimes` AS `oc` ON (`g`.`gangCRIME` = `oc`.`ocID`) " . "LEFT JOIN `gang_settings` AS `gs` ON (`gs`.`gangid` = `g`.`gangID`) " . "WHERE `g`.`gangID` = ".$ir['gang']); if(!$db->num_rows($gq)) { $db->query("UPDATE `users` SET `gang` = 0 WHERE `gang` = ".$ir['gang']); echo "Your Gang doesn't exist"; } $gangdata = $db->fetch_row($gq); $gpdata = $db->query("SELECT `username`, `userid` FROM `users` WHERE `userid` = {$gangdata['gangPRESIDENT']}"); $gvpdata = $db->query("SELECT `username`, `userid` FROM `users` WHERE `userid` = {$gangdata['gangVICEPRES']}"); ERROR is A critical error has occurred, and page execution has stopped. Below are the details: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Action taken: Attempted to execute query: SELECT `username`, `userid` FROM `users` WHERE `userid` = stopped code at the only 2 matching sqls. The gangdata would not apply, which would cause the error for noobs (as in this case). HOWEVER, the ir gang = 0 isn't working I'm guessing? Quote Link to comment Share on other sites More sharing options...
Dayo Posted June 14, 2016 Share Posted June 14, 2016 if there is no gang you are echoing out that the user is in no gang but not killing the script, after that you are missing $h->endpage(); or you coulde use else { /* $gangdata ...*/ } Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted June 14, 2016 Author Share Posted June 14, 2016 endpage is there ^ Quote Link to comment Share on other sites More sharing options...
AdamHull Posted June 14, 2016 Share Posted June 14, 2016 Under echo "Your Gang doesn't exist"; Add $h->endpage(); is what he means Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted June 14, 2016 Author Share Posted June 14, 2016 still have the same error. Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted June 14, 2016 Author Share Posted June 14, 2016 ok added the else, and it kills the mysql error for noobs, but gang members see Fatal error: Uncaught Error: Call to undefined function gang_index() Quote Link to comment Share on other sites More sharing options...
G7470 Posted June 14, 2016 Share Posted June 14, 2016 That tells me that gang_index() is not a function, or if it is, the script can't get to it. ~G7470 Quote Link to comment Share on other sites More sharing options...
boionfire81 Posted June 14, 2016 Author Share Posted June 14, 2016 <?php require_once('globals.php'); if($ir['jail'] == 0 && $ir['hospital'] == 0) { include ('access.php'); } global $ir,$db,$h; if(!$ir['gang']) { echo "You're not in a Gang."; $h->endpage(); } $gq = $db->query("SELECT `g`.*, `oc`.*, `gs`.* FROM `gangs` AS `g` LEFT JOIN `orgcrimes` AS `oc` ON `g`.`gangCRIME` = `oc`.`ocID` LEFT JOIN `gang_settings` AS `gs` ON `gs`.`gangid` = `g`.`gangID` WHERE `g`.`gangID` = {$ir['gang']}"); if(!$db->num_rows($gq)) { $db->query("UPDATE `users` SET `gang` = 0 WHERE `gang` = {$ir['gang']}"); echo "Your Gang doesn't exist"; $h->endpage(); } else { $requireSettings = true; $gangdata = $db->fetch_row($gq); $gpdata = $db->query("SELECT `username`, `userid` FROM `users` WHERE `userid` = {$gangdata['gangPRESIDENT']}"); $gvpdata = $db->query("SELECT `username`, `userid` FROM `users` WHERE `userid` = {$gangdata['gangVICEPRES']}"); $pres=$db->fetch_row($gpdata); $vicepres=$db->fetch_row($gvpdata); $gmem = $db->query("SELECT `userid`, `username`, `level`, `daysingang` FROM `users` WHERE `gang` = {$gangdata['gangID']} ORDER BY `daysingang` DESC, `level` DESC"); $gmembers=$db->fetch_row($gmem); $memcount=$db->num_rows($gmem); echo "<h3><a href='gang.php'> {$gangdata['gangNAME']}</a></h3>"; if($requireSettings) if(empty($gangdata['armoury_is_closed']) && (!isset($_GET['act2']) || $_GET['act2'] != 'editarmoury')){ echo " {$pres['username']} <strong>must</strong> set up the Gang armoury before you can access this.<br />"; if($gangdata['gangPRESIDENT'] == $ir['userid']) { echo "This can be done <a href='gang.php?action=staff&act2=editarmoury'>here</a><br />";} } $wq = $db->query("SELECT COUNT(`warID`) FROM `gangwars` WHERE `warDECLARER` = ".$ir['gang']." OR `warDECLARED` = ".$ir['gang']); if($db->fetch_single($wq)) { echo "<hr /><h3><a href='gang.php?action=warview' style='color: red;'>Your Gang is currently in {$wq} war's($db->fetch_single($wq))</a></h3><hr />"; } $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case "idx": gang_index(); break; case "summary": gang_summary(); break; case "members": gang_memberlist(); break; case "kick": gang_staff_kick(); break; case "donate": gang_donate(); break; case "donate2": gang_donate2(); break; case "warview": gang_warview(); break; case "staff": gang_staff(); break; case "leave": gang_leave(); break; case "atklogs": gang_atklogs(); break; case "crimes": gang_crimes(); break; case "forums": gang_forums(); break; case 'viewarmoury': gang_view_armoury(); break; case 'borrowitem': gang_borrow_item(); break; case 'donateitem': gang_donate_item(); break; default: gang_index(); break; } function gang_index() { global $db, $ir, $userid, $gangdata, $mtg, $gangs; $selectEvents = $db->query("SELECT `gevTIME`, `gevTEXT` FROM `gangevents` WHERE `gevGANG` = ".$ir['gang']." ORDER BY `gevTIME` DESC LIMIT 10"); has to be something to do with the else statement as it didn't happen prior. I can remove the else, but that leaves me back to the op. code checking now. Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted June 15, 2016 Share Posted June 15, 2016 <?php require_once('globals.php'); if($ir['jail'] == 0 && $ir['hospital'] == 0) { include ('access.php'); } global $ir,$db,$h; if(!$ir['gang']) { echo "You're not in a Gang."; $h->endpage(); } $gq = $db->query("SELECT `g`.*, `oc`.*, `gs`.* FROM `gangs` AS `g` LEFT JOIN `orgcrimes` AS `oc` ON `g`.`gangCRIME` = `oc`.`ocID` LEFT JOIN `gang_settings` AS `gs` ON `gs`.`gangid` = `g`.`gangID` WHERE `g`.`gangID` = {$ir['gang']}"); if(!$db->num_rows($gq)) { $db->query("UPDATE `users` SET `gang` = 0 WHERE `gang` = {$ir['gang']}"); echo "Your Gang doesn't exist"; $h->endpage(); } else { $requireSettings = true; $gangdata = $db->fetch_row($gq); $gpdata = $db->query("SELECT `username`, `userid` FROM `users` WHERE `userid` = {$gangdata['gangPRESIDENT']}"); $gvpdata = $db->query("SELECT `username`, `userid` FROM `users` WHERE `userid` = {$gangdata['gangVICEPRES']}"); $pres=$db->fetch_row($gpdata); $vicepres=$db->fetch_row($gvpdata); $gmem = $db->query("SELECT `userid`, `username`, `level`, `daysingang` FROM `users` WHERE `gang` = {$gangdata['gangID']} ORDER BY `daysingang` DESC, `level` DESC"); $gmembers=$db->fetch_row($gmem); $memcount=$db->num_rows($gmem); echo "<h3><a href='gang.php'> {$gangdata['gangNAME']}</a></h3>"; if($requireSettings) if(empty($gangdata['armoury_is_closed']) && (!isset($_GET['act2']) || $_GET['act2'] != 'editarmoury')){ echo " {$pres['username']} <strong>must</strong> set up the Gang armoury before you can access this.<br />"; if($gangdata['gangPRESIDENT'] == $ir['userid']) { echo "This can be done <a href='gang.php?action=staff&act2=editarmoury'>here</a><br />";} } $wq = $db->query("SELECT COUNT(`warID`) FROM `gangwars` WHERE `warDECLARER` = ".$ir['gang']." OR `warDECLARED` = ".$ir['gang']); if($db->fetch_single($wq)) { echo "<hr /><h3><a href='gang.php?action=warview' style='color: red;'>Your Gang is currently in {$wq} war's($db->fetch_single($wq))</a></h3><hr />"; } $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case "idx": gang_index(); break; case "summary": gang_summary(); break; case "members": gang_memberlist(); break; case "kick": gang_staff_kick(); break; case "donate": gang_donate(); break; case "donate2": gang_donate2(); break; case "warview": gang_warview(); break; case "staff": gang_staff(); break; case "leave": gang_leave(); break; case "atklogs": gang_atklogs(); break; case "crimes": gang_crimes(); break; case "forums": gang_forums(); break; case 'viewarmoury': gang_view_armoury(); break; case 'borrowitem': gang_borrow_item(); break; case 'donateitem': gang_donate_item(); break; default: gang_index(); break; } function gang_index() { global $db, $ir, $userid, $gangdata, $mtg, $gangs; $selectEvents = $db->query("SELECT `gevTIME`, `gevTEXT` FROM `gangevents` WHERE `gevGANG` = ".$ir['gang']." ORDER BY `gevTIME` DESC LIMIT 10"); has to be something to do with the else statement as it didn't happen prior. I can remove the else, but that leaves me back to the op. code checking now. i hated mccodes gangs why i made my own Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted June 18, 2016 Share Posted June 18, 2016 I know my code when I see it.. Could just ask me for help.. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted June 18, 2016 Share Posted June 18, 2016 Also, else statement is incorrect. Change the if() statement if(!$ir['gang']) { echo 'You\'re not in a gang'; exit($h->endpage()); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.