数据库返回false的PHP代码

时间:2017-12-05 13:17:20

标签: php json database

我正在创建一个必须检索数据以平衡飞机的应用。我已经创建了PHP代码来连接到一个数据库,该数据库应该从ID号中提取列值,但代码不起作用并且给我一个错误的返回。任何人都可以识别问题,因为我似乎无法找到问题。

var app = angular.module('app', []);
////////////////////////////////////////////////  
var clipboard = new Clipboard('.btn');

var platformList = [
        {id:'aa', power: 3700, level: 'level 1', picture: 1, armourPoints: 400}, 

        {id:'ab', power: 3700, level: 'level 2', picture: 2, armourPoints: 1200},

        {id:'ac', power: 3700, level: 'level 3', picture: 3, armourPoints: 3600}, 

        {id:'ad', power: 3700, level: 'level 4', picture: 4, armourPoints: 10800}, 

        {id:'ae', power: 4000, level: 'level 5', picture: 5, armourPoints: 14400}, 

        {id:'af', power: 6400, level: 'level 6', picture: 6, armourPoints: 57600}, 

        {id:'ag', power: 8155, level: 'level 7', picture: 7, armourPoints: 280000},

        {id:'ah', power: 16310, level: 'level 8', picture: 8, armourPoints: 1200000, explosiveDamage:20, ballisticDefence:30, explosiveDefence:30, penetratingDefence:30, radioactiveDefence:30}, 

        {id:'ai', power: 32620, level: 'level 9', picture: 9, armourPoints: 3300000, explosiveDamage:20, ballisticDefence:50, explosiveDefence:50, penetratingDefence:50, radioactiveDefence:50, corrosiveDefence: 50, concussiveDefence: 50}   
        ];
///////////////
var weaponList = [
        {id:'ba', power:0, name:' None'},   

        {id:'bb', name:'Phlogiston Launcher', power:8600, weaponType:'Radioactive', damageType:'Launcher', projectileSpeed:300, accuracy:90, range:200, launcherDamage:17000, salvo:5, reload:5, shockwave:25000, special: [{resonanceTrigger:'yes'},{affects:'Mortar'},{firefieldchance:20},{duration:4},{abiltyRange:24},{radField:-300}]}, 

                {id:'bc', name:'Venom Spitter', power:8900, weaponType:'Scatter Gun', damageType:'Corrosive', corrosiveBypass:95, corrosiveDamage:22400, multishot:7, projectileSpeed:330, range:105, reload:6.8, splash:16, submersedDamage:22400},

                {id:'bd', name:'Explosive D99-S', power:8900, weaponType:'Rocket', damageType:'Explosive', explosiveDamage:30000, explosiveBypass:95, projectileSpeed:330, range:105, reload:11.25, salvo:3, splash:20, spread:80, submersedDamage:30000},

                {id:'be', name:'Basilisk', power:2580, weaponType:'Scatter Gun', damageType:'Corrosive', corrosiveBypass:100, corrosiveDamage:10000, multishot:10, projectileSpeed:650, range:105, reload:3, splash:12.4, spread:100, submersedDamage:10000},

                {id:'bf', name:'Sentinel 5', power:967, weaponType:'Missile', damageType:'Penetrating', accuracy:100, ballisticDamage:125, penetratingDamage:1287, projectileSpeed:110, range:105, reload:5, salvo:4, flakEvasion:40},

                {id:'bg', name:'Hyena', power:8800, weaponType:'Missile', damageType:'Penetrating', accuracy:75, penetratingDamage:39986, penetrativeBypass:100, projectileSpeed:160, range:105, reload:5, flakEvasion:40},

                {id:'bh', name:'Apocalypse Mortar', power:3420, weaponType:'Mortar', damageType:'Explosive', explosiveDamage:7276, explosiveBypass:100, projectileSpeed:60, range:160, reload:12.11, salvo:4, splash:30, spread:80},

                {id:'bi', name:'Axiom' , power:8600, weaponType:'Depth Charge' , damageType:'Concussive' , concussiveBypass:90, concussiveDamage:51000, projectileSpeed:1000, range:235, reload:20, salvo:5, splash:20, spread:10, submersedDamage:51000, special:[{windupReload:4900},{reloadDecay:    4},{'maxReload':490}]},


        ];
///////////////
var armourList = [
        {id:'ia', power: 0, name: ' None'},
                {id:'ib' , name:'Solar Reinforcements', armourPoints:15000, baseMaxPower:50},
        {id:'ic', power: 2000, name:'name2', bal: 1000}, 
        {id:'id', power: 3000, name:'name3', conc: 2500},
        {id:'ie', power: 4000, name:'name4', conc: 5000}
        ];
