1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

"Undefined variable: data"

Discussion in 'General discussion' started by RJoLe, Sep 2, 2021.

  1. RJoLe

    RJoLe Creeper

    Messages:
    5
    I was making a market plugin. I created my "cases" under the switch($data) value in my form.
    I got this error when I tried the plugin. What should I do to fix the error?

    HTML:
    [22:58:03] [Server thread/CRITICAL]: ErrorException: "Undefined variable: data"
    (EXCEPTION) in "plugins/[ MarketUI ]/src/MarketUI/AnaForm" at line 33
    
    PHP:
    if($data == null){
                   
    $sender->sendMessage("§7«============[ §aMarket §7]============»\n§cMarket Menusunden Basariyla Ciktin...\n§7«=================================»");
                return;
               };

                switch(
    $data){
                    case 
    0:
                        
    $form Dogal;
                        
    $form->DogalForm($sender);
                    break;
                       
                    case 
    1:
                        
    $form Insaat;
                        
    $form->InsaatForm($sender);
                    break;
                       
                    case 
    2:
                        
    $form Ekipman;
                        
    $form->EkipmanForm($sender);
                    break;
                       
                    case 
    3:
                        
    $form Zirhlar;
                        
    $form->ZirhlarForm($sender);
                    break;
                       
                    case 
    4:
                        
    $form Tohumlar;
                        
    $form->TohumlarForm($sender);
                    break;
                       
                    case 
    5:
                        
    $form Diger;
                        
    $form->DigerForm($sender);
                    break;
                       
                    case 
    6:
                        
    $sender->sendMessage("§7«============[ §aMarket §7]============»\n§cMarket Menusunden Basariyla Ciktin...\n§7«=================================»");
                        return;
                    break;

                };
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    Define the variable, because it is undefined
     
    minijaham likes this.
  3. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Now this code gives me a question...
    Since I'm not very familiar with PHP, what does php detect "Dogal" in the following code as?
    PHP:
    $form Dogal;
    Is it detected as a string? Or...does it give you an error :smirk:

    Edit: Okay so apparently it does return a string when dumped.

    WHAT???
     
    Agent and Primus like this.
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    upload_2021-9-2_21-48-59.png
    upload_2021-9-2_21-49-12.png

    WHATTT
     
    Agent and Primus like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.