How to make database able to read & write "ÆØÅ"? - php

So the problem is that i'm trying to upload a "new ico", my site is all about cryptocurrency. Everything is working as it did locally on my computer, but when im trying to upload a new ico it says this:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '�rdi, whitepaper, social, avatar) VALUES ('KickCoin','Random','Random','Random'' at line 1"
�rid = Should be saying "Værdi".
I read that the problem defiantly is something connection based with the database or so (because i didn't have the problem local)? But how do i fix it, so that my website will show "ÆØÅ" and how do i make the database able to understand "ÆØÅ", so that i can upload?
Thanks in advance,
Victor

You can change the database collation to
latin1_swedish_ci/utf8mb4_bin
This will work. Its working fine for my sites.

Related

Error 245 in mysql prepare

I am trying to get a database to work for my app where I want to save results in a database. I have set up a set of php-files which I call from my android application. Everything works as long as the table does not have any columns with json data, but I want to save a json file in my database. The error I get is
mysqli::prepare(): Unknown type 245 sent by the server. Please send a report to the developers in <b>/Users/usrname/LearnPhP/Documents/android_login_api/include/DB_Functions.php</b> on line <b>59</b><br />
Line 59 in DB_Functions:
$stmt = $this->conn->prepare("SELECT * FROM users WHERE email = ?");
I have googled but not found anything. I am working on my MacBook, when using Windows 10 it works perfectly. However, it should work on Mac as well, secondly the next step is to set up a server which is on my desktop computer and then I need to work from my Mac to test it properly.
SOLUTION:
Thanks to the tip in the comments I found out that there was a mismatch between php and mysql. I have mysql 5.7.12 and now I use php 7 and that works fine.
I followed this to update my php.

Phpmyadmin is not showing all tables in a mysql database

I have been running a website from home for a few months now and suddenly phpmyadmin is not showing me all the tables in the mysql database.
Here is a screenshot 1:
I thought the database could be corrupt or maybe someone has executed some bad sql code so I deleted the database and tried to restore from a date that I knew was working and the same thing happened. So I built a new server thinking something in phpmyadmin could be corrupt but now I am facing the same issue on the new server.
I tried manually creating the database but after so many tables have been created the same thing happens.
As you can see in the screenshot 1 on the left side it stops after customcars but then in the middle in continues to downloads. There should be more tables but they will not show up.
I have ran a script to check if they exist and they do but I just cannot access them on phpmyadmin
I have tried importing the database with a .sql file and still no luck.
Sometimes it evan looks like this
Notice the way the customcars on the left is missing and so is the X in the middle for downloads.
My Operating System Is Centos 6,
Mysql Version 5.1.73,
Phpmyadmin 2.11.11.3
Thank you for reading and I hope someone out there has had the same issue so I can fix this asap :)
You might want to check that Settings > Navigation Panel > Maximum items in branch is not set to a low number. http://docs.phpmyadmin.net/en/latest/config.html#cfg_MaxNavigationItems
I had the same issue. I found an eye symbol next to my database name in the left column. When I cliked on the eye symbol I had the option to unhide the missing table. I have no idea how I managed to hide this table but this solved my problem.
You might accidentally hide any table by clicking eye on PhpMyadmin. Click the eye icon then it appears a pop up to show the hidden table.

PHP button delete row from table not working

I am having the simple php code that shows columns in table test (delete.php & delete_ac.php), when click on delete button this suppose to delete the respective column. But it is displaying error occurred and the table HTML showing blank. Not sure which steps i was wrong. Any help are very appreciated.!
http://pastebin.com/9Zz217Bn
I suggest using
echo mysqli_error();
to see what the error is.
Also you don't seem to be setting $id.
From your responses it seems that you have an error in the sql. The error might be from the way you are sending your data to the script. Tangentially you are encountering an error because you have not in any way checked the input which could be anything and are trusting that it is valid data. It helps to assume that all users are mean and want to cause damage.
So I would recommend at least an if and a test for the data being numeric. Then you could see if you were passing bad data. This might help you troubleshoot and will make your code more robust against attack, user error and things like that. You would not want someone manually typing the URL and putting id=>-1 as that would delete everything.
Like the one you commented:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id']; ?>'' at line 1 mysql version is 5.6.12
However what you might need to do (as others have pointed out) is echo the sql and paste it into something like phpmyAdmin or some MySQL GUI and see what it you get back. The (more than likely) error may help you identify the cause of your problems. It looks like you might have ended up with the php code in the query string.
If you have short tags off then the short php you have use will not work and will end up in the link which it does seem to have done. Try:
<?php echo $rows['id']; ?>
Which I think will work for you much better.
If in doubt go back to the earlier suggestion (not just from me) to echo out the generated sql which I would expect will not look right.
While you are at it can I recommend you consider using "LIMIT 1" at the end of your SQL once you have it working? Then if anything goes wrong you only dropped the one row.
One last thing it makes folks here much happier if you just paste the code into the question.
I hope I helped you.
The problem lies in your Querystring of delete button use fuller
Thanks a lots for all answers, i am really appreciated your helpful tips. i have checked the syntax :
<td bgcolor="#FFFFFF">delete</td>
which is missing php line, after filled php line, the code working well:
<td bgcolor="#FFFFFF">delete</td>
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id']; ?>'' at line 1 mysql version is 5.6.12

mysql_real_escape_string () different behaviour on localhost and server, php5.1 , php5.4

Before i call this question, yes i know mysql_query is a bad practice but i need to fix this first then in the near future i will move to PDO or something ok..
I have a code that works perfectly in localhost using php 5.4 the problem is when i load it in server, everything works fine, there is just one error, that at this moment , im blind at it.
On a description field, for a kind of articles in a blog, i use elrte and elfinder editor, the problem is when i send a image to store in de Database, i have different results.
In local i do store the <img src="folder/ok/img.jpg"> but in the server for some reason the same files, and code store that in the database as <img src="\"/folder/ok/img.jpg\"" >
This must be related to this lines (the description file is going on $desc)
if(isset($_POST['submit'])){
//protect and then add the posted data to variables
$titulo = protect($_POST['titulo']);
$desc = mysql_real_escape_string ($_POST['desc']);
$cat_id = protect($_POST['cat_id']);
But can somebody explain this behaviour, cause im blind at this, also i know there are security issues on this, but well at least we are not storing any NASA info.
hope anyone can help me on this
Without having looked too far into it, mysql_real_escape_string is deprecated and you should use mysqli_real_escape_string() now (which goes with the new mysqli lib)
Are you sure $_POST['desc'] is the same on localhost and server? Maybe your POST request is being formed incorrectly

Url rewrite using PHP code

I am working on a client's application www.islamicaim.com. I have problem in url writing in video section. I was using url something like http://islamicaim.com/video_play.php?id=6 for playing videos. Videos work fine but now according to the new requirement of the client I want to write the url something like http://www.islamicaim.com/category/author/video/title.php for making the SEO friendly url.
I have stored the name of an author in database and name can contain space some thing like mr xyz. While using this name I am facing problem. If any one can suggest me how I can achieve this goal as i am a learner of Php. Thanks.....
Here is my query $q2="select id from media_author where name='".$author_name."'";
while $author_name has value "mr xyz"
and I am recieving this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 i have checked this query by running in sql it works fine..
Link where I am having problem is at http://islamicaim.com/media_details.php?category=Talawat-e-Quran&author=Qari%20Syed%20Sadaqat%20Ali
I'm not sure what specific error you are having as you basically just said it presently isn't working for you. But as you said the issue is the url can contain "mr xyz", it's probably that you need to replace the space with a %20.
I don't know PHP but I'm guessing that it, like every other language, has a call to encode a url - call that on your url and that will transform all characters that need to be in the %xx form.
Can't see any problem with your query, unless there is a problem with something else. Have you tried all the possibilities for this? Such as:
$q2 = "SELECT id FROM media_author WHERE name = $author_name";
Or
$q2 = "SELECT * FROM media_author WHERE name = '$author_name'";
Maybe you should add some more related code for us to check.

Categories