Jump to content

vurentjie

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

vurentjie's Achievements

Member

Member (2/5)

0

Reputation

  1. well i ended up just sticking to the follwing...works fine...
  2. hi just a quick question, some code for what I am trying... further up ..... self::$_menus['test'] = array(); self::loadLinks($links,'test'); public static function loadLinks($links){ $linkmark = false; $where = array_slice( func_get_args(), 1 ); foreach($where as $resource){ $linkmark=($linkmark===false)?self::$_menus[$resource]:$linkmark[$resource]; } $linkmark['newlink']='testinglink'; var_dump($linkmark); var_dump(self::$_menus); } it seems the menu array is not being passed by reference, if I convert all static class vars and use &$this->.... I can reference properly.... $this->_menus['test'] = array(); $this->loadLinks($links,'test'); public function loadLinks($links){ $linkmark = false; $where = array_slice( func_get_args(), 1 ); foreach($where as $resource){ $linkmark=($linkmark===false)?&$this->_menus[$resource]:&$linkmark[$resource]; } $linkmark['newlink']='testinglink'; var_dump($linkmark); var_dump($this->_menus); } I thought php5 would handle this as reference? Can anyone give me a why?
  3. hi, i am fiddling with the php reflection classes today, i was wondering what the first argument to method->invoke would do... class Greet{ final public static function saystuff($hi,$bye){ return $hi." and ".$bye; } } $method = new ReflectionMethod('Greet','saystuff'); echo $method->invoke(NULL,"hallo","tchuss"); echo $method->invoke('anythinggoes',"hallo","tchuss"); ? ...EDIT...nevermind I just figured it out - it has to do with calling static method or non-static method, class Greet{ public function saystuff($hi,$bye){ return $hi." and ".$bye; } } $greeting = new Gree(); $method = new ReflectionMethod('Greet','saystuff'); echo $method->invoke(NULL,"hallo","tchuss"); //exception echo $method->invoke($greeting,"hallo","tchuss"); //will work
  4. already have error_reporting on...one of the first things I set when developing... Actually instead of rands. But yes that is gonna be the fix I reckon...it is definitely a precision error. Such a simple solution - wish I had thought of that... Will check in later...
  5. hi, i have a calculation that checks for minor cent precision differences across a number of payments. there is a monthly allowance and payments are distributed according to a pro-rata calculation and should add up to the monthly allowance... sometimes it is out by a cent or fraction of a cent so i thought i could check the difference between the allowance and the total that has been paid, //basic calc $diff = $allowance - $total_paid; if($diff >0).... if($diff <0)... the actual arithmetic is simple enough but i am getting precision errors if i echo it out i can get the following any advice? i calculate the total_paid in a loop loop start $total_paid += $payment; //$payment does NOT get rounded either loop end the allowance is a figure a get from the database i cast this value to float before using it, but it is only there for checking against really. i only round figures after all calculations and only for display with php's number_format.
  6. i found my problem solved
  7. hi, i am having a problem with some xml i am retrieving from another site, and i just dont know how to extract the data this is what the print of the xml looks like SimpleXMLElement Object ( [@attributes] => Array ( [version] => 1.0 ) [header] => SimpleXMLElement Object ( ) [data] => SimpleXMLElement Object ( [string] => Complete0Complete3ca5f1ae-1c91-41f3-be49-063bf2be2d7908/11/2008 2:10:05 AM GMT1234567892testseller2@setcom.comCID: 2 - vurentjie@gmail.com - etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc etc ) ) basically i am stuck as all the data is coming back as one long string that i cannot separate into individual objects, i was expecting something more like SimpleXMLElement Object ( [info] => SimpleXMLElement Object ( [status] => Complete ) [from] => Jani [Address] => 10 Essen Rd [Product] => Chips ) which i could extract quite easily, is there a problem with how i am retrieving the data?? I have tried both SimpleXMLElement and simplexml_load_string; Funnily if i echo the xml return before loading it with one of the above functions it returns as regular xml starting like this... <?xml version='1.0' encoding='UTF-8'?><order_synchro><outcome><status>Complete</status><error_code>0</error_code><error_desc>Complete</error_desc><error_solution/><order> etc stumped.
  8. thanks, speedy response.
  9. hi, sorry was away for a while from these forums. basically your best bet if you want to manipuate combo boxes with php is to look at the following code snippet and learn something perhaps, not the most difficult but could get you started $comparr[0]="Trade in firearms"; $comparr[1]="Manufacture firearms"; $comparr[2]="Conduct Business as a gunsmith"; $comparr[3]="Possess a firearm"; $compopt = "<option value=''> </option>"; for($ee = 0; $ee <=3; $ee++) { if($comparr[$ee] == $row['type']) { $compopt .= "<option selected='yes' value='".$comparr[$ee]."'>".$comparr[$ee]."</option>"; } else { $compopt .= "<option value='".$comparr[$ee]."'>".$comparr[$ee]."</option>"; } } in this example what gets played on is whether a mysql search result is the same as any predefined select items and if so it automatically gets selected. but actually javascript is the best way to do this stuff
  10. hi, i just looked at the docs for the zlib module,in install instructs it says I looked through php.ini and find at first glance ;output_handler = //with options ob_gzhandler" or "zlib.output_compression zlib.output_compression = Off ;zlib.output_handler = extension=php_zlib_filter.dll //which i enabled?? These settings I am sure I could figure out with a bit of fiddling and reading. But mainly need a tip as to where does the above quote come into play? ie --with-zlib[=DIR] Not too sure about this. Any help appreciated.
  11. never mind i did fix it, it had nothing to do with the hidden fields not being sent, actually had to do wit one of my conditionals for updating, basically one of my check params was if <input type='submit' name='save'/> was being submitted before updating, however i had change this to <input type='button' name='save' /> so now it wasnt posting the name, so i add that name as a hidden field and hey presto!
  12. ok after running some tests, the input fields get submitted, however the hidden fields do not, hmmm,gonna go check that out
  13. hi, i have a form on a page was well as a button panel that scrolls along with the form, as it is really long, i am having a bit of a problem submitting the form, i dont think the hidden fields are being passed through, what happens is the button gets clicked and i fire a document.form.submit(), from here php takes over and (is supposed to ) collect the information; the method of the form is post-so this might be one of the problems. what i have tried is document.form.action='?id=98574395375394&place="+seven+"' but this means i need to use get method, now I am attempting to set the hidden fields in the form, athough i dont think this is going to help as they are already set to the correct values, this is my first time trying to submit form with javascript, so any advice or pointers appreciated?
  14. try this, only going to do it for textarea <div id='txterr' style='display:none;'>this textarea must be filled</div> <form> <textarea onchange='check(this.form.mytxt,'txterr');' name='mytxt'></textarea> </form> //js function check(where,what){ var err = document.getElementById(what); if(where.value == ""){ err.style.display = 'block'; } else { err.style.display = 'none'; } }
  15. if i am not mistaken, this is not possible, as php gets processed first,then javascript, i might be wrong
×
×
  • 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.