SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Strict Standards: Non-static method DOMDocument::load() should not be called sta

    Hi...
    I tried to import to my database an xml file using this code:
    PHP Code:
    <?php
    //ini_set('display_errors', -1);
    //error_reporting(E_ALL);
    //error_reporting(-1);
    error_reporting(E_ALL E_STRICT);
    //error_reporting(E_ALL ^ E_NOTICE);
      
    date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $data = array();
    $con mysql_connect("localhost""root","");
    if (!
    $con) {
      die(
    mysql_error());
    }
    $db mysql_select_db("mes"$con);
    if (!
    $db) {
      die(
    mysql_error());
    }


    function 
    add_employee($ETD,$PO_No,$SKUCode,$Description,$POReq ,$Comp)
      {
          global 
    $data;
        
        
          
    $con mysql_connect("localhost""root","");
          if (!
    $con){ die(mysql_error());}
          
    $db mysql_select_db("mes"$con);
          if (!
    $db) {
              die(
    mysql_error());
          }
          
    $ETD$ETD;
          
    $PO_No $PO_No;
          
    $SKUCode $SKUCode;
          
    $Description $Description;
          
    $POReq $POReq;
          
    $Comp $Comp;
        
          
    $sql "INSERT INTO sales_order (ETD,PO_No,SKUCode,Description,POReq,Comp)
          VALUES
          ('
    $ETD','$PO_No','$SKUCode','$Description','$POReq','$Comp')
          ON DUPLICATE KEY UPDATE
          ETD = '
    $ETD', PO_No = '$PO_No', SKUCode = '$SKUCode', Description = '$Description', POReq = '$POReq', Comp = '$Comp'" or die(mysql_error());
          
    $res mysql_query($sql$con);
        
           
    $data []= array('ETD'=>$ETD,'PO_No'=>$PO_No,'SKUCode'=>$SKUCode,'Description'=>$Description,'POReq'=>$POReq,'Comp'=>$Comp);
    }
    // if (isset($_FILES['file']['tmp_name'])){

      
    if(empty($_FILES['file']['tmp_name']['error'])){
         
    $dom = new DOMDocument();
          
    $dom DOMDocument::load('SalesOrder.xml');  
       
    //$dom = DOMDocument::load($_FILES['file']['tmp_name']);
        //$dom = DOMDocument::__construct();          
          
    $rows $dom->getElementsByTagName('Row');
          global 
    $last_row;
          
    $last_row false;
          
    $first_row true;
          foreach (
    $rows as $row)
          {
              if ( !
    $first_row )
              {
                  
    $ETD "";
                  
    $PO_No "";
                  
    $SKUCode "";
                  
    $Description "";
                  
    $POReq "";
                  
    $Comp "";
                
                  
    $index 1;
                  
    $cells $row->getElementsByTagName'Cell' );
            
                  foreach( 
    $cells as $cell )
                  {
                      
    $ind $cell->getAttribute'Index' );
                      if ( 
    $ind != null $index $ind;
                      if ( 
    $index == $ETD $cell->nodeValue;
                      if ( 
    $index == $PO_No $cell->nodeValue;
                      if ( 
    $index == $SKUCode $cell->nodeValue;
                      if ( 
    $index == $Description $cell->nodeValue;
                      if ( 
    $index == $POReq $cell->nodeValue;
                      if ( 
    $index == $Comp $cell->nodeValue;
                                        
    $index += 1;
                  }
                 if (
    $ETD=='' AND $PO_No=='' AND $SKUCode=='' AND $Description=='' AND $POReq=='' AND $Comp=='') {
                        
    $last_row true;
                  }    
                  else {
                        
    add_employee($ETD,$PO_No,$SKUCode,$Description$POReq$Comp);
                  }    
              }
              if (
    $last_row==true) {
                  
    $first_row true;
              }    
              else {
                  
    $first_row false;
              }
          }
      }

      
    ?>
    but I got an error:
    Strict Standards: Non-static method DOMDocument::load() should not be called statically
    in this part:
    $dom = DOMDocument::load('SalesOrder.xml');
    I hope somebody can help me...I need to import data from .xml to my database.
    Thank you so much

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The reason why it's happening is because your calling a method in the DOMDocument class in which is not static, instead of calling it with :: you need to call it with ->. See the following link which has an example of how to use the methods.

    http://www.php.net/manual/en/domdocument.load.php

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, ur right thats the solution..

    Thank you for your help..


Bookmarks

Posting Permissions

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