Zen Cart Logo
Forums / General Questions / Product Name Limitation Not Working

Product Name Limitation Not Working

Locked

Views: 1,043

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
26 Jun 2011, 1:36 AM
#1
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Product Name Limitation Not Working

I just noticed today that when entering a new product on the Admin Side, the product name field is no longer restricting that field during data entry.

I know this is supposed to only be 64 characters. In the past, when entering a product name the field will not allow more than 64 characters to be entered. Now it allows entering more than 64 characters even though only 64 characters is saved to the database. Any ideas why all of a sudden it's allowing the ability to enter more than 64 characters even though in reality only 64 is valid? I so badly want the feature back where the field actually doesn't allowing entering more than 64 characters. Basically, I want the data entry field to obey the maximum value during input (which is what it used to do).

Thanks!

26 Jun 2011, 4:38 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,659
Plugin Contributions:
0

Re: Product Name Limitation Not Working

What version are you using?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

27 Jun 2011, 3:55 PM
#3
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: Product Name Limitation Not Working

Kim:

What version are you using?

Thanks Kim! We are currently using version 1.3.9h but the only changes that has happened recently is converting to utf8 per instruction from this post: http://www.zen-cart.com/forum/showthread.php?t=93439&page=12

Not sure if that could be a source of the issue I am experiencing or not.

27 Jun 2011, 7:27 PM
#4
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: Product Name Limitation Not Working

Also, want to update that this problem applies to other fields as well. For example, when creating account, the first name and last name field is supposed to only allow 32 characters. However, the create account form allows me to enter more than 32 characters but only 32 characters is saved to the database. When saving the character limit for the field is observed but when entering the information in the field the problem is there (allowing entering of more characters than the limit).

I also want to clarify that I do not experience the same problem on a new installation of ZC I just created so something is messed up on our current installation but I don't know how to troubleshoot this.

This problem happens on both admin and catalog fields. I don't know if there's a filed/function that controls this maximum character limitation but will appreciate any help in getting to the bottom of this issue.

Thanks!

27 Jun 2011, 10:24 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Product Name Limitation Not Working

Your Create Account page is imposing a 96 char limit on First Name form field. (You can see it in the HTML too).

You said it doesn'thappen on a new install. Is that new install set to UTF8 from the very start? What's the HTML size and max limit shown on that same First Name field in that case?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Jun 2011, 10:34 PM
#6
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: Product Name Limitation Not Working

DrByte:

Your Create Account page is imposing a 96 char limit on First Name form field. (You can see it in the HTML too).

You said it doesn'thappen on a new install. Is that new install set to UTF8 from the very start? What's the HTML size and max limit shown on that same First Name field in that case?

Thanks DrByte, I am not sure why that's the case because when I look in the database the varchar is 32. I don't know what controls the these pages and why the create account page is imposing a 96 char limit.

I did not convert the fresh install to UTF8 just for the sake of seeing what happens without database modification. I can convert it to UTF8 following exactly the same step I followed before to confirm if this is indeed related to the changes initiated via UTF8 conversion. I am sending you the url to the test site via PM if you can clean something from it.

Thanks!

27 Jun 2011, 10:49 PM
#7
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: Product Name Limitation Not Working

For what it's worth and I don't know if this makes any sense to you, every field is actually being multiplied by a 3 to come up with the maxlength. I am not sure exactly what's going on but for every field on create account page of for example on the admin side, creating a new product, each field maxlength is set to the varchar showing in the database x 3 but when the information is saved to the database only the varchac value is saved.

So for example on the create account page, the postal code char is 10 but the maxlength set is 30...even when you enter 30 the db will only save 10.

Not sure if this information helps on not to help me pinpoint where things maybe messed up on which file controls this.

Thanks!

1 Jul 2011, 6:58 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Product Name Limitation Not Working

The following fixes to the query_factory.php file will resolve the problem of field lengths not being properly detected in a UTF8 database:
There's only one "query_factory.php" file.
Replace one function with another. Simple.

  function metaColumns($zp_table) {
    $res = @mysql_query("select * from " . $zp_table . " limit 1", $this->link);
    $num_fields = @mysql_num_fields($res);
    for ($i = 0; $i < $num_fields; $i++) {
     $obj[strtoupper(@mysql_field_name($res, $i))] = new queryFactoryMeta($i, $res);
    }
    return $obj;
  }
```becomes```
  function metaColumns($zp_table) {
    $sql = "SHOW COLUMNS from :tableName:";
    $sql = $this->bindVars($sql, ':tableName:', $zp_table, 'noquotestring');
    $res = $this->execute($sql);    
    while (!$res->EOF) 
    {
      $obj [strtoupper($res->fields['Field'])] = new queryFactoryMeta($res->fields); 
      $res->MoveNext();
    }    
    return $obj;
  }
```and```
  function queryFactoryMeta($zp_field, $zp_res) {
    $this->type = @mysql_field_type($zp_res, $zp_field);
    $this->max_length = @mysql_field_len($zp_res, $zp_field);
  }
```becomes```
  function queryFactoryMeta($zp_field) {
    $type = $zp_field['Type'];
    $rgx = preg_match('/^[a-z]*/', $type, $matches);
    $this->type = $matches[0];
    $this->max_length = preg_replace('/[a-z\(\)]/', '', $type);
  }

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Jul 2011, 6:11 AM
#9
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: Product Name Limitation Not Working

Thank you so much! I applied the code changes and that solved the problem.

Thank you so much! I am one happy dude right now :D