How to save chemistry equations in MySQL table field [closed] - php

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I want to save chemistry equations in my database, equations for example:
`AB + O2 → Oxide of A & B`
Even typing here 2 is coming beside O whereas it's the symbol of oxygen like below:
 
Please note: If I am trying to directly copy and paste it in MySQL table field using phpMyAdmin, there also O2 is not getting saved as a symbol.
Note: MySQL field is text , collation is utf8mb4_general_ci.
Saving from php to mysql is next step. For now at least simply copying it (from phpMyAdmin) should work in MySQL.

I noticed that the subscript numbers on the web pages aren't actually subscripts, its just the HTML tag making it. (the <sub> tag).
So you have to use some kind of converter for it or do it yourself to convert it to actual unicode subscript.
If you want to print the equations to web page from database, you can save it with the HTML tag e.g.
H<sub>2</sub>O

Related

How do I convert Hindi Text to UTF-8? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I've got an Excel file with text in Hindi which I'm trying to read via PHP but I only get gibberish out of it.
When I open the .xls File with Numbers, the text looks like this:
But when I copy and paste this exact text here it looks like this:
ß[+kq'kh ge ij fuHkZj djrh gSAÞ
When I read it via PHP I get exactly the same gibberish text.
Is this an encoding problem in the .xls file and is it somehow possible to extract a UTF-8 encoded version from it?
Jaswinder Singh's comment fixed the Issue!
The text is written in a font called "Kruti Dev 010" which is just normal text but displayed as hindi letters.
By using this tool I could recover the texts to unicode.
Thanks Jaswinder!

Store and show emojis [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I use a TextView to user type a comment, I store it on data base and show on a tableview or label to user. But when the user type a emoji on middle of string, the emojis is stored like a hexa, how to convert this emojis again when I add on label or tableview?
Or I dont need to change anything on my swift code and I need to change my database to store emojis? Or my API PHP?
Your connection to MySQL must specify utf8mb4.
Your column/table must be `CHARACTER SET utf8mb4.

replace ascii code in string php [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have an app that stores survey responses. Some of the responses are plain-text responses with feedback.
When the person filling the survey out adds a line (his return on the key board) this creates a new paragraph.
It is stored in my Postgres database as an ascii character chr(10) (referring to it in Postgres terms).
This is all fine however the problem I am running into is when I display the values. My PDF printing app doesn't understand this ascii encoding and displays it all as one line. Instead of:
One line
Two lines
Three lines
It returns it as:
One line Two lines three lines
Makes for very long drawn out paragraphs...
I am trying to figure out how I can replace the ascii code with an html break <br/>.
I am obviously familiar with str_replace - the point is that I am not familiar with ascii at all and need some help on how to search for this in the string to replace with an HTML break <br/>.
Thank you.
To replace line breaks with <br />, you can use the built-in PHP function nl2br
e.g.
$content = nl2br($content);
(technically it inserts the BRs before the line breaks, so they're still there, but should work ok)

how can we get raw html from mysql database in php [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a table in database. this table has one field which consist raw html data below format:
<iframe width="475" height="271" src="http://www.youtube.com/embed/GcUYa4_1aYs?rel=0&hd=1" frameborder="0" allowfullscreen></iframe>
when I am fetching the data from database its rendering the html code. I want to just show as it is(Raw html) in PHP without rendering. how can i display it? when i am showing that, its just rendering the data from database.
You can use htmlentities or use single quote '', this is a very good SO question and answer on difference in php between single and double quotes.
Use htmlentities($your_html_code);
It is your safest bet, it does what htmlspecialchars() does, and more.

using explode with php and mysql [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I am doing my project and I am using php and MySQL
My program is reading a data from textarea as a list of people, I use the explode function to separate the list and then I generate a for loop to insert them to MySQL database
till this part I don't have any problems
The problem is when I query the database with a where condition specifying a name from the list it does not recognize it
My question does the explode function change any thing to the names in the list or add any special characters
because I use the same functionality with specific name and it goes smoothly
Thanks in advance
It should not. PHP explode will not change your text and the WHERE query should operate correctly.
Are the characters all utf8 encoded? Check the database and see what you are querying for actually exists the same way you are sending it.
Like the others said, if you can provide us an example of the following it would be great:
Actual textarea input (not exploded).
DB Dump of what is inserted.
Your QUERY to select
Additionally, it could be a space issues, use trim before you insert the data or in your query instead of field = '$a' do a field LIKE '%$a%'
I don't think explode() will modify anything. try to use trim() in your foreach loop before inserting. Might be some characters that can not be seen.

Categories