SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Rules for naming fields
-
Jul 13, 2004, 15:50 #1
- Join Date
- Mar 2004
- Location
- Michigan
- Posts
- 77
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Rules for naming fields
Ok, I ran into some trouble at work today. I have a table with multiple fields for the same topic. For example, users can enter three URLs and they get inserted into three different fields url1, url2, url3. It did allow me to rename the fields to url[1], url[2], url[3] so that I can use them in a loop. However, I can't get the PHP to read the fields when they're named with brackets. I can read them in PuTTY if I enclose them in double quotes, but phpMyAdmin gives me errors that point to the brackets (I've tried both single and double quotes, I don't know if that matters). Is there a certain way I need to code it for it to work?
Thanks
-C
-
Jul 13, 2004, 16:30 #2
- Join Date
- Nov 2001
- Location
- Atlanta, GA, USA
- Posts
- 5,011
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You could try using aliases on the query.
SELECT url[1] as firstUrl FROM table;
However, those are some looney column names, if you ask me. I am thinking your rationale for using brackets in column names is spurious: just a guess. :-)
Or perhaps I've misunderstood your problem entirely.Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?
-
Jul 14, 2004, 05:25 #3
-
Jul 14, 2004, 09:39 #4
- Join Date
- Jun 2004
- Location
- London, UK
- Posts
- 227
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by daveman
or even better, learn a little bit about normalisation:
http://www.oreilly.com/catalog/javad...apter/ch02.pdf
The bit about 1NF is most relevant to this one.
But if you insist, why not just get rid of the [] and call them url01, url02 or something, at least that would work.
-
Jul 15, 2004, 16:17 #5
- Join Date
- Mar 2004
- Location
- Michigan
- Posts
- 77
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by daveman
-
Jul 15, 2004, 16:26 #6
- Join Date
- Mar 2004
- Location
- Michigan
- Posts
- 77
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by pointbeing
Can you still run through loops with brackets? Will it work to use something like "url" . $i instead of url[$i]?
Bookmarks