Post by asif » Sat Apr 26, 2008 7:41 pm

i m using 0.7.7 version. it was workin fine on my local pc with mysql "Server version: 5.0.45-community-nt" and php 5. same specs r on the remote server where i uploaded but it is giving me many errors on different pages. the one it gives when i try to create account. the error is given below...
Error: Field 'cart' doesn't have a default value
Error No: 1364
insert into customer set firstname = 'asif', lastname = 'Mahmood', email = 'asif.m_1201084877_per@gmail.com', telephone = '333', fax = '', password = '81dc9bdb52d04dc20036dbd8313ed055', newsletter = '0', status = '1', date_added = now()

i didnt change any code. i checked the file "account_create.php" in controller and it doesn't hav $cart variable included when inserting in customer table. logically there must be cart variable in query but its working fine when running on local machine. It gives above error when execute on server.MySql version is same.
please help me...its urgent...

New member

Posts

Joined
Wed Jan 16, 2008 10:35 pm

Post by bruce » Sat Apr 26, 2008 10:12 pm

I have seen this on the forums before and agree that the code should not work because cart in the customer table is declared as not null and the insert statement does not provide a value. However, on my windows installation of xampp, this doesn't seem to matter. I suspect that there is a config option in the mysql or even php config files that can turn this "feature" on and off.

What I suggest is that you either change the code in account_create.php
to the following:

Code: Select all

    	if (($request->isPost()) && ($this->validate())) {
      		$sql = "insert into customer set firstname = '?', lastname = '?', email = '?', telephone = '?', fax = '?', password = '?', newsletter = '?', status = '1', date_added = now(), cart='' ";
      		$database->query($database->parse($sql, $request->get('firstname', 'post'), $request->get('lastname', 'post'), $request->get('email', 'post'), $request->get('telephone', 'post'), $request->get('fax', 'post'), md5($request->get('password', 'post')), $request->get('newsletter', 'post')));
which would give you the following sql, based on your example

Code: Select all

insert into customer set firstname = 'asif', lastname = 'Mahmood', email = 'asif.m_1201084877_per@gmail.com', telephone = '333', fax = '', password = '81dc9bdb52d04dc20036dbd8313ed055', newsletter = '0', status = '1', date_added = now(), cart=''
and no error

OR, and probably better, just change the cart field of the table customer to allow nulls

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by asif » Mon Apr 28, 2008 2:58 am

ok i changed it in the DB. i m facing many other like these errors on category, option and option_value pages at admin site. if it depends on any switch in Php or mysql config then please please let me know....which can fix them all...or i have to ask the hosting provider to setup XAMPP for my hostng... askin hosting provider is difficult n money consuming :(

New member

Posts

Joined
Wed Jan 16, 2008 10:35 pm

Post by bruce » Mon Apr 28, 2008 8:43 am

Hi asif,

Please keep posting the errors as it is a chance to review the sql and database design so that it can be fixed for everyone.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by asif » Wed Apr 30, 2008 12:28 am

i dont know abt the whole indepth DB architecture of opencart so these changes always pinchin my head. same kinda problem was found in option,option_value,order_status.php in controller folder of admin side.
i made follwoing changes in option.php and will make the similar changes in other. please tell me can it cause any bad thingy????

Code: Select all

foreach ($request->get('language', 'post') as $key => $value) {
			        		//$sql = "insert into `option` set option_id = '?', language_id = '?', name = '?'";
					//$database->query($database->parse($sql, $insert_id, $key, $value['name']));

				if($insert_id){
					$sql = "insert into `option` set option_id = '?', language_id = '?', name = '?'";
					$database->query($database->parse($sql, $insert_id, $key, $value['name']));
				}
				else {
					$sql = "insert into `option` set language_id = '?', name = '?'";
					$database->query($database->parse($sql, $key, $value['name']));
				}	
        		

        		$insert_id = $database->getLastId();
      		}
commented code above is the original code...i can't get why we inserting the previous "option_id" creeated by MySQL in the next entry for next language.... i think its to hav the same ID of this option for all the languages...
pls help me n explain so that i can change the remaining pages the same way....
Last edited by asif on Wed Apr 30, 2008 2:09 pm, edited 1 time in total.

New member

Posts

Joined
Wed Jan 16, 2008 10:35 pm

Post by pdbs » Thu May 08, 2008 4:44 am

I will try to insert these changes in my code on a LAMP server.

If I can successfully get things to work I will offer my server for hosting of the  'OpenCart' solution. This will be for anyone that has issues with the ISP provider.  At this point my system seems to work 'OK'. I have not tryed any extended pay or extra feature yet. I am still trying to understand these different code changes posted here.

New member

Posts

Joined
Thu May 08, 2008 2:56 am

Post by asif » Thu May 08, 2008 2:45 pm

do these changes if u r getting any problem on these pages otherwise don't insert these changes in ur code... it is due to different servers...

New member

Posts

Joined
Wed Jan 16, 2008 10:35 pm

Post by bruce » Thu May 08, 2008 6:27 pm

Hi asif.

Actually, I would recommend making the changes anyway.

I have added them to my installations because what you have done is perfectly correct and will work everywhere. A lot of the sql in OpenCart seems to be taking advantage of "bugs" in MySql.

Your interpretation of the code is correct also. The option id for a particular option is supposed to be the same for all languages.

Just out of interest, I did it as follows. I think it is clearer what is happening with $insert_id and also, for trivial benefit, eliminated redundant database calls to getLastId for each subsequent language.

Code: Select all

        if (($request->isPost()) && ($this->validateForm())) 
        {
            //
            //  Changes inspired by asif
            //
            $insert_id = 0;
            foreach ($request->get('language', 'post') as $key => $value) 
            {
                if ($insert_id == 0)
                {
                    $sql = "insert into `option` set language_id = '?', name = '?'";
                    $database->query($database->parse($sql, $key, $value['name']));
                    $insert_id = $database->getLastId();
                }
                else
                {
                    $sql = "insert into `option` set option_id = '?', language_id = '?', name = '?'";
                    $database->query($database->parse($sql, $insert_id, $key, $value['name']));
                }
            }      	  	
            $session->set('message', $language->get('text_message'));		  
            $response->redirect($url->ssl('option'));
        }
Last edited by bruce on Thu May 08, 2008 6:46 pm, edited 1 time in total.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by asif » Fri May 09, 2008 12:13 am

yeh bruce thats better way to do it...i hav found another error of this kind in process function of Cart class, but it only occurs when u don't enable tax options...i'll post that in detail..
but right now i m unable to send emails through open cart, it doesnt gives any error but mails r not delivered...send mail is enable by my hosting provider...is there any other client must be installed on the hosting machine...any clue..do help me..

New member

Posts

Joined
Wed Jan 16, 2008 10:35 pm

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by pdbs » Fri May 09, 2008 9:50 am

Hope this helps:

Question I would have for sendmail would be can you send email to a local user on the system?

I had an issue with my host where email was only available local host. If this is the case do the following and verify that RDNS is set properly.
nslookup  (Your DNS Provider )
nslookup
> server
> q=mx
>

The results should contain your proper domain name of the server  from where mail is sent.

Then:
telnet   25

The name returned should match what is in the CNAME or IP Address

New member

Posts

Joined
Thu May 08, 2008 2:56 am

Post by hm2k » Thu Jun 26, 2008 6:33 am


UK Web Hosting


User avatar
Global Moderator

Posts

Joined
Tue Mar 11, 2008 9:06 am
Location - UK
Who is online

Users browsing this forum: No registered users and 2 guests