Re: Undefined Index ...confusion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Miller, Terion wrote:
> I keep getting this error while trying to use the field 'ID' to pass in a url.. And it's odd because the query is pulling everything BUT the ID which is the first field...
> 
> code:
> <a href="view.php?ID=<?php echo $_SESSION['fullRestaurantList']['ID']?>"><?php echo htmlspecialchars(stripslashes($_SESSION['fullRestaurantList'][$i]['name'])); ?>

What's the query?

I find (I use PostgreSQL rather than the mySQL that many on this list use) that
unless you explicitly ask for a field called ID (using  SELECT "ID" ... ) you
get a returned field in lower case
So
$resource = pg_query("SELECT ID, Foo FROM MyTable WHERE Foo='Bar'");
$data = pg_fetch_all($resource)

gives me an array $data of rows like
$data[0]['id'] = '1'
$data[0]['foo'] = 'Bar'

To make sure $data[] has fields named ID and Foo I would have to do

$resource = pg_query("SELECT ID AS \"ID\", Foo AS \"Foo\" FROM MyTable WHERE
Foo='Bar'");


-- 
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux