Results 1 to 3 of 3

Thread: [RESOLVED] Classes and Arrays

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Resolved [RESOLVED] Classes and Arrays

    Hey,

    I have a class set up with some variables

    PHP Code:
    var $caption
        var 
    $default
        var 
    $xPos
    I create a new instance of this class and copy accross some POST variables which are in fact arrays.

    PHP Code:
     $newPrint->caption $_POST['caption'];
        
    $newPrint->default $_POST['default'];
        
    $newPrint->xpos  $_POST['xPos']; 
    I then try to use these arrays as bellow in a sql script

    PHP Code:
        '$this->caption[$i]',
        
    '$this->default[$i]',
        
    $this->xPos[$i], 
    However I get this output....

    PHP Code:
    VALUES 'Array[0]''Array[0]', [0], Array[0], 
    Which results in an error. Anyone spot anything obvious?

  2. #2
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    Re: Classes and Arrays

    PHP Code:
    "..'{$this->caption[$i]}', 
        '
    {$this->default[$i]}', 
        
    {$this->xPos[$i]},.." 
    Though in best practice it would be good to concatenate - At least that's what I do:
    PHP Code:
    "......'".$this->caption[$i]."',
    '"
    .$this->default[$i]."',
    "
    .$this->xPos[$i]."......" 
    With the context you've posted in that's all I can really suggest, sorry.
    Last edited by RudiVisser; Jun 13th, 2008 at 02:06 PM.
    » Twitter: @rudi_visser : Website: www.rudiv.se «

    If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Classes and Arrays

    Fixed the issue thanks once again Rudi.

    Pino

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width