CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Apostrophes in names

Print topic Send  topic

Author Message
osulywan


Posts: 16
Posted: 12/21/2013, 3:49 PM

I built an PHP app in CCS 5 and it works great. People put names and comments with apostrophes (i.e. O'Sullivan) and they go into MySQL DB and returned fine.

Now I copy this project, give it a new theme (Artisteer Design) and upload it. Same server. I did make several changes to customize. The cloned app now shows \' (escape apostrophe) when names are displayed (O\'Sullivan)

I don't get errors but when I update a row with O\'Sullivan it becomes O\\\'Sullivan.
All code looks the same. Does anyone know what is going on?
View profile  Send private message
eratech


Posts: 513
Posted: 12/21/2013, 7:54 PM

I don't know for sure, but I suspect it is a DB connection setup.

Are both projects using the same database and database settings? They might be running on the same MySQL server, but could have different settings (that has happened with date formats for me)

It's unlikely to be the generated code, but check some the Connection Settings in the Common.php and db_mysql.php files for possible differences.

E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
osulywan


Posts: 16
Posted: 12/22/2013, 11:11 AM

Good point Eratech -
Both projects are PHP/MySQL. Both DB settings are congruent/ I tried MySQL and Improved MySQL. Here are more details. I look at rows (PHPMyadmin) and see there is no \. I can update in PHPMyadmin with either \' (slash apostrophe) or '' (apostrophe apostrophe) and the row displays correctly. After the update, the value is the DB is \' suggesting to me it is in the code somewhere.

I imagine somewhere there is a str_replace(''','\'') that is performing twice. Resulting in \\' in the value and MySQL ignoring the first slash.
View profile  Send private message
osulywan


Posts: 16
Posted: 12/22/2013, 12:32 PM

added this code to BeforeExecuteUpdate:

$applications->DataSource->SQL = str_replace("\\\\'","'",$applications->DataSource->SQL);

Seems like a cludgy fix. I know there is some switch somewhere that fixes this.

Some routine is changes ' to \'
Then it occurs again changing \' to \\\\'
View profile  Send private message
eratech


Posts: 513
Posted: 12/22/2013, 5:26 PM

Yep- cludge it is, but at least it's done for now.

I agree - a setting is flipped somewhere in the generated code to turn on the replace.

I've been amazed how much has changed in the last couple of years in both MySQL and PHP - both have been deprecating old settings and functions so sometimes code that was fine is now not-quite-broken for no good reason.

Cheers

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
osulywan


Posts: 16
Posted: 12/23/2013, 9:56 PM

Okay, I isolated the cause. This CCS project is designed to go on a Wordpress site. Both are styled the same but I want the Wordpress navigation menu on CCS pages. I made an Include page with this code:

$menu = theme_get_menu(array(
'source' => theme_get_option('theme_menu_source'),
'depth' => theme_get_option('theme_menu_depth'),
'menu' => 'primary-menu',
'class' => 'art-hmenu'));

Also require('../wp-config.php');

That wp-config.php includes pages which includes pages, etc. I have never untangled it completely. I just got it to work. It displays Wordpress primary navigation menu on my CodeCharge pages. Sweet.

Anyhoo ... If I remove the include, apostrophes are no problem.

So riddle me this: Why would a Wordpress menu effect the way updates are done in CodeCharge?

Couple of other tidbits. All tables are in the same DB. I did this same trick on the first project that works fine with apostrophes. This cloned project works fine EXCEPT when you enter apostrophe in a text field you get \', update it again \\\' update again \\\\\\'

I will set up a CCS menu that looks like the WP menu for now. Replace the WP menu include with the CCS menu include. Alas, another elegant solution foiled by unintended consequences.
View profile  Send private message
Lucius

Posts: 220
Posted: 12/30/2013, 5:06 AM

Quote :
So riddle me this: Why would a Wordpress menu effect the way updates are done in CodeCharge?

Most likely Wordpress include file has a custom overload implementation of some function that is used in CodeCharge, or more likely of PHP core function. Look for custom implementation of string escaping functions...

In any way such mixing of two frameworks is never good idea, as you don't know exactly what you are doing, which means you don't know what changes and what is worse what vulnerabilities you are introducing into your code. Some security implemented on CodeCharge can relay on some functions modified by your include.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.