First, thanks for taking the time to look at my problem.
Second, the problem...
I would like to store an array variable in a postgres table. How do I do that?
Here is what I'm trying to do....
<?
//define array...
$var = array("first_item", "second_item", "third_item", ..."nth_item") ;
//build query string...
$query = "INSERT INTO genric_tbl (username, items) VALUES ('$usr', '{$var}')" ;
?>
Note: the column "items" in the postgres table is defined as a one-dimensional array.
After executation I get this message:
Warning: PostgreSQL query failed: ERROR: array_in: Need to specify dimension in /html/www/temp.php on line 101
What does the warning mean? Why does the above code not work? I have tried:
'{'{$var}'}', '$var', '{\"$var\"}', "$var". Nothing seems to work.
I have also tried storing the array variable under columns as varchar and text, but with negative results. What am I doing wrong? Any help would be greatly appreciated. Thank you.
Second, the problem...
I would like to store an array variable in a postgres table. How do I do that?
Here is what I'm trying to do....
<?
//define array...
$var = array("first_item", "second_item", "third_item", ..."nth_item") ;
//build query string...
$query = "INSERT INTO genric_tbl (username, items) VALUES ('$usr', '{$var}')" ;
?>
Note: the column "items" in the postgres table is defined as a one-dimensional array.
After executation I get this message:
Warning: PostgreSQL query failed: ERROR: array_in: Need to specify dimension in /html/www/temp.php on line 101
What does the warning mean? Why does the above code not work? I have tried:
'{'{$var}'}', '$var', '{\"$var\"}', "$var". Nothing seems to work.
I have also tried storing the array variable under columns as varchar and text, but with negative results. What am I doing wrong? Any help would be greatly appreciated. Thank you.