Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Bunch of random errors.

    1| Notice: Undefined index: acc in /var/www/vhosts/steam-wars.com/httpdocs/beta/index.php on line 4
    PHP Code:
    if($_REQUEST['acc'] !== $_SESSION['user_email'] && $_REQUEST['acc'] != NULL) { 
    2 | Notice: Use of undefined constant rank - assumed 'rank' in /var/www/vhosts/steam-wars.com/httpdocs/beta/rankup.php on line 30
    Notice: Undefined index: Admin in /var/www/vhosts/steam-wars.com/httpdocs/beta/rankup.php on line 30
    PHP Code:
    $req_exp=$req_exp_array[$stats_array[rank]];
    $cur_exp=$stats_array["exp"];

    if (
    $stats_array["rank"]=="Admin"

    3 | Notice: Use of undefined constant suspicion_lastcalc - assumed 'suspicion_lastcalc' in /var/www/vhosts/steam-wars.com/httpdocs/beta/ai_police.php on line 18 Notice: Use of undefined constant suspicion_lastcalc - assumed 'suspicion_lastcalc' in /var/www/vhosts/steam-wars.com/httpdocs/beta/ai_police.php on line 33 Notice: Use of undefined constant level_suspicion - assumed 'level_suspicion' in /var/www/vhosts/steam-wars.com/httpdocs/beta/ai_police.php on line 65
    PHP Code:
    <?
    // SETTINGS
    //*************************************
    $calcevery "1500"// how often to calc heat
    $moneytoheat "150000"// how much money change = 1 heat point
    $sentence_warrant "3600"// typical "outstanding warrant" sentence
    $bail_warrant "500000";
    $arrestchance "13"// % chance of being arrested when heat is maxed out
    //*************************************

    $time time(); // set timestamp used for many features listed below
    //print "TIME: $time<br>";
    //print "LAST CALC: ".($time - $stats_array['suspicion_lastcalc'])."<br/>";

    // HEAT CALCULATOR
    //*************************************

    if ($stats_array[suspicion_lastcalc]==0)
    {

        
    $curnet=$stats_array[bank];

        
    $sql="UPDATE user_skills SET suspicion_lastcalc='$time', suspicion_prevnet='$curnet' WHERE nickname='$stats_array[nickname]'";
        
    //print "SQL: $sql<br/>";
        
    $sql=mysql_query($sql);

    }
    elseif (
    $tools->IsInJail())
    {
        
    // in jail--do nothing
        //print "In jail....<br/>";
    }
    elseif ((
    $time $stats_array[suspicion_lastcalc]) > $calcevery)
    {

        
    $curnet=$stats_array[bank];
        
    $prevnet=$stats_array[suspicion_prevnet];

        
    $change=$curnet $prevnet;
        
    $change=round($change);
        
    $heatchange=$change $moneytoheat;

        if (
    $heatchange <= 0)
        { 
    //reduce heat
            
    $heatchange *= -1;
            
    $newsuspicion=$stats_array[level_suspicion] - $heatchange;
            if (
    $newsuspicion 0) { $newsuspicion=0; }
        }
        else
        { 
    //gain heat
            
    $newsuspicion=$stats_array[level_suspicion] + $heatchange;
            if (
    $newsuspicion 100) { $newsuspicion=100; }
        }

        
    $sql="UPDATE user_skills SET suspicion_lastcalc='$time', suspicion_prevnet='$curnet', level_suspicion='$newsuspicion' WHERE nickname='$stats_array[nickname]'";    
        
    //print "SQL: $sql<br/>";
        
    $sql=mysql_query($sql);

    }


    // THE ARREST/SHAKEDOWN
    //*************************************

    if ($stats_array[level_suspicion]==100 AND $x != "policestation")
    {

        
    $randarrest=rand(1,100);
        if (
    $randarrest <= $arrestchance)
        {
            
    $beatup=rand(1,150);
            
    $damage=rand(5,30);

            if (
    $beatup $stats_array[level_suspicion]) { // get beatup
                    
    $time=time();
                        
    mysql_query("INSERT INTO user_actions (id, user, type, action, city, time) values ('','$stats_array[nickname]','busted-heat','<a target=content href=driver.php?x=profile&u=$stats_array[nickname]>$stats_array[nickname]</a> <img src=/beta/layout_images/abusted.png title=\"Busted For Warrants\">','$stats_array[city]','$time')");
            echo
    "<br><br><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br /><font color=red><b>Error | You Got Caught. The Chief Sent Some Of His Guys To Pick You Up After Getting Tired Of Waiting For His Cut. They Gave You An Old Fashioned Lesson In Police Brutality Which Damaged Your Health By ".$damage."%. They Also Booked You For Outstanding Warrants.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />"; }  
    else {
                    
    $time=time();
                        
    mysql_query("INSERT INTO user_actions (id, user, type, action, city, time) values ('','$stats_array[nickname]','busted-heat','<a target=content href=driver.php?x=profile&u=$stats_array[nickname]>$stats_array[nickname]</a> <img src=/beta/layout_images/abusted.png title=\"Busted For Warrants\">','$stats_array[city]','$time')");
    echo
    "<br><br><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br /><font color=red><b>Error | Looks Like You Got Caught Chump. The Chief Does Not Like Waiting For His Cut. They Booked You For Outstanding Warrants.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />"; }
            
    $sentence=time() + $sentence_warrant;
            
    $sql="UPDATE adv_stats, jail, user_characters, user_skills SET adv_stats.busted=adv_stats.busted+1, jail.jailsentence='$sentence', jail.crimecommited='Outstanding Warrants', jail.bail='$bail_warrant', user_characters.weapon='0', user_characters.cash='0', user_skills.level_suspicion='0', user_skills.level_health=user_skills.level_health-$damage WHERE adv_stats.nickname='$stats_array[nickname]' AND jail.nickname='$stats_array[nickname]' AND user_characters.nickname='$stats_array[nickname]' AND user_skills.nickname='$stats_array[nickname]'";
            
    //print "SQL: $sql<br/>";
            
    $sql=mysql_query($sql);
            exit;
        }
    }
    ?>

  • #2
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,368
    Thanks
    262
    Thanked 32 Times in 31 Posts
    those are not errors, those are notices.

    As for yours,

    #1 prob just needs to be initialized
    #2 same
    #3 same


    Basic Notices do not effect script performance like a fatal error would. So you have several choices.

    First you can set your error control in the script or in the htaccess or in the php ini to only show fatal error and hide notices. And then they wont show and you can run your script to your hearts content with no notices showing. I dont prefer to do that because IMO it needs to be fixed, but im just anal that way.

    Or you can decide to initiate the var beforre you use it.

    if(!isset($myvar)){$myvar='';}

    and do that for every one at the beginning of that php file, you may have a long list and then the notices will go away.
    Last edited by durangod; 01-24-2014 at 11:45 PM.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You cannot rely on the availability of anything in the request superglobal. Also, don't use the request superglobal, use either get or post depending on method:
    PHP Code:
    if (isset($_GET['acc']) && $_GET['acc'] != $_SESSION['user_email']) 
    2 and 3 are the same problem. You must wrap any string in quotations otherwise its a constant. In this case its for the associative offset of the array.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    VegasKiller (01-25-2014)

  • #4
    New Coder
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    You cannot rely on the availability of anything in the request superglobal. Also, don't use the request superglobal, use either get or post depending on method:
    PHP Code:
    if (isset($_GET['acc']) && $_GET['acc'] != $_SESSION['user_email']) 
    2 and 3 are the same problem. You must wrap any string in quotations otherwise its a constant. In this case its for the associative offset of the array.
    Thank you this fixed it, But I still do not get what you mean by wrapping the vars.

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    He means this:

    $req_exp=$req_exp_array[$stats_array[rank]];

    Should be this:
    $req_exp=$req_exp_array[$stats_array['rank']];
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    VegasKiller (01-27-2014)

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    That's right; without the quotes than the string is a constant. PHP defaults constants it cannot find to a string and issues a warning, but it should be corrected in case you happen to define a constant by the same name.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    VegasKiller (01-27-2014)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •