PHP + ORACLE Database Select Statement, Help Me

Do you have questions regarding other database enginges (not MySQL) -- ask here!

Moderators: egami, macek, gesf

Post Reply
landi
php-forum Active User
php-forum Active User
Posts: 388
Joined: Thu Mar 15, 2012 3:59 pm

Sun Jun 12, 2016 5:13 am

Hi,
I don't understand your query, and the code you posted cannot produce the error you posted. However, it is worth noting that while mysql can use lowercase column names, with oracle you MUST use UPPERCASE to retrieve the column values from the row.
For example:

Code: Select all

// You can use lowercase for the column in the sql statement:
select 'foo' as city_name from dual;
But once you have the row, you MUST use uppercase.

Code: Select all

print $row['city_name'] // Fails with Notice: Undefined index: city_name in ...
print $row['CITY_NAME'] // Works, outputs 'foo'
If this is your first time with oracle and php, I suggest you try a very simple example, and post the results if it fails.

landi
php-forum Active User
php-forum Active User
Posts: 388
Joined: Thu Mar 15, 2012 3:59 pm

Mon Jun 13, 2016 3:17 am

Your query is too complex to review. Post an example of a query using just one table and one column. If that works, we can go from there. If it fails, we can try to fix it.

NigelRen
php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Fri Aug 05, 2011 9:53 am

Mon Jun 13, 2016 7:32 am

Should the line...

Code: Select all

echo "".$results ['CITY'][$i]."";
Be

Code: Select all

echo "".$results ['CITY_NAME'][$i]."";
Also - married_statusr probably should be married_status.

You can simplify your group by to...

Code: Select all

group by a.no_city,a.no_region
But probably order by...

Code: Select all

order by getnamecity(a.no_city,a.no_region)
to get in alphabetical order (If that's what you want).

Post Reply