Page 1 of 1

Unkown Column Error

Posted: Mon Jul 31, 2006 9:29 am
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;
  }

Posted: Mon Jul 31, 2006 10:03 am
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?

Posted: Mon Jul 31, 2006 10:11 am
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"??

Posted: Mon Jul 31, 2006 10:12 am
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.

Posted: Mon Jul 31, 2006 10:19 am
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.

Posted: Mon Jul 31, 2006 10:23 am
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?

Posted: Mon Jul 31, 2006 10:34 am
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 />

Posted: Mon Jul 31, 2006 10:47 am
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... :?