title: Why does my QueryPath script result in "Creating default object from empty value" error?
body: <p>I am trying to scrape a website to get some practice with <a href="https://github.com/technosophos/querypath/" rel="nofollow">QueryPath</a>.</p>
  
  <p>Here is what I have so far, and gives me an error: </p>
  
  <blockquote>
    <p><strong>Creating default object from empty value</strong></p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>// URL to scrape
  $baseurl = 'http://some-site-with-a-table-of-items-that-contain-links.com';
  
  // Get all rows from table
  $rows = htmlqp($baseurl, '#items_table')-&gt;find('tr');
  
  //initialize items array
  $items = array();
  
  // initilize counter
  $i = 0;
  
  // Iterate through rows of items
  foreach($rows as $row) {
  
      // get the url for the item in this row
      $url = qp($row)-&gt;find('.link_txt a')-&gt;attr('href');
  
      // select all the info in the item detail box
      $item = htmlqp($url)-&gt;find('.item_detail_box');
  
      // assign the item attributes to an array
      $items[$i] = [
  
          // the qp item $row is from the info on the main table of items
          'img_thumb'     =&gt; qp($row)-&gt;find('.reflection')-&gt;attr('src'),
          'name'          =&gt; qp($row)-&gt;find('.link_txt a')-&gt;text(),
          'item_level'    =&gt; qp($row)-&gt;find('.col_center')-&gt;text(),
          'req_level'     =&gt; qp($row)-&gt;find('.col_right')-&gt;text(),
          'url'           =&gt; $url,
  
          // the qp item $item is from the actual item detail page
          //'img'         =&gt; qp($item)-&gt;find('.reflection')-&gt;attr('src'),
          //'is_unique'   =&gt; qp($item)-&gt;find('.unique')-&gt;text(),
  
  
      ];
  
      $i++;
  }
  
  $data = print_r($items, true);
  
  return '&lt;pre&gt;' . $data . '&lt;/pre&gt;';
  </code></pre>
  
  <p>The error will occur if I uncomment either of the <code>img</code> or <code>is_unique</code> array lines.</p>
  
  <p>Everything else works and gives expected output when those lines are commented out.</p>