GetDotted Domains

Viewing Thread:
"Passing array variables to a database"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Sat 12/02/05 at 17:38
Regular
Posts: 10,364
Hi there.

Here's the deal.

Got an array called "images".

After attempting to put the values into the database (i.e. $this->images[$i] with $i being a counter in a for loop)

All I get within my database is instead of the array value itself, I just get

"Array[0]"
"Array[1]"

etc

How do I get it to insert the proper values of the array, for example, if array[0] had "cheese" as it's value, then I would want "cheese" to be put into the database when Array[0] was called.
Sat 12/02/05 at 21:02
Regular
Posts: 10,364
Cheers Nimco, that sorted it!
Sat 12/02/05 at 18:51
Regular
"NULL"
Posts: 1,384
Change the line:

$sql="INSERT INTO Images VALUES('','$this->AID', '$this->image[$i]')";

to:

$sql="INSERT INTO Images VALUES('','".$this->AID."', '".$this->image[$i]."');";

and see if it works then.
Sat 12/02/05 at 18:48
Regular
Posts: 10,364
if($this->imgchecked==1) {
for($i=0; $i<=2;$i++) {
$sql="INSERT INTO Images VALUES('','$this->AID', '$this->image[$i]')";
echo $this->image[$i]."
"; //Just print the values to see if they are there
if(!$result = mysql_query($sql)) {
echo("

Error: " .
mysql_error() . "

");

}
else {
unset($sql);
unset($result);

}

}


}


Any guesses?

The results that are returned in the database are just

ImadeID=# (auto incremented number)
AID=(secondary key)
ImageURL="Array[0]"


ImadeID=# (auto incremented number)
AID=(secondary key)
ImageURL="Array[1]"


ImadeID=# (auto incremented number)
AID=(secondary key)
ImageURL="Array[2]"

Yet when echoing the contents of $this->image[$i] it returns the results perfectly so there is nothing wrong with the array in itself!

Any ideas?
Sat 12/02/05 at 18:05
Regular
"Devil in disguise"
Posts: 3,151
You shouldn't have any problems doing it, show us your code please.
Sat 12/02/05 at 17:38
Regular
Posts: 10,364
Hi there.

Here's the deal.

Got an array called "images".

After attempting to put the values into the database (i.e. $this->images[$i] with $i being a counter in a for loop)

All I get within my database is instead of the array value itself, I just get

"Array[0]"
"Array[1]"

etc

How do I get it to insert the proper values of the array, for example, if array[0] had "cheese" as it's value, then I would want "cheese" to be put into the database when Array[0] was called.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Excellent
Excellent communication, polite and courteous staff - I was dealt with professionally. 10/10
Second to none...
So far the services you provide are second to none. Keep up the good work.
Andy

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.