acunaara
asked on
How run a query in command prompt to get results from a PHP web server??
I have a web site in PHP and i want to query it but through command prompt.
This site shows me all the content in DB related to a keyword that i want to look for.
What query can i execute?
This site shows me all the content in DB related to a keyword that i want to look for.
What query can i execute?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just bear in mind that running a PHP page from the command line might not function as expected due to dependence on server pre-processing ($_GET, $_POST, $_SERVER, $_COOKIES etc)
Things like that are always true. Here is a simple PHP program that runs both on the web server and the command line.
<?php
//
/// DB configuration for 'dibsiam03'
$dbhost = "10.10.10.10"; // Your database server
$dbuser = "username"; // Your db username
$dbpass = "password"; // Your db password
$dbname = "database name"; // Your database name
$dbtable = "tablename"; // tablename
$dbh = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
$dbsel = mysql_select_db($dbname) or die(mysql_error());
echo $dbh." :: ".$dbsel."<br>";
$sql = "SELECT * FROM $dbtable LIMIT 4";
$res = mysql_query($sql);
if (!$res) print "<option>mysql_query failed, ".mysql_error()."</option>";
//$row = mysql_fetch_array($res);
while ($row = mysql_fetch_array($res, MYSQL_NUM)) {
echo '<table><tr>';
echo '<td>'.$row[0]."</td>\r\n";
echo '<td>'.$row[1]."</td>\r\n";
echo '<td>'.$row[2]."</td>\r\n";
echo '<td>'.$row[3]."</td>\r\n";
echo '<td>'.$row[4]."</td>\r\n";
echo '<td>'.$row[5]."</td>\r\n";
echo '<td>'.$row[6]."</td>\r\n";
echo '</tr></table>';
}
?>
ASKER
Dave.. I am using a client computer so, i cannot execute that command in the server directly since my only access is a web page, this is because of permissions.
Because of that i am trying to use the command prompt in order to make several queries with different keywords and the only output for each query is YES or NO.
Because of that i am trying to use the command prompt in order to make several queries with different keywords and the only output for each query is YES or NO.
As I said, I ran that PHP program on the command line to get data from a different computer. If PHP is installed on the client computer you can run it or one modified for your needs on the client to get info from the server. But I think if the only output is YES or NO then you are talking about accessing a PHP program on a web server. The basic idea is no different.
ASKER
I've requested that this question be deleted for the following reason:
No valid answers
No valid answers
Please advise as to why none of the answers provided were valid? There were many suggestions that were valid in terms of querying a website from a command prompt?
Answers were provided that in the context of the question are valid. Asker has not provided any details on why the posted solutions are not suitable.
Powershell example
powershell -command "& { iwr http://www.yourwebserver.com/somepage.html -OutFile savedpage.txt }"
Bitsadmin has been deprecated in favour of PS - but you can google it if you need examples.