将 php 数据获取到命令行提示符

发布于 2024-11-30 17:59:17 字数 647 浏览 0 评论 0原文

服务器上的 PHP 应用程序正在将某个具有序列号的文档保存到 MySQL 数据库中。如何获取启动本地文档扫描仪的命令行提示符的序列号?

例如:

c:\myscan Ask_for_current_seq_nmbr.pdf

myscan 是用 c 编写的,负责处理 PC 的事情。仅文件名未知。

一些代码(来自查询 PHP 文件)

$query = "SELECT last_seq FROM seq_table WHERE cat = 1";

$result = mysql_query($query, $link) or die('ERROR: '. mysql_error().'<br />ON LINE: '.__LINE__);

while($row = mysql_fetch_assoc($result)) {
    echo $row['last_seq'];
}

!!!笔记 !!! 我正在从远程服务器获取页面。前任。 www.site.com/query.php?q=SELECT * FROM... 该选择会产生我想在命令提示符中使用的最后使用的序列号。

!!更新 !!

我们必须检查远程服务器上的 PHP 文件,以避免使用必须在 IP 基础上启用的远程 MySQL。

A PHP application on the server is saving a certain document with a sequential number into a MySQL database. How to obtaion that sequential number to a command line prompt that initiates the local doocument scanner?

ex:

c:\myscan ask_for_current_seq_nmbr.pdf

myscan is something written in c that takes care of the PC stuff. Only the name of file is unknown.

Some code (from the query PHP file)

$query = "SELECT last_seq FROM seq_table WHERE cat = 1";

$result = mysql_query($query, $link) or die('ERROR: '. mysql_error().'<br />ON LINE: '.__LINE__);

while($row = mysql_fetch_assoc($result)) {
    echo $row['last_seq'];
}

!!! NOTE !!!
I am fetching a page from a remote server. ex. www.site.com/query.php?q=SELECT * FROM...
And that selection results in the last used sequential number which I would like to use in my command prompt.

!! UPDATE !!

We HAVE to go through a PHP file on the remote server to avoid having to use Remoote MySQL which has to be enabled on an IP basis.

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

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

发布评论

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

评论(3

誰認得朕 2024-12-07 17:59:17

您可以从 中使用 PHP 的各种函数调用在命令行上运行的进程exec 系列文档

如果您在构建实际的命令字符串时遇到问题,您可以这样做:

$cmd = sprintf('c:\myscan %d.pdf', $sequential_number);

当您编写脚本时,它已经使用 $sequential_number 将其写入数据库,我假设您已经拥有它。

如果数据库生成该数字,则可能作为主键。请参阅 mysql_insert_id文档< /em> 用于获取 id。

You can call processes that run on the commandline with various function from PHP from the exec familyDocs.

If you're having problems building the actual command string, you can do with:

$cmd = sprintf('c:\myscan %d.pdf', $sequential_number);

As you write that the script is already writing it into the db with the $sequential_number I assume you have it already.

In case the database generates the number, then probably as the primary key. See mysql_insert_idDocs for obtaining the id.

[浮城] 2024-12-07 17:59:17

好的,从反斜杠和 C:\ 判断,我猜你正在使用 Windows。

您必须结合以下内容:

http://dev。 mysql.com/doc/refman/5.5/en/mysql.html

如何存储使用 bat 脚本在变量中获取命令表达式的结果?

,然后使用 %VARIABLE_NAME% 语法访问您创建的变量的内容。

Okay judging by the backslash and the C:\ I am guess you're using windows.

You are going to have to combine the following:

http://dev.mysql.com/doc/refman/5.5/en/mysql.html

How to store the result of a command expression in a variable using bat scripts?

and then to access the content of the variable you created use the %VARIABLE_NAME% syntax.

蓝海似她心 2024-12-07 17:59:17

您的 mysql 表中应该有标志,例如 is_processed,其值 = 0 或 1。
当扫描开始时,它会运行查询:

SELECT * FROM TABLE where is_processed = 0 order by sec_number

处理后,您应该运行查询:

UPDATE TABLE set is_processed = 1 where sec_number = 'sec_processed_number';

You should have flag in your mysql table like is_processed with value = 0 or 1.
When scan starts it runs query:

SELECT * FROM TABLE where is_processed = 0 order by sec_number

After processing you should run query:

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