MySQL query doesnt work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

adamb10
Forum Commoner
Posts: 91
Joined: Sat Jun 24, 2006 7:44 pm

Post by adamb10 »

jamiel wrote:So there is only one row in the Settings Table?
Image[/img]
adamb10
Forum Commoner
Posts: 91
Joined: Sat Jun 24, 2006 7:44 pm

Post by adamb10 »

My brain caught up finally. :) I decided to start fresh and turn errors on. The errors pointed out that fields in the query dont even belong to that table. I made a new query and now it's fixed! :)

I still wonder if the where clause is useful though...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

A where clause is useful for any table that has more than one row (which most do). If you do not specify a where, then the entire table updates with the information passed to it.
adamb10
Forum Commoner
Posts: 91
Joined: Sat Jun 24, 2006 7:44 pm

Post by adamb10 »

I do use a where clause in scripts that have an id table but nothing else.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Not trying to take this too far off topic, but database table design best practices suggest that all tables have a primary key 'id' field of some sort. You may want to look into developing your tables with id fields. All of my tables have them in some capacity.
adamb10
Forum Commoner
Posts: 91
Joined: Sat Jun 24, 2006 7:44 pm

Post by adamb10 »

I only see a use for an id field when you need to put 2 seperate fields together. For a table storing settings though, I dont know how it can be of use.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

So the settings table you posted the image of above is only housing one row of data? What do the setting control?
adamb10
Forum Commoner
Posts: 91
Joined: Sat Jun 24, 2006 7:44 pm

Post by adamb10 »

Yes only 1 row. The settings include...

Guestbook title
Guestbook Logo
Table Width
Disable Posting
Disable BBCode
Disable Quick Post
Location of Quick Post
Turn off Menubar
Location of Menubar
Max comments to show per page
Links instead of images
Turn off IM Fields
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

Each setting should have an id and it's own row to make your table practical.

id,setting,value
adamb10
Forum Commoner
Posts: 91
Joined: Sat Jun 24, 2006 7:44 pm

Post by adamb10 »

Wait, so the setting wont store anything?

I'm confused.
Post Reply