From: Rafael C. <raf...@gm...> - 2014-04-05 17:26:03
|
Hi Tim, Thank you, very much. Yes, you are right. When $ItemDescriptionLanguages is empty, *<pre>$sql = mb_substr($sql,0,mb_strlen($sql)-3) . ')';</pre>*deletes wrong. I improved <pre> *$sql = "SELECT descriptiontranslation, language_id FROM stockdescriptiontranslations WHERE stockid='" . $StockID . "' AND ("; foreach ($ItemDescriptionLanguages as $DescriptionLanguage) { $sql .= "language_id='" . $DescriptionLanguage ."' OR "; } $sql = mb_substr($sql,0,mb_strlen($sql)-3) . ')';* </pre> with <pre> *$sql = "SELECT descriptiontranslation, language_id FROM stockdescriptiontranslations WHERE stockid='" . $StockID . "'";* </pre> (if we want all DescriptionTranslation is not necessary to list each), but main problem persist: somewhere $ItemDescriptionLanguages becomes empty (or is not global?). I appreciate if someone can give me an idea of where this variable is loaded. I have reviewed Stocks.php, StockClone.php, SystemParameters.php and SQL_CommonFunctions.inc, and so far I have not found anything that tells me what can be the cause of $ItemDescriptionLanguages becomes empty. Best regards, Rafael. 2014-04-05 11:06 GMT-06:00 Tim Schofield <tim...@gm...>: > Hi Rafael, > > I can tell you what is happening but I cannot explain it .Line 937 of > Stocks.php is as follows: > > $sql = "SELECT descriptiontranslation, language_id FROM > stockdescriptiontranslations WHERE stockid='" . $StockID . "' AND ("; > > and then there is a loop that is supposed to add some conditions: > > $sql .= "language_id='" . $DescriptionLanguage ."' OR "; > > and then finally the line > > $sql = mb_substr($sql,0,mb_strlen($sql)-3) . ')'; > > removes the last 3 characters and (which is supposed to be 'OR ' that > was added to the last condition) and then adds a closing bracket. > However for some reason the loop is not adding anything and so then > the last 3 characters added in 937 "D (" are being removed so your SQL > ends with "AN)" which is obviously wrong, see the error message. > > You can verify what I am saying by putting an > > echo $sql; > > after line 941 but before the DB_query() function call. > > For this to happen $ItemDescriptionLanguages must be empty but I > cannot tell you why. I have tried to force it to happen on my machine > but cannot replicate it. Check the value of the config variable > ItemDescriptionLanguages in the config table and see what that says. > > Thanks > Tim > > On 5 April 2014 17:39, Rafael Chacón <raf...@gm...> > wrote: > > Dear All: > > > > In Stocks.php and in StockClone.php, I got this error when I edit > > (Stocks.php) or clone (StockClone.php) a stock item, after I click the > > "Update" / "Insert New Item" button (Stocks.php / StockClone.php): > > > > Database Error 1064 : > > You have an error in your SQL syntax; check the manual that > > corresponds to your MySQL server version for the right syntax to use > > near 'AN)' at line 1 > > Database SQL Failure : The SQL that failed was > > SELECT descriptiontranslation, language_id FROM > > stockdescriptiontranslations WHERE stockid='2000000300030' AN) > > > > The company has 3 languages (Spanish -default-) and > > ItemDescriptionLanguages = "en_US.utf8,fr_FR.utf8,". > > > > When I re-setup ItemDescriptionLanguages, I works,but in a second > > query the problem reappears. > > > > I think the problem is that the variable ItemDescriptionLanguages > deletes. > > > > Any ideas to where to look for? > > > > Best regards, > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > > Web-erp-developers mailing list > > Web...@li... > > https://lists.sourceforge.net/lists/listinfo/web-erp-developers > > > > -- > Course View Towers, > Plot 21 Yusuf Lule Road, > Kampala > T +256 (0) 312 314 418 > M +256 (0) 752 963 325 > www.weberpafrica.com > Twitter: @TimSchofield2 > Blog: http://weberpafrica.blogspot.co.uk/ > |