|
-
Jun 13th, 2008, 12:17 PM
#1
Thread Starter
PowerPoster
[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?
-
Jun 13th, 2008, 02:01 PM
#2
Hyperactive Member
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.
-
Jun 13th, 2008, 02:08 PM
#3
Thread Starter
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|