Welcome Guest, Not a member yet? Register   Sign In
Escaping the trademark symbol with MySQL

[eluser]TWP Marketing[/eluser]
In a sense, Colin, you're correct.

I removed the decoding with html_entity_decode(), in my function: read_ds_record(), which fixes the problem.

Because this particular view is on the administrative side of my project, I actually WANT to see and edit the encoded text, NOT the parsed text.

When I send this same text into my User side view, where it cannot be edited, the decode will work just fine, being done with a different function, displaying the trademark symbol and any other HTML characters that are coded into the db using htmlentities().

Thanks for your help!

[eluser]TWP Marketing[/eluser]
I pass arrays (and single vars) by reference in almost all cases, to reduce the memory space needed and reduce the execution time. For example, the text in question here is stored as a 'text' data type in MySQL, which can be up to 64KB, I'd rather not have that memory space duplicated from one function call to another. I declare most arrays in the controller and that one memory allocation is used by one or more other functions in the model. While it is rare to use more than a fraction of the 64KB, it is a possibility, so pass-by-reference makes sense. I've not found any part of CI's code that fails due to pass-by-reference (yet...).

As far as your second question, without encoding to the db, it works. But I didn't want to risk allowing unprotected HTML being stored in the db. I'll be adding some XSS_cleaning in the future too.

What I meant is that call time pass by reference has been deprecated now. If I run this script:

$str = 'string';

function reverse_string($str)
    $str = strrev($str);


echo $str;

I get this error:
PHP Warning:  Call-time pass-by-reference has been deprecated; If you would like to pass it
by reference, modify the declaration of reverse_string().  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 in C:\Users\Daz\- on line 10

I know that this has nothing to do with your problem, I just thought I'd point this out in case you were unaware of it.

[eluser]TWP Marketing[/eluser]
I was not aware of the deprecation. That change seems to make no sense. I'll have to do some research because I want the benefit of using only one instance of a var. PITS!
but thanks for the info.

UPDATE: I did some research, here: http://devzone.zend.com/article/1714-Whats-New-in-PHP-5
which states:

Quote:"This behavior is not very intuitive, as many developers would expect the Java-like behavior. In Java variables actually hold a handle (or pointers) to the object, and therefore, when it is copied only the handle and not the entire object is duplicated.
There were two kinds of users in PHP 4, the ones who were aware of this problem and the ones who weren't. The latter would usually not notice this problem and their code was written in a way where it didn't really matter if the problem existed or not. Surely some of these people had sleepless nights trying to track down weird bugs which they couldn't pinpoint. The former group dealt with this problem by always passing and assigning objects by reference. This would prevent the engine from copying their objects but would be quite a headache as the code included numerous & signs.

The old object model not only led to the above-mentioned problems but also led to fundamental problems that prevented implementing some additional features on top of the existing object model.

In PHP 5, the infrastructure of the object model was rewritten to work with object handles. Unless you explicitly clone an object by using the clone keyword you will never create behind the scene duplicates of your objects. In PHP 5, there is neither a need to pass objects by reference nor assigning them by reference.

Note: Passing by reference and assigning by reference is still supported, in case you want to actually change a variable's content (whether object or other type)."

TWP: Note the 'Note:' at the end. This is precisely the need I have. That being said, I am using PHP5 and don't face the problem of having to force my code to run under PHP4, EXCEPT when I deal with CI related programming... It's the exceptions to the rule that bite you every time. Thanks again for making me aware of this whole situation.

Theme © iAndrew 2016 - Forum software by © MyBB