Nginx clean urls, how to rewrite a folder as an argument with try

I'm writing a simple CMS in PHP. Pages (markdown files) and images are accessed like this (respectively): example.org/?q=about.md example.org/?i=photo.jpg Optionally, I would like to use clean URLs with Nginx, to make the same requests look like this: example.org/about example.org/photo.jpg I rather use try_files than if and rewrite but after experimenting for hours, I can't get it t

Nginx的清洁URL,如何用try尝试重写一个文件夹作为参数

我正在用PHP编写一个简单的CMS。 页面(降价文件)和图像以这种方式访问​​(分别): example.org/?q=about.md example.org/?i=photo.jpg 或者,我想使用干净的URL与Nginx,使相同的请求看起来像这样: example.org/about example.org/photo.jpg 我宁愿用try_files比if和rewrite ,但经历过了小时后,我无法得到它的工作。 location / { try_files $uri $uri/ /?q=$uri.md =404; } location ~ .(gif|jpg|png)$ { t

PHP: Why isn't exec() returning output?

I'm writing a PHP script to be used to check for network connections with Linux shell command ping calling it with PHP's exec() : <?php // Bad IP domain for testing. $domain_bad = "lksjdflksjdf.com"; $ip_address = $domain_bad; exec("ping -c 1 $domain_bad", $output, $return_var); var_dump($return_var); echo "return_var is: $return_var" . "n"; var_dump($output); exit; ?> I

PHP:为什么不是exec()返回输出?

我正在编写一个PHP脚本用于检查与Linux shell命令ping通过PHP的exec()调用它的网络连接: <?php // Bad IP domain for testing. $domain_bad = "lksjdflksjdf.com"; $ip_address = $domain_bad; exec("ping -c 1 $domain_bad", $output, $return_var); var_dump($return_var); echo "return_var is: $return_var" . "n"; var_dump($output); exit; ?> 我没有从$output中得到来自ping的错误消息的$output ,这正是

What is the best way to convert a string to UTF

I am wondering what the best way to convert an string into UTF-8 using PHP is. The following looks ok on the page, but in MySQL some characters are looking garbled. MYSQL: UPGRADE EVENT – New Mazda2 from £124.99 per month. Representative 0% APR over 3 years. Min 50% deposit required. Call xxxxxxxxxxxx for test drive, info or Ts&Cs. UPGRADE EVENT – New Mazda2 from £124.99 per month.

将字符串转换为UTF的最佳方法是什么?

我想知道什么是使用PHP将字符串转换为UTF-8的最佳方式。 以下看起来确定在页面上,但在MySQL中一些字符看起来乱码。 MYSQL: UPGRADE EVENT – New Mazda2 from £124.99 per month. Representative 0% APR over 3 years. Min 50% deposit required. Call xxxxxxxxxxxx for test drive, info or Ts&Cs. UPGRADE EVENT – New Mazda2 from £124.99 per month. Representative 0% APR over 3 years. Min 50% deposit re

From collation Modern

I am writing a PHP script to import some data from a Microsoft SQL Server database to my MySQL database. Collation in the SQL Server is Modern_Spanish_CI_AI (so I guess the encoding is ASCII), and in my MySQL database I'm using UTF-8 encoding and utf8_unicode_ci as collation. When I import the data I get wrong characters corresponding to the Spanish letter Ñ. I've tried to use the PH

从整理现代

我正在编写一个PHP脚本来将一些数据从Microsoft SQL Server数据库导入到我的MySQL数据库中。 SQL Server中的排序是Modern_Spanish_CI_AI(所以我猜编码是ASCII),而在我的MySQL数据库中,我使用UTF-8编码和utf8_unicode_ci作为归类。 当我导入数据时,我得到了与西班牙文字母Ñ相对应的错误字符。 我试图用PHP函数utf8_encode($ string)和mb_convert_encoding($ string,“UTF-8”)没有任何成功,(我有不同的错误字符,

Insert a ♥ into MySQL (heart character) via PHP

I'm having a heck of a time getting ♥ type characters into my database using php. I've got UTF-8 setting on the page <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> and <?php $line = $_REQUEST['line']; $line = stripslashes($line); $line = htmlspecialchars($line); $line = trim($line); $line = mysql_real_escape_string($line); mysql_query("SET CHARACTER SE

通过PHP将♥插入MySQL(心脏字符)

我有一段时间让♥使用PHP在我的数据库中输入字符。 我在页面上设置了UTF-8设置 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 和 <?php $line = $_REQUEST['line']; $line = stripslashes($line); $line = htmlspecialchars($line); $line = trim($line); $line = mysql_real_escape_string($line); mysql_query("SET CHARACTER SET utf8"); $sql = "INSERT INTO posts (txt) values ('$

Which MySQL collation exactly matches PHP's string comparison?

Here is a MySQL query: SELECT last_name FROM users ORDER BY last_name We get all that data into PHP and then run: $prior = NULL; do { $current = array_shift($results); assert($current >= $prior); $prior = $current; } while ($current !== NULL); Currently this assertion fails for certain inputs. Is it possible to add a COLLATE clause to the MySQL query above to absolutely guaran

哪种MySQL整理与PHP的字符串比较完全匹配?

这是一个MySQL查询: SELECT last_name FROM users ORDER BY last_name 我们将所有数据都存入PHP,然后运行: $prior = NULL; do { $current = array_shift($results); assert($current >= $prior); $prior = $current; } while ($current !== NULL); 目前这个断言对于某些输入是失败的。 是否可以在上面的MySQL查询中添加COLLATE子句以绝对保证PHP断言? 我试过的东西: 上面的代码,它不适用于某些非A

Symfony: InvalidArgumentException while parsing web.xml

Recently I moved a Symfony-system to another Server and got an error ever since. The technical details are: An apache 2.4 server on a windows server 2012 A fileserver which can be accessed by apache over the local network When I moved the Symfony-page I deleted the cache. What happens now is, that I get these error-messages: InvalidArgumentException: Unable to parse file "\FILESERVERPAGEPATH

Symfony:解析web.xml时出现InvalidArgumentException

最近我将Symfony系统移到了另一台服务器上,从此以后出现了错误。 技术细节是:Windows Server 2012上的apache 2.4服务器apache可以通过本地网络访问的文件服务器 当我移动Symfony页面时,我删除了缓存。 现在发生的是,我得到这些错误消息: InvalidArgumentException: Unable to parse file "\FILESERVERPAGEPATHvendorsymfonysymfonysrcSymfonyBundleFrameworkBundleDependencyInjection/../Resources/configweb.xml".

unique always saying value already exists

I'm using CodeIgniter's form validation, and I've spent a lot of time trying to fix this, with no luck. I have this field: <input type="text" name="user" id="user" length="20" placeholder="Username"> And I'm using this to validate: $this->form_validation->set_rules('user', 'Username', 'trim|required|min_length[3]|max_length[20]|alpha_dash|is_unique[users.user]');

独特总是说价值已经存在

我使用CodeIgniter的表单验证,并花了很多时间来解决这个问题,但没有运气。 我有这个领域: <input type="text" name="user" id="user" length="20" placeholder="Username"> 我正在使用它来验证: $this->form_validation->set_rules('user', 'Username', 'trim|required|min_length[3]|max_length[20]|alpha_dash|is_unique[users.user]'); 我的数据库有一个表users和user是一个领域,所以我不知道我做错了

How to store boolean datatype in MySQL?

Which datatype is used for storing true/false information in MySQL? Especially when writing and reading with a PHP-Script. Over time I have used and seen several approaches: tinyint, varchar fields containing the values 0/1, varchar fields containing the strings '0'/'1' or 'true'/'false' and finally enum Fields containing the two options 'true'/'false'. Not one seems optimal, I prefer the t

如何在MySQL中存储布尔数据类型?

哪种数据类型用于存储MySQL中的true/false信息? 特别是在使用PHP脚本编写和阅读时。 随着时间的推移,我使用并看到了几种方法: tinyint, varchar fields containing the values 0/1, varchar fields containing the strings '0'/'1' or 'true'/'false' and finally enum Fields containing the two options 'true'/'false'. 没有一个看起来是最优的,我更喜欢tinyint 0/1 variant ,因为PHP中的自动类型转换给了我相当简

How can I add a Boolean field to MySQL?

It seems I should use tinyint(); but I don't know how to implement it? The question is what is your recommendation if I need to have a boolean field in MySQL DB and modify it´s value with PHP Yep, TINYINT(1) is the way to go... you can also use BOOL or BOOLEAN which are synonyms (so it does not make a difference). 0 evaluates to false in PHP and 1 to true (actually, any other number th

我如何添加一个布尔字段到MySQL?

看来我应该使用tinyint(); 但我不知道如何实现它? 问题是如果我需要在MySQL DB中有一个布尔字段并用PHP修改它的值,那么你的建议是什么 是的, TINYINT(1)是要走的路...你也可以使用BOOL或BOOLEAN ,它们是同义词(所以它没有区别)。 0在PHP中评估为false , 1为true (实际上,除0之外的任何其他数字评估为true ,但通常使用1 )。 我更喜欢bool,BIT,TINYINT(1)。 因为它们中没有一个实际是布尔值。 您可以