I'm building a website for a friend using Wordpress. There is one particular element he is going to need to update and he's not used to code so I have created a file that he can edit without getting involved in wordpress.
In wordpress I call this file using PHP include which works wonderfully until there are any £ symbols in the file. At this point the £ symbol gets replaced with a ? in a square thats been rotated 45 degrees.
I have looked on this site and found this, the problem being, that doesn't help me.
I have tried replacing the £ symbols for £ & £ both of which give the same output.
Anyone got any ideas?
EDIT: As requested;
<p class="menu_item">Americano - £2.00<br><span id="item_description">A double espresso stretched</span></p>
there are various lines like the one above in the file being called. I then call the file in wordpress using <?php include './wp-content/menu_content.txt'?> - I have tried calling it as a txt file, php and html.
I think this is not a problem with wordpress but rather with web server that tries to serve this site in some other encoding. Can you provide response/request headers and a raw html page heading?
Related
I am trying to create a file management system on my website. Problem is with downloading files that contain special characters (other work correctly).
If I use file_exists($mypath) the result is true therefore file exists.
When deleting this file with unlink($mypath) it also works fine.
Only thing that doesn´t work is downloading the file.
The download is done via href link where I echo the path but it somehow converts the characters so the link doesn´t work. The solution is in some conversion but I had no success yet.
I suspect that php is converting the special characters into html entities.
You should use the 'rawurlencode' php method to keep the special characters.
The following link talks about you issue (special chars appearing in file name and wanting to create a link):
http://www.dxsdata.com/2015/03/html-php-mailto-content-link-with-special-characters/
Their solution shows the use of rawurlencode, the following was copied from above link just incase the link goes dead:
Snip start...
Scenario
On your website, you want to offer a link which opens a mail client like Outlook with mail and content suggestion. The content contains a link to a file with special characters in its name, which causes Outlook to break the link, e.g. if it contains spaces or german Umlaute.
Solution
Using PHP, write
<?php
$fullPath = $yourAbsoluteHttpPath . "/" . rawurlencode(rawurlencode($filename));
$mailto = "mailto:a#b.com?subject=File for you&body=Your file: ".$fullPath;
?>
Generate Mail
Note the double usage of “rawurlencode” function. The first one is needed for HTML output, the second one will be needed for the part when Outlook takes the link code into its mail window.
Snip end ;-)
I ran into a quirky syntax issue.
I am using php and cUrl to pull in data from a web page. The link has several variables. One of them is '<V', but the resulting link keeps translating '<V' as '<V', looking as '<' and the 'less than' symbol, when I need the literal text.
I have looked all over the place to figure out how to force php to read '<V' literally but have not found it.
Any ideas here would be appreciated.
Thanks.
You need to encode your HTML entities. Either use htmlentities or manually type out the string "<V".
I'm having an issue, which seems like a bug, whereby if I download a CSV that I've created it seems to leave 12 empty spaces on the top of the file before filling in the content I want in there.
Is this just a general bug?
I'm using Codeigniter 2.1.3
Thanks Guys
I just had this same issue. When I looked through my code I was calling in a model that had a closing ?> tag, and for some weird reason, that created the extra space. Look to see if you have any closing php tags.
i had the issue too. But i solve it not related to closing ?>, but space in the beginning of php file. use tools such as winHex to open related php files, look if the file start with a space(in Hex it's 20), remove it, and the problem had solved.
sorry for my poor english.
I have a page written with php where, for some reason, all of the plain html content of the file index.php goes on one line (look at the source) The white space is preserved, but all the new-lines disappear.
I cannot come up with any reason why this would happen, short of a syntax error, but I went through with a fine toothed comb, and found nothing out of place. This only happens on the index.php page.
Anyone have any Ideas what I should be looking for? I can post more code if necessary.
<?php
//...
include('ssi/header.php');
?>
<div>
<section id="charters">
<h2>Tanker Chartering</h2>
<!-- ... -->
The above code evaluates to something like this:
<div> <section id="charters"> <h2><a href="charters.php">Tanker ...
Maybe you have linux server and you're using windows system. Different operating systems use different new line characters. Also, for one server my FTP client uploaded it with wrong formatting, and missed every line break.
Also applications like
Notepad++ gives you the ability to change formatting and linebreaks.
It's probably the encoding of the file combined with the transfer mode on the ftp from which you downloaded/uploaded the file. Try using something like notepad2, and saving the file in UTF-8 rather than ANSI. Also upload/download with your FTP program in binary not ASCII. That stopped all of my newline issues with PHP.
could it be that your hosting provider is doing some kind of minimization for you? no newlines means less characters pused down the wire.
I have a bit of PHP where I want to store a URL in a string.
The code itself seems fine, but for some reason, when I use the characters $sectionId=, it causes problems, in fact, it alters $sectionId= and changes it to §ionId=.
If I misspell it to $secionId then it works fine.
The full url SHOULD be:
http://url.com/file.php?appKey=$appkey&storeId=$storeid§ionId=$sectionid&v=3
but when I do an echo $myURL; on it, it gives me:
http://url.com/file.php?appKey=$appkey&storeId=$storeid§ionId=$sectionid&v=3
Notice the §ionId= instead of $sectionId=.
Can anyone help me with this? It seems like basic PHP, but I don't understand why it just doesnt like those 4 or 5 characters in a row!!
Thanks.
Are you echoing it right to HTML? Well, some over-helpful browsers will do character conversions without being asked explicitly to with a semicolon; all you need to do is run it through htmlentities or replace all &s with & and it will display correctly.