PDA

View Full Version : Location Field vB Code Problem


UserName
Thu 15th Jun '00, 6:02am
I am trying to integrate the latest release of vB with a membership system on my site. We are sharing the database between the two applications. I am not writing the code myself, but I am troubleshooting and I just found some trouble. We added a "location" field to the "user" table, along with several other fields. Well, it appears that there is a "location" field in the "session" table and this is causing the system to die. Here is the error message that was sent to me when I tried to open the vBulletin after adding the location field:

---------
Database error in vBulletin: Invalid SQL: SELECT DISTINCT user.userid,username,location FROM user,session WHERE session.userid=user.userid AND session.userid<>0 AND invisible=0 ORDER BY username
mysql error: Column: 'location' in field list is ambiguous
mysql error number: 1052
Date: Thursday 15th of June 2000 01:29:26 PM
Script: /vbulletin/index.php
Referer: http://forum.myname.com/vbulletin/admin/index.php?action=head
---------

An obvious solution would be to go through our code and change the field name to something like "location2" - but, there is a substantial amount of code, which has been worked on by several developers, and I have some hesitation about trying to make the changes in that way. I am wondering if this is a problems that should occur or if it's something that is simply a bug and that will be worked out of the vBulletin code. Hopefully it's something that I can easily remedy, but I am still learning PHP and I am not sure what the ramifications are or where else in the code I might run into the same problems.

Any thoughts on this situation and how to handle it would be appreciated. Thanks and take care!

UserName
Thu 15th Jun '00, 6:50am
Ok. I got out my trusty MySQL book and determined that the solution is to go through the vBulletin code and change the select statement (I have only found the one occurance so far) to make it specify which table "location" belongs to by simply changing:

"SELECT DISTINCT user.userid,username,location"
to:
"SELECT DISTINCT user.userid,username,session.location"

The problem will return when I go to upgrade - I need to make sure I remember to re-make any of the changes. I wonder if it might be better if John were to specify each table for each field in each select statement where there are multiple tables involved, so that those of us wanting to add the (much requested) "location" field to the "user" table could do it without worry. Again, I am still learning all of this, so feel free to beat me if what I'm suggesting is ridiculous!

John
Thu 15th Jun '00, 7:12am
That is the correct fix. I'll add in that code now for you.

John

UserName
Thu 15th Jun '00, 10:02am
I can't believe I got it right! :)