Author Topic: Column: 'user_id' in where clause is ambiguous  (Read 9784 times)

0 Members and 1 Guest are viewing this topic.

Offline Xwall

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.xwall.tk
Column: 'user_id' in where clause is ambiguous
« on: April 04, 2003, 12:23:31 PM »
I have this error in this type of url.
xwall.metropoliglobal.com/galerias/details.php?image_id=5318&mode=search   :?

DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.image_name, i.image_media_file, i.image_thumb_file, i.user_id FROM galerias_images i LEFT JOIN galerias_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND user_id IN (2461) AND i.cat_id IN (0, 15, 34, 121, 61, 56, 14, 145, 40, 133, 28, 3, 72, 4, 99, 47, 59, 50, 91, 74, 16, 35, 131, 101, 65, 134, 146, 51, 100, 5, 2, 41, 48, 75, 29, 62, 92, 57, 122, 102, 30, 36, 33, 63, 93, 58, 135, 6, 147, 76, 17, 144, 52, 42, 132, 94, 103, 31, 71, 79, 7, 18, 43, 77, 78, 37, 140, 148, 53, 113, 104, 80, 55, 90, 95, 8, 19, 32, 54, 137, 149, 81, 114, 105, 67, 96, 9, 20, 38, 150, 138, 123, 106, 70, 10, 82, 97, 139, 21, 130, 11, 107, 68, 83, 141, 23, 124, 12, 66, 84, 25, 118, 26, 13, 69, 109, 85, 112, 119, 44, 24, 110, 86, 87, 1, 126, 27, 111, 88, 115, 39, 120, 98, 60, 117, 89, 49, 128, 142, 127, 125, 116, 129) ORDER BY image_date DESC
Column: 'user_id' in where clause is ambiguous

Column: 'user_id' in where clause is ambiguous  :?:   :?:  :?:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Column: 'user_id' in where clause is ambiguous
« Reply #1 on: April 04, 2003, 07:01:04 PM »
please tell us more details what did u do.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Xwall

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.xwall.tk
Column: 'user_id' in where clause is ambiguous
« Reply #2 on: April 04, 2003, 07:36:54 PM »
In profile section When i click in (Display all images added by xxx).
In the results of the search, when i click in some picture i have a DB error.


DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.image_name, i.image_media_file, i.image_thumb_file, i.user_id FROM galerias_images i LEFT JOIN galerias_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND user_id IN (1) AND i.cat_id IN (0, 15, 34, 121, 61, 56, 14, 145, 40, 133, 28, 3, 72, 4, 99, 47, 59, 50, 91, 74, 16, 35, 131, 101, 65, 134, 146, 51, 100, 5, 2, 41, 48, 75, 29, 62, 92, 57, 122, 102, 30, 36, 33, 63, 93, 58, 135, 6, 147, 76, 17, 144, 52, 42, 132, 94, 103, 31, 71, 79, 7, 18, 43, 77, 78, 37, 140, 148, 53, 113, 104, 80, 55, 90, 95, 8, 19, 32, 54, 137, 149, 81, 114, 105, 67, 96, 9, 20, 38, 150, 138, 123, 106, 70, 10, 82, 97, 139, 21, 130, 11, 107, 68, 83, 141, 23, 124, 12, 66, 84, 25, 118, 26, 13, 69, 109, 85, 112, 119, 44, 24, 110, 86, 87, 1, 126, 27, 111, 88, 115, 39, 120, 98, 60, 117, 89, 49, 128, 142, 127, 125, 116, 129) ORDER BY image_hits ASC
Column: 'user_id' in where clause is ambiguous

I see the error and the picture.  :(

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Column: 'user_id' in where clause is ambiguous
« Reply #3 on: April 06, 2003, 03:52:16 PM »
I'm not quet sure what did u do to details.php, but there I can see some changes there, that cause the error messages. (btw, it will show u not only when u click "show all images by user", but also, when just search something.
in your index.php look for:
Code: [Select]
elseif ($mode == "search") {
  if (!isset($session_info['searchid']) || empty($session_info['searchid'])) {
    $session_info['search_id'] = $site_sess->get_session_var("search_id");
  }

  if (!empty($session_info['search_id'])) {
    $search_id = unserialize($session_info['search_id']);
  }

  $sql_where_query = "";

  if (!empty($search_id['image_ids'])) {
    $sql_where_query .= "AND image_id IN (".$search_id['image_ids'].") ";
  }

  if (!empty($search_id['user_ids'])) {
    $sql_where_query .= "AND user_id IN (".$search_id['user_ids'].") ";
  }

  if (!empty($search_id['search_new_images']) && $search_id['search_new_images'] == 1) {
    $new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
    $sql_where_query .= "AND image_date >= $new_cutoff ";
  }

change those lines:
   $sql_where_query .= "AND i.image_id IN (".$search_id
    $sql_where_query .= "AND i.user_id IN (".$search_id['user_ids'].") ";
    $sql_where_query .= "AND i.image_date >= $new_cutoff ";


Hope this is it ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Xwall

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.xwall.tk
Column: 'user_id' in where clause is ambiguous
« Reply #4 on: April 06, 2003, 04:25:14 PM »
Solved problem, thank you very much     :D