将 php 数据获取到命令行提示符
服务器上的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以从
中使用 PHP 的各种函数调用在命令行上运行的进程exec
系列文档。如果您在构建实际的命令字符串时遇到问题,您可以这样做:
当您编写脚本时,它已经使用
$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:
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_id
Docs for obtaining the id.好的,从反斜杠和 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.
您的 mysql 表中应该有标志,例如 is_processed,其值 = 0 或 1。
当扫描开始时,它会运行查询:
处理后,您应该运行查询:
You should have flag in your mysql table like is_processed with value = 0 or 1.
When scan starts it runs query:
After processing you should run query: