Jump to content

crazyone

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Posts posted by crazyone

  1. If T1 to T21 is the only thing you have in your array then do the following:

     

    $trades  = implode(',', $_POST);

     

    Else you could extract those values by walking the array and taking the values if they start with T. For example:

     

    $ExtractedResults = array();
    function GetTFields(&$item1, $key){
    global $ExtractedResults;
    if(substr($key, 0, 1) == 'T' && is_numeric(substr($key, 1)) && (int)(substr($key, 1)) >= 1 && (int)(substr($key, 1)) <= 21){
    $ExtractedResults[$key] = $item1;
    }
    }
    array_walk($_POST, 'GetTFields');
    $trades  = implode(',', $ExtractedResults);

     

    Cheers

  2. For all to know

    My previous question was in fact a real PHP bug. This bug is linux AND windows, the problem is caused when you have the

    zend.ze1_compatibility_mode = On

    in the php.ini file. This is a bug that was reported before several times without having been resolved. I commented and reactiveated the bug on the php bug submission engine...

    Math
  3. [!--quoteo(post=388939:date=Jun 28 2006, 02:43 PM:name=Buyocat)--][div class=\'quotetop\']QUOTE(Buyocat @ Jun 28 2006, 02:43 PM) [snapback]388939[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Could it be because you're using vardump? Or was this happening before you tried vardump? Also there are several very robust PEAR packages that handle DB abstraction and I strongly suggest you use one of them unless this is a learning experience for you. There really isn't any reason to reinvent the wheel.
    [/quote]

    Nope, it happens on several levels, not just this one, if i put a $this->connect() in my server connection class it also loses my link resource...

    And don't worry, i'm not reinventing the wheel, i am doing a complete data definition language abstraction layer that doesn't already exist on PEAR. Or else i didn't look correctly last time i went there. Overall i can't find any php5 compatible DDL and DML abstraction library.

    Back to my problem, what i don't understand is why the __destruct is being called for nothing, i'll try some other tests, can you keep me updated on stuff you try thnks
  4. Hi, this is pretty simple and i'm actually going to give you a real push to form management in PHP.

    At the top of the PHP file you could write this:

    [code]<?php
    if($_SERVER['REQUEST_METHOD'] == 'POST'){
      if(isset($_POST['textfield']) && strlen($_POST['textfield']) > 0){
        echo $_POST['textfield'];
      }else{
        echo 'No textfield value submitted';
      }
    }elseif($_SERVER['REQUEST_METHOD'] == 'GEST'){
      $_POST['textfield'] = '';
    }
    ?>[/code]
  5. I created a set of class to manage mysql server structure and part of this has two classes used for query and result management. I got a problem storing the result in one of my classes because of the following :

    It seems PHP is calling the constructor (__construct) then immediatly calling the destructor for no apparent reason... (__destruct). Because of that i can't pass my resource to my constructor because the destructor called immedialty after destroys it. This either forces me to set the result AFTER the creation of the object which is not normal IMO.

    Is this a normal behavior of PHP5, a bug in the windows binary? I'm running PHP 5.1.2 on a windows 2003 server (Which i doubt is a problem in this case)

    Here is some code

    [code]======================================================
    QUERY FUNCTION
    ======================================================

    public function query($sql, $buffered = true){
    if($this->p_mylink){
      //execute the query and look for an exception
      if($buffered == true){
       $res = mysql_query($sql, $this->p_mylink);
      }else{
       $res = mysql_unbuffered_query($sql, $this->p_mylink);
      }
      if(is_resource($res)){    //Result returned
       $mddl_result = new myDDLResult($res);
       echo 'Completed creation<br><pre>';
       var_dump($mddl_result);
       echo '</pre><br>';
       return $mddl_result;    //Create a result object and return it
      }elseif($res === true){    //Command executed succesfully
       return new myDDLResult();    //Create a result object and return it
      }elseif($res === false){    //Can only mean an error occured
       return $this->getError();    //Create a result object and return it
      }else{    //Impossible case but we'll warn the user
       throw new myDDLException('query failed to compare mysql_query type');
      }
    }
    throw new myDDLInvalidOperationException('Not connected to server');
    }

    =========================================================
    RESULT CLASS
    =========================================================

    //Class in charge of interfacing a result
    final class myDDLResult {
        //Local vars
        private $p_myresult;

        //Constructor / destructor
        public function __construct($result = NULL){
            //Store
            echo 'Creating';
            echo '<br>';
            var_dump($result);
            echo '<br>';
            $this->p_myresult = $result;
        }
        public function __destruct(){
            echo 'Destroying';
            echo '<br>';
            var_dump($this->p_myresult);
            echo '<br>';
            mysql_free_result($this->p_myresult);
        }
    }

    ====================================================
    OUTPUT
    ====================================================
    Creating
    resource(3) of type (mysql result)
    Destroying
    resource(3) of type (mysql result)
    Completed creation

    object(myDDLResult)#1 (1) {
      ["p_myresult:private"]=>
      resource(3) of type (Unknown)
    }
    Destroyingresource(3) of type (Unknown)

    Warning:  mysql_free_result(): 3 is not a valid MySQL result resource in C:\Source\palliscience\maj.palliscience.com\dev\lib_myddl.php on line 200


    Destroying
    resource(3) of type (Unknown)

    Warning: mysql_free_result(): 3 is not a valid MySQL result resource in C:\Source\palliscience\maj.palliscience.com\dev\lib_myddl.php on line 200
    Destroying
    resource(3) of type (Unknown)

    Warning: mysql_free_result(): 3 is not a valid MySQL result resource in C:\Source\palliscience\maj.palliscience.com\dev\lib_myddl.php on line 200
    Destroying
    resource(3) of type (Unknown) [/code]
×
×
  • 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.