简体   繁体   English

MySQL查询中的不可见字符

[英]Invisible characters in MySQL query

At the last few days anytime when I am writing a query, it is not working. 在我编写查询的最后几天,它无法正常工作。

But as soon as I replace the full query with one from my old files and change the necessary variables, it is working.. They are totally the same. 但是,一旦我用旧文件中的一个替换了完整查询并更改了必要的变量,它便开始工作。它们完全一样。 Maybe these are invisible characters but always when i am writing? 也许这些是看不见的字符,但总是在我写作时? how can I prevent this? 我该如何预防呢? I am not writing sample code, because any mysql_query("SELECT... and while($... I am writing by my own is not working. 我没有编写示例代码,因为我自己编写的任何mysql_query("SELECT... and while($...

(by the way I am using OSX if it is matters) (顺便说一下,我正在使用OSX)

PS: I heard that mysql_query is not the good way, but I will improve myself. PS:听说mysql_query不是一个好方法,但是我会改善自己的。

Example code: 示例代码:

$users_query = mysql_query("SELECT * FROM users WHERE id = '$_SESSION[user_id]'");
while($users = mysql_fetch_array($users_query))
  {
$id         = $users['id'];
$username   = $users['username'];
}

This wasn't working. 这没用。 After I overwrote this with my older query and changed the names, everything started to work, but the final result looks the exact same, with the same amount of characters.:( 在用较旧的查询改写了这个名称并更改了名称后,所有内容开始起作用,但是最终结果看起来完全相同,但字符数相同。:(

UPDATE::: Now I know that invisible character causing the problem, (picture is not attached due to lack of reputation) but how can I prevent this? UPDATE :::现在,我知道导致该问题的不可见字符(由于缺乏声望而未附上图片),但是如何防止这种情况发生呢? Few weeks ago this wasn't a problem. 几周前这不是问题。

I have seen this issue when copying files from Windows into Mac OS. 从Windows将文件复制到Mac OS时,我已经看到此问题。 you open the file in Vi/Vim and do :set list to make vi show invisible extra characters and remove them. 您可以在Vi / Vim中打开文件并执行:set list以使vi显示不可见的多余字符并将其删除。

Sorry everybody but at the same time, thanks for helps. 对不起大家,但同时,感谢您的帮助。 The problem caused by a character which is inserted by pressing the ALT and SPACE at the same time. 由同时按下ALT和SPACE插入的字符引起的问题。 for making a * in the query you need to press ALT+Shift+?(Question mark) together if you are using OSX. 如果在使用OSX时要在查询中输入*,则需要同时按ALT + Shift +?(问号)。 Fast typing made me not to release the ALT in the right time. 快速输入使我不能在正确的时间发布ALT。 Thank You, for everybody. 谢谢大家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM