Jump to content

rwhite35

Members
  • Posts

    159
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.octoberblue.net
  • Yahoo
    rwhite4166@yahoo.com

Profile Information

  • Gender
    Not Telling
  • Location
    Cleveland, Ohio
  • Interests
    Development, playing guitar, watching my boys play sports.

rwhite35's Achievements

Member

Member (2/5)

6

Reputation

  1. Sorry correction to the above: // does work echo "Team Name: " . $lrow['rteamname'] . ", Season: " . $lrow['season']; //does work echo "Team Name: $lrow[rteamname], Season: $lrow[season]"; // doesn't work echo "Season: $lrow['season'], ..."; regular scalar variables like $teamname wouldn't require concatinating or escaping when using double quotes around the echo statement. Mixed quotes like above do require one syntax or the other.
  2. Notice the syntax Requinix is using with your associative array key names. You need quotes around the key name. echo "Season: $lrow['season'], League: $lrow['league'], Team Name: $lrow['rteamname'], First Name: $lrow['firstname'], Last Name: $lrow['lastname']"; Note you can only output your variables without concatinating a long string when your variables are enclosed in double quotes: // doesn't work echo "Season: $lrow["season"], ..."; // doesn't work echo 'Season: $lrow['season'], ...'; // does work, concatinated string echo "Season: " . $lrow["season"] . ", ..."; //does work, concatinated string echo 'Season: ' . $lrow['season'] . ', ...'; // does work, mixed quotes echo "Season: $lrow['season'], ..."; Finally, to make sure your array has value use var_dump($array_name) or print_r($array_name) to output the arrays content. Good Luck rwhite35
  3. This works great. <?php $qparams = array(); if($_POST) { $skus = $_POST['rec']; foreach($skus as $key=>$value) { $qparams[] = array($key, $_POST['ponumb'], $_POST['strnbr']); } } echo "<pre>"; print_r($qparams); echo "</pre>"; ?> <html> <head> <title>Testing HTML Array</title> </head> <body> <form action="", method=post> <fieldset><label>Test Form</label><br> 1769057 <input type="radio" name=rec[1769057] selected> 1768743 <input type="radio" name=rec[1768743] selected> <input type="text" name="ponumb" value="D000000034"> <input type="text" name="strnbr" value="100"><br> <input type="submit" value="submit"><br> </fieldset> </form> </body> </html> outputs Array ( [0] => Array ( [0] => 1769057 [1] => D000000034 [2] => 100 ) [1] => Array ( [0] => 1768743 [1] => D000000034 [2] => 100 )) Thanks! rwhite35
  4. Hey Jacques, Thank you for the reply. I've coded up mac_gyvers answer and it works great. I think it is similar to what you are suggesting too. Later, Ron
  5. Thanks mac_gyver, Ill try that and post the result.
  6. Hello, Have an associative array of variable length and variable key names. The POST array can have the following structure, where [rec_n] can have one or many elements. : $_POST Array ( [rec_1769057] => on [rec_1768743] => on [ponumb] => D000000034 [strnbr] => 100 ) The 'n' is a variable SKU number and concatenated from a select statement. There are thousands of SKUs. PONUMB and STRNBR are static and will always be at the end of the array. I have an algorithm for slicing this array into two separate arrays. skuitems Array ( [rec_1769057] => on [rec_1768743] => on ) postrnbr Array ( [ponumb] => D000000034 [strnbr] => 100 ) The two arrays are then assigned to a $params array one for each update statement... $params Array ( [0] => Array ( [0] => 1768743 [1] => D000000034 [2] => 100 ) [1] => Array ( [0] => 1769057 [1] => D000000034 [2] => 100 )) I would like to accomplish the above in one go... At present the solution has and O(2) notation. Here is the algorithm that works, but seems clunky to me. if( isset($postar) && is_array($postar)) { // first order of mag. $cnt = count($postar) - 2; // total minus last two elements $postrnbr = array_slice( $postar, -2, 2 ); // always ponumb and strnbr $skuitems = array_slice($postar, 0, $cnt); // will be one or more sku items $skukeys = array_keys($skuitems); $qparams = array(); //bind params for update statement foreach($skukeys as $sku) { // second order of mag. $skusplit = explode("_",$sku); // ie Array( [0]=>rec, [1]=>1234545 ) $qparams[] = array($skusplit[1], $postrnbr['ponumb'], $postrnbr['strnbr']); } } Thanks in advance! rwhite35
  7. Have a Zend Framework 2.4 connection factory that needs to establish a connection with an AS400 iSeries database. The connection has to be made this way bcuz there are multiple test environment and the factory needs to accommodate each. The method is using Zend\Db\Adapter\Adapter and I pass that class an array of database connection parameters. At issue: Zend\Db\Adapter doesn't accept the relational database (directory) name. I'm assuming that since the driver is PDO_IBM, there would be some expectation of a field for explicitly defining the name for the directory. Here is the method: public function conn($dbs) { $this->adapter = new Adapter(array( 'driver' => $dbs['db']['driver'], 'dbname' => $dbs['db']['dbname'], 'username' => $dbs['db']['username'], 'password' => $dbs['db']['password'], 'hostname' => $dbs['db']['hostname'], 'port' => $dbs['db']['port'], )); var_dump($this->adapter); return $this->adapter; } Adapter is an alias for \Zend\Db\Adapter\Adapter And here is the object that gets created. ["driver":protected]=> object(Zend\Db\Adapter\Driver\Pdo\Pdo)#224 (4){ ["connection":protected]=>object(Zend\Db\Adapter\Driver\Pdo\Connection)#225 (6) { ["driver":protected]=> *RECURSION* ["profiler":protected]=> NULL ["driverName":protected]=> string(3)"ibm" ["connectionParameters":protected]=> array(6) { ["driver"]=> string(7) "PDO_IBM" ["dbname"]=> string(7) “<relational_database_name>” ["username"]=> string(3) “<user_name" ["password"]=> string(3) “<password>" ["hostname"]=> string(9) "127.0.0.1" ["port"]=> string(3) "446" } I can instantiate the connection object using and query the database fine with: $conn = new \Zend\Db\Adapter\Adapter( ); // using Pdo=ibm:<relational_database_name> And here is the error Connect Error: SQLSTATE=42705, SQLConnect: -950 Relational database dbname=<rdn>;hos not in relational database directory. Any thought (about this topic) are greatly appreciated. Regards,
  8. Have you tried setting xhr.open( ) third argument to false? Since XMLHttpRequest default behavior is asynchronous, it may be that the larger file are taking to long to process. Setting XMLHttpRequest() to false (or synchronous) causes the save.php to completely run before the ready state changes, which in turn complete the request process. you'll also need to incorporate the readyState and Status in to your function. It would look something like: xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { console.log("done"); } }
  9. Yep this ultimately was the problem. A sub class (not SiteNavigation) was not properly getting instantiated due to a typo in an extended data class... VERY FRUSTRATING trying to track down bugs when they are three objects deep. What bubbles up isn't typically the correct problem. I was getting a path errors. Eventually (after a lot of trial and error) I created a test script to load each class individually. It was through that test script the typo was revealed... Thanks again.
  10. Thanks for the reply requinix! The way I called serialize() was incorrect - fixed that now - thanks! The service manager runs after all classes have been autoloaded and I've confirmed that I have valid objects at this point in the service manager process. Im expecting serialize() to recursively "serialize" each sub class. But when I pass $regObj through serialize(), only the parent RegistryClass is being serialized. error_log("RegistryClass Serialized: " . $RegClassSerial); // outputs C:13:”RegistryClass”:2:{N;} Here is the RegistryClass relevant code: class RegistryClass implements Serializable { private $data; private $regList = array(); /* instantiates the singleton, add sub classes to regList with set(), etc */ public function serialize() { return serialize($this->data); // where recursion is expected } public function unserialize($data) { $this->data = unserialize($data); } public function getData() { return $this->regList; } To test the theory that serialize() isn't recursively serializing each sub class, I've hacked a work around that does this manually. And here is that code: $regObj = RegistryClass::getInstance(); /* adds sub classes, see code in initial post */ $serial = serialize($regObj); /* * here's the hack to manually force serializing each sub class * by cloning the serialized string and appended the sub classes */ foreach($regObj->getData() as $obj) { if(is_a($obj, $className)) { $serial .= serialize($obj); } } $_SESSION['RegistryClass'] = $serial; The hack code produces a string that looks like: error_log("RegistryClass Sub Class Serialized: " . $serial); // RegistryClass Serialized: C:13:"RegistryClass":2:{N;}O:14:"SiteNavigation":2:{s:13:"... And finally, when the serial string from $_SESSION['RegistryClass'] is assigned and unserialized(), the parent class is picked up but not the subs. Again, no recursion. // module/view/Index.phtml $serialized = $_SESSION['RegistryClass']; // echo $serialized //C:13:”RegistryClass”:2:{N;}O:14:"SiteNavigation":2:{s:13:"*siteConfig";N;s:8:"*route";N;} $newObj = unserialize($serialized); print_r($newObj); /* * outputs * RegistryClass( * [data:RegistryClass:private] => * [regList:RegistryClass:private] => Array( ) * ) */ As you see from above, regList is empty. Where I'm expecting SiteNavigation. Thanks again for the feedback, I appreciate your insight.
  11. So I have a registry class that holds sub class instances. When the application loads a module, the registry class needs to make sub class functionality available to the module. There's an autoloader in place, I just need the class instances. A service manager should load the registry class with sub classes. Service manager RegistryClass has this prototype at the end of the process: // hash table of registry properties and classes // SiteNavigation example is one sub class RegistryClass Object( [data:RegistryClass:private] => [regList:RegistryClass:private] => Array ( [SiteNavigation] => SiteNavigation Object ( [siteConfig:protected] => [route:protected] => 
 ) ) ) There are several MVC scripts in the module that require different things. However, when the script (ie module controller) picks up the Registry object, it's hash table (regList) is empty. // empty table, empty belly RegistryClass Object ( [data:RegistryClass:private] => [regList:RegistryClass:private] => Array ( ) ) I've tried using the built in PHP interface Serializable however, it's producing incomplete PHP objects when I call unserialize() method. Called from a module script - that looks like: $newObj = unserialize($serialized); // Registry appears fine, however, SiteNavigation is incomplete RegistryClass Object ( [data:RegistryClass:private] => [regList:RegistryClass:private] => Array ( [SiteNavigation] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => SiteNavigation [siteConfig:protected] => [route:protected] => ) ) ) Here is a snip from the service manager which 1. instantiates a singleton registry class 2. instantiates the sub classes. $regObj = RegistryClass::getInstance(); // Singleton class holds instances of sub classes in hash table /* * set() method simply assigns sub class names as key and object instance as value to regList */ if(class_exists($className)) { $regObj->set($className, new $className); } /* * now serialize and assign to session, RegistryClass implements Serializable */ $_SESSION['RegistryClass'] = $regObj->serialize($regObj); It seems like the sub classes (ie SiteNavigation) doesn't serialize. Error log output only C:13:"RegistryClass":2:{N;}). Any thoughts are appreciated.
  12. In addition to QuickOldCar's answer, your markup is different then what Schema.org defines as a price object. Check out the http://schema.org/price Price description. Click on the Microdata tab for example markups. You may want: <span itemprop="priceCurrency" content="USD">$</span><span itemprop="price" content="1000.00">1,000.00</span> <link itemprop="availability" href="http://schema.org/InStock" />In stock
  13. It looks like you're using a framework and it has a helper method called groups_helper. Does the frameworks groups_helper have a method to do what you want? Also have you var_dumped the $user array? Does $user have some element that id's which group(s) they belong to? Example(pseudocode): //pseudocode $user = array( 'group_id' => array ( 'a_group' => 123, 'b_group' => 456, ), ) Since you're using some framework, you'll need to fully understand that frameworks methods in order to change your code above.
  14. Use the download attribute of <a> tag. <a href="<?php echo $link?>" download="<?php echo $filename?>">Download File</a>
  15. One thing is your Ternary operator. //change this $name = isset($_POST['name']) ? $_POST['name'] : ""; //to this $name = (isset($_POST['name'])) ? $_POST['name'] : ""; I wasn't able to see where you were passing PHP var to Javascript, however you can try this, it would be cleaner then trying to assign JQuery selector value. var name = <?php echo htmlspecialchars(json_encode($name), ENT_NOQUOTES); ?>;
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.