A
A
Adiost2011-05-31 17:44:57
MySQL
Adiost, 2011-05-31 17:44:57

Problems with encoding when requesting data from MySQL database; IP blocking

Good evening, sir!

I got two problems.
The first is that in the table settings I didn’t set any encoding, but still question marks instead of Cyrillic. The PHP script itself that executes the request is encoded in Unicode UTF-8. What could be the problem, how to solve?

The second problem is the need to prohibit re-executing the same PHP script with the same Post request from the same IP. What is the best way to implement this? It seems to me that entering IP into the database is absolutely unprofitable and in general this is an extra load on the server. Any ideas?

Thank you in advance, gentlemen!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xaker1, 2011-05-31
@xaker1

Regarding encoding:
mysql_query("SET NAMES utf8");
mysql_query("SET COLLATION_CONNECTION=utf8_bin");
On the second problem, should the session mechanism be used? We check the presence of the flag - if it is, then disable the script. If not, we create and work further. The truth is only suitable for real users whose browsers store cookies.

S
slang, 2011-05-31
@slang

To protect yourself from repeated posts to the same address from a client with the same IP, make some kind of MD5 thread out of them:
md5($_POST . $_SERVER['REMOTE_ADDR'] . __FILE__);//по хорошему тут URI нужен а не __FILE__
And into its database. Check with the next posts. You can also add a time stamp and periodically reset the old ones (so that the base does not swell). There is no unprofitability here, except that only the solution method is chosen incorrectly (for example, you protect yourself from an accidental double-click on a submission in this way).
I left a comment on the encoding above.

D
Dmitry Sergeev, 2011-05-31
@JetMaster

in order not to make an extra request SET NAMES 'utf9' COLLATE 'utf8_unicode_ci', in the my.cnf file in the [mysqld] section, you can add the line init_connect='SET NAMES utf8' (as far as I remember, there was init-connect before muscle version 4.1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question