///////////////
var specialList = [
        {id:'pa', power: 0, name: ' None'},
        {id:'pb', name:'Fire Support Platform M', weaponPower:33, penetratingdamage:31, penetratingrange:25},

                {id:'pc', name:'SSKP Enhancement', weaponPower:13, penetratingAccuracy:50},

                {id:'pd', name:'Thermobaric Casing 2', weaponPower:7,penetratingDamage:27},

                {id:'pe', name:'Supercharged EM Rails 2', weaponPower:45, ballisticCriticalChance:25, ballisticCriticalDamage:300},

                {id:'pf', name:'Ballistic Recoil Suppressor', weaponPower:20, ballisticDamage:65, ballisticReload:30},

        {id:'pg', name:'Compound Panels E', armourPower:12, ballisticDefence:33, explosiveDefence:33, penetratingDefence:33},


        ];

///////////////
var transformersList = [
        {id:'wa', power: 0, name: ' None'},

        {id:'wb' , name:'A-T Transformer 1', weaponPower:25, bonusDamage:35, ballisticDefence:-10, explosiveDefence:-10, penetratingDefence:-10, radioactiveDefence:-10, armourAbilities:-10},

        {id:'wc', power: 20000, name:'name2', bal: 1000}, 
        {id:'wd', power: 30000, name:'name3', conc: 2500}, 
        {id:'we', power: 40000, name:'name4', conc: 5000}
        ];
///////////////


