Unkown Column Error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Unkown Column Error

Post by Benjamin »

Here is the query..

Code: Select all

tep_db_query("insert into `" . TABLE_CUSTOMERS_INFO . "` (`customers_info_id`, `customers_info_number_of_logons`, `customers_info_date_account_created`) values ('" . (int)$customer_id . "', '0', now())");
Here is the error..
1054 - Unknown column 'cache_id' in 'field list'

insert into `customers_info` (`customers_info_id`, `customers_info_number_of_logons`, `customers_info_date_account_created`) values ('0', '0', now())

[TEP STOP]
Any clues? I was able to fix it by changing tep_db_query to mysql_query. Here is tep_db_query..

Code: Select all

function tep_db_query($query, $link = 'db_link') {
    global $$link;
    $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

    return $result;
  }
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

That is odd. The DB is returning an unknown column name for a column that is not even in your query? Is there perhaps a temp table that is being used that might have an insert into that field and perhaps that field is not in the table?
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

Everah wrote:That is odd.
That's exactly what I was thinking :D

The only thing I was able to come up with was that perhaps in some way the query we see is not the query being submitted, but the error message is just plain weird.

astions... do you have a column anywhere in your database called "cache_id"??
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I doubt there is a temp table. This is an osCommerce glitch I have fixed before. I believe the cache field is in another table and is used in a different query. It's a weird error for sure though.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

GM wrote:do you have a column anywhere in your database called "cache_id"??
Just checked, no there is not. I did try to add the field to the customers_info table a while back and that did not fix the problem. Changing the tep_db_query to mysql_query, without a link id, does fix it though.
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

Have you tried passing the link by reference?

Code: Select all

function tep_db_query($query, $link = 'db_link') { 
    global $$link; 
    $result = mysql_query($query, &$$link) or tep_db_error($query, mysql_errno(), mysql_error()); 

    return $result; 
  }
Does this change anything?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Store didn't like that to much..
<br />
<b>Warning</b>: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of mysql_query(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in <b>/var/www/vhosts/***/httpdocs/includes/functions/database.php</b> on line <b>46</b><br />
<br />
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

Ah dammit. Sorry about that - forgot that passing by reference at call-time was deprecated.

I was just wondering whether the instance of the connection was always the same, or whether somehow some other connection was being used.

Try hardcoding the name of the link?

I'm clutching at straws here... :?
Post Reply