FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » ODBC Connection
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: ODBC Connection [message #172743 is a reply to message #172739] Sun, 27 February 2011 19:51 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 2/27/2011 2:19 PM, richard wrote:
> On Sun, 27 Feb 2011 10:49:26 -0800 (PST), bruceaj wrote:
>
>> On Feb 27, 1:36 pm, richard<mem...@newsguy.com> wrote:
>>> On Sun, 27 Feb 2011 09:57:11 -0800 (PST), bruceaj wrote:
>>>> I am connecting to an MS Access database. The connection and exec work
>>>> fine. My problem is getting the data.
>>>
>>>> The following two statement work;
>>>> $row = odbc_fetch_array($rs);
>>>> $value = $row['Newspaper'];
>>>
>>>> If I change to
>>>> $value = $row[1];
>>>
>>>> is_null($value) returns true.
>>>
>>>> What am I doing wrong or is an idiosyncrasy of using MS Access?
>>>
>>>> Bruce
>>>
>>> I'd say it's due to the fact you did not define $row[1].
>>> Instead, you used 'newspaper' as the row identifier.
>>> It can't find [1] so it reports an error.
>>
>> Okay??? I guess I don't know what I thought I knew!!
>>
>> Doesn't "odbc_fetch_array" returns an associative array. If so, can't
>> I address the elements either by name "newspaper" or by index "1".
>>
>> One minor point, the index I should be using is "0" since the
>> associative array is 0 based.
>>
>> Appreciate some suggestions on what I need to address the elements of
>> my array, $row, via an index value.
>>
>> Thanks again...
>>
>> Bruce
>
> as I understand it, the array contents have to be defined.
> If you define an array with names rather than number, then you can not
> assume 0 is going to be the first array item. Or that 0 will be associated
> with the first item by default.
>
> $item[0]="aaa"
> $item[1]="bbb"
> $item['sample']="ccc"
> $item['data']="data"
> $item[2]="ddd"
>
> If I wanted to recall the third item in the array, I would have to use
> ['sample'] not [2].
> If [2] did not exist, I can not assume [2] would equate to ['sample'].
>
> IOW, what you defined in the array, is what can be recalled.

Richard, odbc_fetch_array() IS defining the array. Just not the way he
expects.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: static vs global variable
Next Topic: SOCIAL NETWORK FOR PHP PLATFORM..
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 19:01:12 GMT 2024

Total time taken to generate the page: 0.05801 seconds