///////////////////////////////////////////////  
function Ctrl($scope) {  
    $scope.lists = {

    platform:   platformList,
            weapon:     weaponList,
     special:   specialList,
      armour:   armourList,
       trans:   transformersList,
                                    };   
////////////////////////////////////////////////                          
Object.assign($scope, {
       platform: '',        
       weapon: '',
       armour1: '',
       armour2: '',
       armour3: '',        
       special1: '',
       special2: '',
       special3: '',
       trans1: '',  

});
////////////////////////////////////////////////  
//var checkURL = $(location).attr("href") //use this line for live site as it will use the URL
//var domain = checkURL.split('&');         //use this line for live site as it will split the URL

var fiddleURL = '   http://www.ahoymearty.co.uk/waynestest/turretbuilder/index.html#&ah&bq&ib&ib&ib&pe&pf&pg&wb' //temp URL for testing - delete this line on live site
var domain = fiddleURL.split('&');      //temp URL split for JSFiddle testing

var platformID = domain[1];
var weaponID = domain[2];
var armour1ID = domain[3];
var armour2ID = domain[4];
var armour3ID = domain[5];
var special1ID = domain[6];
var special2ID = domain[7];
var special3ID = domain[8];
var trans1ID = domain[9];

var platformFromURL = _.max(platformList, function(searchPlatform){ return searchPlatform.id == platformID;});
var weaponFromURL = _.max(weaponList, function(searchWeapon){ return searchWeapon.id == weaponID;});
var armour1FromURL = _.max(armourList, function(searchArmour1){ return searchArmour1.id == armour1ID;});
var armour2FromURL = _.max(armourList, function(searchArmour2){ return searchArmour2.id == armour2ID;});
var armour3FromURL = _.max(armourList, function(searchArmour3){ return searchArmour3.id == armour3ID;});
var special1FromURL = _.max(specialList, function(searchSpecial1){ return searchSpecial1.id == special1ID;});
var special2FromURL = _.max(specialList, function(searchSpecial2){ return searchSpecial2.id == special2ID;});
var special3FromURL = _.max(specialList, function(searchSpecial3){ return searchSpecial3.id == special3ID;});
var trans1FromURL = _.max(transformersList, function(searchTrans1){ return searchTrans1.id == trans1ID;});

$scope.platform = platformFromURL;
$scope.weapon = weaponFromURL;
$scope.armour1 = armour1FromURL;
$scope.armour2 = armour2FromURL;
$scope.armour3 = armour3FromURL;
$scope.special1 = special1FromURL;
$scope.special2 = special2FromURL;
$scope.special3 = special3FromURL;
$scope.trans1 = trans1FromURL;

//////////////////////////////////////////////// 
$scope.calcTotals = function(codeAddress){
//////////////////////////////////////////////////
//               Base Power Stats               //
//////////////////////////////////////////////////
     $scope.powertotal = Math.round(
     ($scope.weapon.power || 0) + 
     ($scope.special1.power || 0) + 
     ($scope.special2.power || 0) + 
     ($scope.special3.power || 0) + 
     ($scope.armour1.power || 0) +    
     ($scope.armour2.power || 0) + 
     ($scope.armour3.power || 0) + 
     ($scope.trans1.power || 0) +
     (($scope.trans1.weaponPower/100) * $scope.weapon.power || 0) +
     (($scope.special1.weaponPower/100) * $scope.weapon.power || 0) +      
     (($scope.special2.weaponPower/100) * $scope.weapon.power || 0) +      
     (($scope.special3.weaponPower/100) * $scope.weapon.power || 0) +           
     (($scope.armour1.weaponPower/100) * $scope.weapon.power || 0) +   
     (($scope.armour2.weaponPower/100) * $scope.weapon.power || 0) +        
     (($scope.armour3.weaponPower/100) * $scope.weapon.power || 0)          
                                                                );      
//////////////////////////////////////////////////
//                 Attack Stats                 //
//////////////////////////////////////////////////    
$scope.ballisticDamageTotal = Math.round(     
            ($scope.weapon.ballisticDamage || 0) + 
        (($scope.special1.ballisticDamage/100) * $scope.weapon.ballisticDamage || 0) + 
      (($scope.special2.ballisticDamage/100) * $scope.weapon.ballisticDamage || 0) +
      (($scope.special3.ballisticDamage/100) * $scope.weapon.ballisticDamage || 0)
                                                                        );
////////////////////////////////////   
$scope.damageTotal = Math.floor(
                $scope.ballisticDamageTotal +
        (($scope.trans1.bonusDamage/100) * $scope.ballisticDamageTotal || 0) 
                                                                );
////////////////////////////////////     
$scope.ballisticReloadPercent = Math.floor(
            ($scope.special1.ballisticReload ||0) + 
      ($scope.special2.ballisticReload ||0) + 
      ($scope.special3.ballisticReload ||0) 
                                                                );
////////////////////////////////////  
$scope.ballisticDamagePercent = Math.floor(
            ($scope.special1.ballisticDamage ||0) + 
      ($scope.special2.ballisticDamage ||0) + 
      ($scope.special3.ballisticDamage ||0) 
                                                                );
//////////////////////////////////////////////// 
$scope.explosiveDamagePercent = Math.floor(
            ($scope.special1.explosiveDamage ||0) + 
      ($scope.special2.explosiveDamage ||0) + 
      ($scope.special3.explosiveDamage ||0) 
                                                                );
//////////////////////////////////////////////// 
$scope.ballisticCriticalChanceTotal = Math.floor(
            ($scope.special1.ballisticCriticalChance ||0) + 
      ($scope.special2.ballisticCriticalChance||0)  + 
      ($scope.special3.ballisticCriticalChance ||0) 
                                                                );
//////////////////////////////////////////////// 
$scope.ballisticCriticalDamageTotal = Math.floor(
            ($scope.special1.ballisticCriticalDamage ||0) + 
      ($scope.special2.ballisticCriticalDamage||0)  + 
      ($scope.special3.ballisticCriticalDamage ||0) 
                                                                );
//////////////////////////////////////////////// 


//////////////////////////////////////////////////
//                 Defence Stats                //
//////////////////////////////////////////////////

var balisticDefence1 = ($scope.platform.ballisticDefence) ||0
var balisticDefence2 = (100-(balisticDefence1)) * ($scope.special1.ballisticDefence / 100) ||0
var balisticDefence3 = (100-(balisticDefence1 + balisticDefence2)) * ($scope.special2.ballisticDefence / 100) ||0
var balisticDefence4 = (100-(balisticDefence1 + balisticDefence2 + balisticDefence3)) * ($scope.special3.ballisticDefence / 100) ||0
var balisticDefence5 = (100-(balisticDefence1 + balisticDefence2 + balisticDefence3 + balisticDefence4)) * ($scope.trans1.ballisticDefence / 100) ||0
//////////////////////////////////////////////////
var explosiveDefence1 = ($scope.platform.explosiveDefence) ||0
var explosiveDefence2 = (100-(balisticDefence1)) * ($scope.special1.explosiveDefence / 100) ||0
var explosiveDefence3 = (100-(balisticDefence1 + balisticDefence2)) * ($scope.special2.explosiveDefence / 100) ||0
var explosiveDefence4 = (100-(balisticDefence1 + balisticDefence2 + balisticDefence3)) * ($scope.special3.explosiveDefence / 100) ||0
var explosiveDefence5 = (100-(balisticDefence1 + balisticDefence2 + balisticDefence3 + balisticDefence4)) * ($scope.trans1.explosiveDefence / 100) ||0
//////////////////////////////////////////////////
var penetratingDefence1 = ($scope.platform.penetratingDefence) ||0
var penetratingDefence2 = (100-(penetratingDefence1)) * ($scope.special1.penetratingDefence / 100) ||0
var penetratingDefence3 = (100-(penetratingDefence1 + penetratingDefence2)) * ($scope.special2.explosiveDefence / 100) ||0
var penetratingDefence4 = (100-(penetratingDefence1 + penetratingDefence2 + penetratingDefence3)) * ($scope.special3.penetratingDefence / 100) ||0
var penetratingDefence5 = (100-(penetratingDefence1 + penetratingDefence2 + penetratingDefence3 + penetratingDefence4)) * ($scope.trans1.penetratingDefence / 100) ||0
//////////////////////////////////////////////////
var radioactiveDefence1 = ($scope.platform.radioactiveDefence) ||0
var radioactiveDefence2 = (100-(radioactiveDefence1)) * ($scope.special1.radioactiveDefence / 100) ||0
var radioactiveDefence3 = (100-(radioactiveDefence1 + radioactiveDefence2)) * ($scope.special2.radioactiveDefence / 100) ||0
var radioactiveDefence4 = (100-(radioactiveDefence1 + radioactiveDefence2 + radioactiveDefence3)) * ($scope.special3.radioactiveDefence / 100) ||0
var radioactiveDefence5 = (100-(radioactiveDefence1 + radioactiveDefence2 + radioactiveDefence3 + radioactiveDefence4)) * ($scope.trans1.radioactiveDefence / 100) ||0
//////////////////////////////////////////////////
var corrosiveDefence1 = ($scope.platform.corrosiveDefence) ||0
var corrosiveDefence2 = (100-(corrosiveDefence1)) * ($scope.special1.corrosiveDefence / 100) ||0
var corrosiveDefence3 = (100-(corrosiveDefence1 + corrosiveDefence2)) * ($scope.special2.corrosiveDefence / 100) ||0
var corrosiveDefence4 = (100-(corrosiveDefence1 + corrosiveDefence2 + corrosiveDefence3)) * ($scope.special3.corrosiveDefence / 100) ||0
var corrosiveDefence5 = (100-(corrosiveDefence1 + corrosiveDefence2 + corrosiveDefence3 + corrosiveDefence4)) * ($scope.trans1.corrosiveDefence / 100) ||0
//////////////////////////////////////////////////
var concussiveDefence1 = ($scope.platform.concussiveDefence) ||0
var concussiveDefence2 = (100-(concussiveDefence1)) * ($scope.special1.concussiveDefence / 100) ||0
var concussiveDefence3 = (100-(concussiveDefence1 + concussiveDefence2)) * ($scope.special2.concussiveDefence / 100) ||0
var concussiveDefence4 = (100-(concussiveDefence1 + concussiveDefence2 + concussiveDefence3)) * ($scope.special3.concussiveDefence / 100) ||0
var concussiveDefence5 = (100-(concussiveDefence1 + concussiveDefence2 + concussiveDefence3 + concussiveDefence4)) * ($scope.trans1.concussiveDefence / 100) ||0
//////////////////////////////////////////////////


$scope.ballisticDefenceTotal = Math.round(balisticDefence1 + balisticDefence2 + balisticDefence3  + balisticDefence4 + balisticDefence5)
$scope.explosiveDefenceTotal = Math.round(explosiveDefence1 + explosiveDefence2 + explosiveDefence3  + explosiveDefence4 + explosiveDefence5)
$scope.penetratingDefenceTotal = Math.round(penetratingDefence1 + penetratingDefence2 + penetratingDefence3  + penetratingDefence4 + penetratingDefence5)
$scope.radioactiveDefenceTotal = Math.round(radioactiveDefence1 + radioactiveDefence2 + radioactiveDefence3  + radioactiveDefence4 + radioactiveDefence5)
$scope.corrosiveDefenceTotal = Math.round(corrosiveDefence1 + corrosiveDefence2 + corrosiveDefence3  + corrosiveDefence4 + corrosiveDefence5)
$scope.concussiveDefenceTotal = Math.round(concussiveDefence1 + concussiveDefence2 + concussiveDefence3  + concussiveDefence4 + concussiveDefence5)

//////////////////////////////////////////////////
$scope.armourPointsTotal = $scope.platform.armourPoints + 
$scope.armour1.armourPoints  + 
$scope.armour2.armourPoints + 
$scope.armour3.armourPoints

//////////////////////////////////////////////////
//////////////////////////////////////////////////
var buildPower = $scope.powertotal;
var totalPower = $scope.platform.power + ($scope.armour1.baseMaxPower || 0) + ($scope.armour2.baseMaxPower || 0) + ($scope.armour3.baseMaxPower || 0) ;
var pictureNeeded = $scope.platform.picture;

//change image according to drop menu selection
var imageUrl = "http://ahoymearty.co.uk/turretbuilder/images/turretlvl" + pictureNeeded + ".png"
$('#platformImage').css('background-image', 'url(' + imageUrl + ')');

//////////////////////////////////////////////// 


} //end of var app

我希望结果允许我的应用程序使用ID编号来提取值。

0 个答案:

没有答案