从 PHP 获取内容:POST 和查询出现问题

发布于 2024-08-27 22:14:15 字数 1717 浏览 8 评论 0原文

为我有史以来最长的问题道歉。我正在尝试与 ROOT 中的 mysql 数据库的 php 前端进行交互(C++ 中的 CERN 框架,用于高能物理分析)。首先,我尝试让这个 php 界面与 wgetcurl 很好地配合,因为我对它们更熟悉。以下命令有效:

wget --post-data "hostname=localhost:3306&un=joeuser&pw=psswd&myquery=show_spazio_databases;" http://some.host.edu/log/log_query_matlab.php

结果是:

database1

database2

很好。如果我省略 --post-data 那么我会得到结果:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admin'@'localhost' (using password: NO) in /log/log_query_matlab.php on line 6
i'm dead! Access denied for user 'admin'@'localhost' (using password: NO) 
Warning: mysql_query() [function.mysql-query]: Access denied for user 'admin'@'localhost' (using password: NO) in /log/log_query_matlab.php on line 29

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /log/log_query_matlab.php on line 29

我可以访问 php 脚本(只读),但错误本身并不是太重要。重要的是使用 ROOT,我使用一个名为 socket.SendRaw(message, message.Length()) 的函数(套接字是一个 TSocket),这给了我如果我的“消息”是,则与 wget 相同的“错误”,没有后数据开关

"POST http://some.host.edu/log/log_query_matlab.php?hostname=localhost:3306&un=joeuser&pw=psswd&myquery=show_spazio_databases"

这可能是徒劳的,但是有人知道我应该格式化包含相当于以下内容的“消息”的方法吗--post-data 开关。或者,是否有一种标准方法可以在一行中格式化 POST 请求(我见过 multi -行的东西。是吗?)抱歉我一无所知!

附言。 mysql 查询是 showdatabase,但空格已替换为 _spazio_(意大利语中的空格)。 db 和 php 接口的作者需要它(以及符号的各种替换),但是以前有人见过这个吗?试图解决这个问题太糟糕了!

Apologies for my longest question on SO ever. I'm trying to interface with a php frontend for a mysql database in ROOT (a CERN framework in C++ for high energy physics analysis). To start off with, I tried to get this php interface to play nice with wget and curl first because I'm more familiar with them. The following command works:

wget --post-data "hostname=localhost:3306&un=joeuser&pw=psswd&myquery=show_spazio_databases;" http://some.host.edu/log/log_query_matlab.php

The results are:

database1

database2

That's good. If I leave out the --post-data then I get the result:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admin'@'localhost' (using password: NO) in /log/log_query_matlab.php on line 6
i'm dead! Access denied for user 'admin'@'localhost' (using password: NO) 
Warning: mysql_query() [function.mysql-query]: Access denied for user 'admin'@'localhost' (using password: NO) in /log/log_query_matlab.php on line 29

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /log/log_query_matlab.php on line 29

I have access to the php script (read only), but the error itself isn't too important. What matters it that using ROOT, I use a function called as socket.SendRaw(message, message.Length()) (socket is a TSocket) and this gives me the same "error" as wget without the post data switch if my "message" is

"POST http://some.host.edu/log/log_query_matlab.php?hostname=localhost:3306&un=joeuser&pw=psswd&myquery=show_spazio_databases"

This may be in vain, but does someone knows a way I should format the "message" that includes something that is equivalent to the --post-data switch. Or, is there a standard way to format POST requests in a single line (I've seen multi-line stuff. Is that right?) Sorry I'm clueless!

PS. The mysql query is show databases but the space has been replaced with _spazio_, Italian for space. The author of the db and php interface requires it (and various replacements for symbols), but has anyone seen this before? Trying to troubleshoot that was terrible!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人间不值得 2024-09-03 22:14:15

正确的“单行”(必须是多行)是:

POST http://some.host.edu/log/log_query_matlab.php HTTP/1.1
Host: some.host.edu
Content-Type: application/x-www-form-urlencoded
Content-Length: 73

hostname=localhost:3306&un=joeuser&pw=psswd&myquery=show databases

每行的末尾都有 \r\n。内容长度之后的间隙有两组。

The correct "one liner" (had to be multiline) was:

POST http://some.host.edu/log/log_query_matlab.php HTTP/1.1
Host: some.host.edu
Content-Type: application/x-www-form-urlencoded
Content-Length: 73

hostname=localhost:3306&un=joeuser&pw=psswd&myquery=show databases

The end of each line has \r\n. The gap after content-length has two sets of those.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文