' Error

ChrDav

New Member
Messages
15
Reaction score
0
Points
0
Hi,

My site was working fine up until a month or so ago, now whenever I open a page in the editor it converts all my apostrophes to '. Can this be fixed?

Everytime I open the editor I have to fix this up.
An example of my code is below:
$userselect = mysql_query("SELECT * FROM Users WHERE Username= '$username'") or die(mysql_error());

which converts to
$userselect = mysql_query("SELECT * FROM Users WHERE Username= '$username'") or die(mysql_error());

Thanks,
Chris.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
I suspect that this is as a result of copying and pasting.

WYSIWYG Editors like DW automatically convert code when pasted into the design view.

If I'm doing work on the core php, I tend to revert back to notepad!

No editor should convert simply by opening it though!!! :nuts:

You may find the same problems with "&" and a number of other symbols used in php.
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
are you using the html editor or the regular file editor?
 

tttony

Member
Messages
147
Reaction score
0
Points
16
its like blogger.com I had problems with the html editor
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
if you have access to the script code, then you can do a str_replace(''', ''', $string); or str_replace(''', '\'', $string); depending on what you want it to show. the first one will create an apostrophe using the html code &apos, while the second one will just display an apostrophe in the source, which will be displayed as an apostrophe on the page
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
oh, misread your op. just do a search and replace for ' to '. since this is happening in the php code, my first post is useless.
 

ChrDav

New Member
Messages
15
Reaction score
0
Points
0
It doesn't matter whether I open it in the code editor or the HTML editor, it still happens. I change it, then next time I open the file for editing it changes back. I know that I can do the search and replace, however everytime I open the file I have to do it again and this gets extremely annoying. You can't use search and replace in the HTML editor which is extremely annoying.

Pasting or typing it manually will make no difference.

This never used to occur until sometime in the last month so maybe something has changed with the servers?

If I use an external editor, everytime I want to look at my page I have to upload it to the server once again. I do a lot of change something small, reload the page to check it did exactly what I wanted it to do, so this just becomes impractical.
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
If I use an external editor, everytime I want to look at my page I have to upload it to the server once again. I do a lot of change something small, reload the page to check it did exactly what I wanted it to do, so this just becomes impractical.
I do the same as you.

What software are you using that this has problems with? this could have a number of causes, either with the ftp client, the software, or the server (although i doubt it's the server). I'll take a look at google to see if i can come up w/ anything.


WAIT!!!
looking at your op, i'm under the impression that you are using cpanels built-in editor. I would highly suggest using another program to edit with.

I'm currently using zend studio 6, but that costs money. You can also use aptana studio or eclipse, both of which are free. With them includes a built in ftp client so you don't need an external one (filezilla, cuteftp, etc...)
 
Last edited:

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
to code. do you use notepad, dreamweaver, frontpage or do you use cpanels built in editor when you get these problems?

if you're using cpanel's editor, i would suggest using one of the free ones i posted above (aptana or eclipse).
 

ChrDav

New Member
Messages
15
Reaction score
0
Points
0
I used to use Notepad. Now I use the built in one so that I don't have to repeatedly upload files when I just want to double check a small change.
 

mrxp_anupam

New Member
Messages
65
Reaction score
0
Points
0
This is probably a problem with the editor you are using.
Please use some other editor and this will be resolved.

Can use Dreamweaver or textpad
 

ChrDav

New Member
Messages
15
Reaction score
0
Points
0
I know I can do that, however I have to upload my files to the x10 server to see them, which is why I don't do it.
Is there either:
a) a way my code can be modified (see the first post) OR
b) a solution (which clearly no-one has)
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
ChrDav, there are plenty of solutions, but we're trying to help you get around them by determining where the problem is occurring. You can always do something like the following.

Original Code:
Code:
$userselect = mysql_query("SELECT * FROM Users WHERE Username= '$username'") or die(mysql_error());

Change To:
PHP:
$sql = "SELECT * FROM Users WHERE Username= '$username'";
$sql = html_entity_decode($sql);
$userselect = mysql_query($sql) or die(mysql_error());

Notice, all you need to do is put the string in html_entity_decode().
 
Last edited:

ChrDav

New Member
Messages
15
Reaction score
0
Points
0
Thanks vol7ron. I too would love to know the source of the problem, however if one can't be found altering the code may need to be done.
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
Well if you could, take a screenshot of the editor you're using. I think it's important to list what browser and add-ons (if any) you're also using. The other thing to identify is what character set/encoding you're using as these may affect how the browser interprets the data. If you're not using us-ascii, go ahead and do so.

At the top of the page I see "Edit", "Code Editor", "HTML Editor" -- I typically just use the Edit one. The final thing that you should list is the file type in CPanel. You might see text/html, application/cgi, text/cgi, etc. These could also affect your code.

I know I said that was the final thing, but you should be using the new File Manager, and not the "Legacy File Manager." However, test the legacy version and if it works for you, then just use that.
 

gomarc

Member
Messages
516
Reaction score
18
Points
18
It’s your browser!

With the example you provided, I was able reproduce this problem using Internet Explorer 7. On the other hand, doing exactly same thing with Firefox 3.0.4, your code does not change.
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
My feeling was either the browser, editor, or charset/filetype. I think he should try in FF as I've experienced a problem like what he's having before.
 
Top