Jump to content
MakeWebGames

php code check no errors found??


Recommended Posts

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?

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...