Html html5和mysql之间的直接连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10023087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
direct connectivity between html5 and mysql
提问by Naina
I am a newbie on HTML5. I know this is a silly question but I heard about the connectivity between mysql and html5 using php. but can we do direct connectivity between both without php? If yes, please guide me with your suggestions and the tutorials.
我是 HTML5 的新手。我知道这是一个愚蠢的问题,但我听说过使用 php 的 mysql 和 html5 之间的连接。但是我们可以在没有 php 的情况下直接连接两者吗?如果是,请用您的建议和教程指导我。
采纳答案by codef0rmer
Alone HTML wont let you connect to mysql DB. But yes, the server side javascript can help you to achieve what you are trying to do. There are node.js modules available to connect and query mysql DB. You have to install node.js and then you can write the backend in Javascript.
单独的 HTML 不会让您连接到 mysql DB。但是是的,服务器端 javascript 可以帮助您实现您想要做的事情。有 node.js 模块可用于连接和查询 mysql DB。您必须安装 node.js,然后才能用 Javascript 编写后端。
回答by jwir3
Well, you wouldn't be able to connect to it directly with html5, as it runs client-side. This means that the code for html5 (most likely some form of javascript) will run on the client, but your mysql system is on another server. Normally, you don't directly open up access to a database to the web (security reasons).
好吧,您将无法使用 html5 直接连接到它,因为它在客户端运行。这意味着 html5 的代码(很可能是某种形式的 javascript)将在客户端上运行,但您的 mysql 系统在另一台服务器上。通常,您不会直接打开对 Web 数据库的访问(安全原因)。
On the other hand, as other posters have mentioned, you can run javascript server-side. I'm not sure why you would want to do this, though, when php is probably a more powerful and better suited tool for this type of operation.
另一方面,正如其他海报所提到的,您可以运行 javascript 服务器端。不过,我不确定您为什么要这样做,因为 php 可能是更强大、更适合此类操作的工具。
You can do it with php, though, as you mentioned. Check out http://us3.php.net/manual/en/function.mysql-connect.php
不过,正如您所提到的,您可以使用 php 来完成。查看http://us3.php.net/manual/en/function.mysql-connect.php