PHP problems with apostrophes and Quotation marks


#1

akhilkumar332Staff12h Helped me with this topic late in August 2017

My website is
https://exper17.000webhostapp.com/

The specific subpage is
https://exper17.000webhostapp.com/gmvolt.php

I started with an htlm/css website that I wrote, and got tired of of re-writing the NAVBAR on each page, so I made a php page to contain the NAVBAR. I call the NAVBAR with the command

<?php include('navbar.php');?>

Works Beautifly, except that apostrophes and quotation marks
get written to the screen as question marks

On akhilkumar’s advice I added this to .htaccess
AddDefaultCharset Off

AND I put this (started line with <)
meta charset=“utf-8” >
into the head of:
exper17.000webhostapp.com/gmvolt.php

Note: 1st character in each line below is <
Preview won’t reproduce line if I start it with <

!DOCTYPE html>
html>
head>
title>GM Volt Writer
meta charset=“utf-8” >
meta name=“description” content=“GM Volt” />
link href=“stylesheet.css” rel=“stylesheet” type=“text/css” />
head>

I also tried
meta charset=“utf-8” />
because of some suggestions I found online

I also tried some other charsets besides utf-8

Can someone tell me where I’m in error?


#2

Try this

<!DOCTYPE html>
<html>
<head>
<title>GM Volt Writer</title>
<meta charset=“utf-8” >
<meta name=“description” content=“GM Volt” />
<link href=“stylesheet.css” rel=“stylesheet” type=“text/css” />
</head>

#3

Hi ckhawand,

As I type stuff in this window, I notice that some html statements just do not show up in the preview window. In my last note, I was trying to get around that problem, without success.

If you could go to
https://exper17.000webhostapp.com/gmvolt.php

you’ll see the problem, and if you hit Ctrl+U, you’ll see I already have exactly as you suggest.

Good! At least I’m on the right track, but can you see what I’m doing wrong?


#4

Do you mean those �?


#5

Yes, that’s it exactly!


#6

Add this to your php script
header(“Content-type: text/ html; charset=utf-8”);


#7

where, in
https://exper17.000webhostapp.com/gmvolt.php

do I put it?
in the header? Before the header? after it?

I really don’t know anything about php, except that one command

<?php include('navbar.php');?>

#8

Put it after the include line


#9

I tried it, but no luck, it didn’t work


#10

Do you load HTML content from your database?

Put this inside <head> tag.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


#11

Hi Supon,

I put it in
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

It didn’t help

Actually, ckhawand suggested something similar earlier
<meta charset=“utf-8” >

It didn’t work, either


#12

What is the text editor you use?


#13

I used Microsoft’s Text editor. The files it creates, the files that I upload to the server are ascii


#14

This is a weird problem. Can you try using Sublime text and try again.


#15

Hi Supon,

What is Sublime text? Won’t it just produce ascii? Isn’t ascii just ascii, no matter where it comes from?


#16

Can you type those ASCII characters on the forum?


#17

Hi Supon - I don’t understand - what would you like me to do?


#18

Actually, i can’t tell you an exact answer. I guess it might be a problem with your text editors encoding. I asked you to try using Sublime Text. Download it and open your file with it. Then save it in encoding utf-8 and upload.


#19

Later tonight, I’ll see IF I can get either of my Ubuntu computers to work. If I can I’ll download Sublime Text – Thanks Again!


#20

Hi Supon,

It LOOKS like I solved the problem. I downloaded Sublime text from

http://tipsonubuntu.com/2017/05/30/install-sublime-text-3-ubuntu-16-04-official-way/

I opened the old ascii file
https://exper17.000webhostapp.com/gmvolt.php
and saved it as utf-8

I also opened another file I had the same problem with:
https://exper17.000webhostapp.com/scopejunction.php
and saved it as utf-8

They both seem OK

After I finish updating the whole website, I would be glad to write this up as some sort of application note, if you think it will be helpful. Please don’t close this yet, because I want to first see if any similar problems pop up.

Again - Thanks

  • Gary