1

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.

3
  • Does $row['last_seq'] contains what you're looking for? Commented Aug 22, 2011 at 20:11
  • Yes. It does contain what I am looking for. Commented Aug 22, 2011 at 20:14
  • I am now doing this via URLProtocol Commented Jun 6, 2012 at 15:18

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

Very good, very good. But we have to go through a PHP file on the server to avoid using remote MySQL.
0

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';

1 Comment

I am not sure how this relates to what I am trying to do. The trick is to obtain the last used seq number to the command line on the pc.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.