Title: PHP variable issues
Last modified: August 22, 2016

---

# PHP variable issues

 *  Resolved [Laneige90](https://wordpress.org/support/users/laneige90/)
 * (@laneige90)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/php-variable-issues/)
 * Hi there.
 * I’m having a few issues with some code of mine. This is my custom hook function
   in functions.php.
 *     ```
       function GrabExtraOrderInfo($args)
       {
           global $wpdb;
           $postid = (int)$args->id;
           $ExtraDimensions = get_post_meta(1872/*$postid*/,'_extraDimensions');
           $Shapeid = get_post_meta(1872/*$postid*/,'_shapeid',true);
           $shapeIdInt = (int)$Shapeid;
           $ShapeTable = $wpdb->prefix . "ShapeData";
   
           $url = $wpdb->get_results("SELECT $ShapeTable.url FROM $ShapeTable WHERE              id =$shapeIdInt");
   
           foreach($url as $chunks)
           {echo '<img src="' . $chunks->url . '"/>';}
   
           foreach ($ExtraDimensions as $values)
           {echo print_r($values);}
   
           die();
       }
       ```
   
 * My problem is with the get_post_meta id under it’s first argument. If I put an
   integer directly as a parameter, the data I need is retrieved and it is echoed
   correctly. However, if I use my `$postid` variable, the function prints nothing.
   Now, if I debug the `$postid` variable it outputs the id I need correctly. I 
   assumed that it must be due to it not being converted as an integer but my string
   to int conversion as made no difference.
 * The parameter `$args` is the order object sent from the order email (woocommerce)

The topic ‘PHP variable issues’ is closed to new replies.

## Tags

 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [string](https://wordpress.org/support/topic-tag/string/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 0 replies
 * 1 participant
 * Last reply from: [Laneige90](https://wordpress.org/support/users/laneige90/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/php-variable-issues/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
