Author Topic: Unknown column 'i.user_id' in 'on clause'  (Read 525259 times)

0 Members and 1 Guest are viewing this topic.

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
Unknown column 'i.user_id' in 'on clause'
« on: September 07, 2008, 01:39:52 PM »
This error occur when used 4images v1.7 / 1.7.1 (and/or some old mods) and MySQL v5.x
It caused by the changes in MySQL v5 handling multiple tables on one query.
If your 4images is newer then v1.7.1 and you still get these errors, then you must have installed a mod that is not MySQL v5 compatible.

There are three ways fix the problem:
1) Downgrade MySQL to v3 or v4
2) Upgrade your 4images
3) In .php files replace all
FROM table1 ref, table2 ref

with:
FROM (table1 ref, table2 ref)


There are quiet a few places needs to be fixed, so I'd recommend use a text editor which allows use unix regular expressions to search and modify files.

This REGEX string I've used in UltraEdit:
Code: [Select]
(FROM\s+)("\.[A-Z_]+\."\s+[a-z]+,\s*"\.[A-Z_]+\."\s+[a-z]+)and in replacing string used:
Code: [Select]
\1(\2)
it worked quiet well. That editor allows search and replace string in files without opening them in the editor, which would be the fastest way, however I'd strongly recommend do a complete backup of all .php files before you attempt doing it.

I corrected this problem by running a perl command from the shell in the 4images root dir, the \admin dir and the \includes dir:

Code: [Select]
perl -pi '-es/(FROM\s+)("\.[A-Z_]+\."\s+[a-z]+,\s*"\.[A-Z_]+\."\s+[a-z]+)/$1($2)/g' *.php
This might be useful for people without access to Ultraedit.
Remember to BACK UP everything before you try this!


If you don't have such editor or for any other reasons can't use that REGEX, prepare yourself for a long journey modifying almost all 4images files manually.
The list below is only for non-modified 4images v1.7 / 1.7.1 That means if after fixing all these files you still getting errors there are only two reasons:
1) you missed a modification
2) you've installed a mod that also not MySQL v5 compatible.

In any case you'll need find and fix the problem yourself.

Hopefully after looking at the list below you'll understand what has to be changed.

Good luck.

Find in categories.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in details.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in index.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in lightbox.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)


Find in member.php (4 times):
Code: [Select]
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." iReplace with:
Code: [Select]
FROM (".COMMENTS_TABLE." c, ".IMAGES_TABLE." i)

Find in postcards.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)


Find in postcards.php:
Code: [Select]
FROM ".POSTCARDS_TABLE." p, ".IMAGES_TABLE." iReplace with:
Code: [Select]
FROM (".POSTCARDS_TABLE." p, ".IMAGES_TABLE." i)


Find in search.php:
Code: [Select]
FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." mReplace with:
Code: [Select]
FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)

Find in search.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in top.php (4 times):
Code: [Select]
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)

Find in admin\comments.php:
Code: [Select]
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." iReplace with:
Code: [Select]
FROM (".COMMENTS_TABLE." c, ".IMAGES_TABLE." i)


Find in admin\home.php:
Code: [Select]
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." sReplace with:
Code: [Select]
FROM (".USERS_TABLE." u, ".SESSIONS_TABLE." s)

Find in admin\usergroups.php:
Code: [Select]
FROM ".GROUPS_TABLE." g, ".GROUP_MATCH_TABLE." gmReplace with:
Code: [Select]
FROM (".GROUPS_TABLE." g, ".GROUP_MATCH_TABLE." gm)

Find in includes\auth.php:
Code: [Select]
FROM ".GROUP_ACCESS_TABLE." a, ".GROUP_MATCH_TABLE." mReplace with:
Code: [Select]
FROM (".GROUP_ACCESS_TABLE." a, ".GROUP_MATCH_TABLE." m)


Find in includes\functions.php (2 times):
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in includes\sessions.php:
Code: [Select]
FROM ".USERS_TABLE." u, ".LIGHTBOXES_TABLE." lReplace with:
Code: [Select]
FROM (".USERS_TABLE." u, ".LIGHTBOXES_TABLE." l)
« Last Edit: August 20, 2009, 04:19:35 PM by V@no »
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 sanko86

  • Sr. Member
  • ****
  • Posts: 310
    • View Profile
    • Elemegim
Ynt: Unknown column 'i.user_id' in 'on clause'
« Reply #1 on: January 25, 2009, 01:27:16 PM »
thanks admin.
Web site:http://www.anlatiyoruz.com
Hayat zorluklarla doludur.Ama en zoru insanın insana düşmanlığıdır.

Offline nabeel

  • Banned for spam
  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: Unknown column 'i.user_id' in 'on clause'
« Reply #2 on: August 22, 2009, 10:19:11 AM »
very nice
my site: [removed. spam]

Offline wooody

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: Unknown column 'i.user_id' in 'on clause'
« Reply #3 on: October 24, 2011, 01:27:40 PM »
Hello,
i got 2 errors , any help.


An unexpected error occured. Please try again later.
Bad SQL Query: SELECT DISTINCT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name, u.user_name
            FROM (4images_images i,  4images_categories c)
            LEFT JOIN 4images_users u ON (u.user_id = i.user_id)
            WHERE i.image_active = 1 AND i.cat_id NOT IN (0) AND c.cat_id = i.cat_id
            ORDER BY i.image_downloads DESC LIMIT 1
Incorrect key file for table '/tmp/#sql_5169_3.MYI'; try to repair it


An unexpected error occured. Please try again later.
Bad SQL Query: SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name, u.user_name
        FROM (4images_images i,  4images_categories c)
        LEFT JOIN 4images_users u ON (u.user_id = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (0)
        ORDER BY RAND()
         LIMIT 28
Incorrect key file for table '/tmp/#sql_5169_2.MYI'; try to repair it


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/logopub/public_html/includes/db_mysql.php on line 116

Read more: http://www.logopub.net/#ixzz1bhJFSAgI

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
Re: Unknown column 'i.user_id' in 'on clause'
« Reply #4 on: October 24, 2011, 01:49:31 PM »
Hello.
For this you'll need contact your server's administrator, something wrong with the server.
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 wooody

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: Unknown column 'i.user_id' in 'on clause'
« Reply #5 on: October 24, 2011, 11:34:19 PM »
Hello.
For this you'll need contact your server's administrator, something wrong with the server.

Hello, I don't think from Server, i think for one of installed module.


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
Re: Unknown column 'i.user_id' in 'on clause'
« Reply #6 on: October 25, 2011, 01:29:48 AM »
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 jimraynor

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Unknown column 'i.user_id' in 'on clause'
« Reply #7 on: May 02, 2012, 02:25:47 PM »
Hello vano i dont understand this section

Quote
This REGEX string I've used in UltraEdit:

   

(FROM\s+)("\.[A-Z_]+\."\s+[a-z]+,\s*"\.[A-Z_]+\."\s+[a-z]+)

and in replacing string used:

   

\1(\2)

how can i do this? where is regex? is this a document in ftp? or php myadmin ?

Thank you.

Offline tabkon11

  • Pre-Newbie
  • Posts: 2
    • View Profile
    • گروه تحقیقاتی
Re: Unknown column 'i.user_id' in 'on clause'
« Reply #8 on: September 04, 2018, 02:30:53 AM »
<span id="result_box" class="short_text" lang="en" tabindex="-1">Good content was grateful</span>

<a href="https://ganjedaron.com">گروه تحقیقاتی</a>