Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Using PHP from the command line

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Using PHP from the command line

Postby Ace » Sun Oct 27, 2002 1:24 pm

Hey,

First, sorry, posted in Errors before, but I thought that this might be a better place to post in...

This is how it is...
I do add.php?name=something in the browser, and all works as it should (adding the something to mysql database). However, I cant make it work from the command line! According to the php manual site which says:
"To hand over the GET-variables in interactive mode like in HTTP-Mode (e.g. your URI is myprog.html?hugo=bla&bla=hugo), you have to call

php myprog.html '&hugo=bla&bla=hugo'
(two & instead of ? and &!)

There just a little difference in the $ARGC, $ARGV values, but I think this is in those cases not relevant."
it should be: php.exe add.php '&name=something', but its not working! I get the error Error: name not set. name is not a intern commando, extern commando, program or commandofile.) So, it seems that it's not GETTING any value by doing that add.php '&name=something' thingy...

Here is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text-html; charset=Windows-1252">
</HEAD>
<BODY>
<?
include('datastore.inc.php');
if (!isset($name)) {
echo "<B>Error: name not set.</B>";
exit;
}
$name = addslashes(trim($name));
$time = time();
$query = "INSERT INTO `names` VALUES ('', '$name', '$time')";
$result = mysql_query($query);
?>
</BODY>
</HTML>

Some that can tell whats wrong?

Thanx,
Ace
Ace
New php-forum User
New php-forum User
 
Posts: 9
Joined: Sun Oct 27, 2002 7:28 am

Re: Using PHP from the command line

Postby Dmitrit Plakhotnik » Fri Nov 01, 2002 7:04 am

Ace wrote:Hey,

First, sorry, posted in Errors before, but I thought that this might be a better place to post in...

This is how it is...
I do add.php?name=something in the browser, and all works as it should (adding the something to mysql database). However, I cant make it work from the command line! According to the php manual site which says:
"To hand over the GET-variables in interactive mode like in HTTP-Mode (e.g. your URI is myprog.html?hugo=bla&bla=hugo), you have to call

php myprog.html '&hugo=bla&bla=hugo'
(two & instead of ? and &!)

There just a little difference in the $ARGC, $ARGV values, but I think this is in those cases not relevant."
it should be: php.exe add.php '&name=something', but its not working! I get the error Error: name not set. name is not a intern commando, extern commando, program or commandofile.) So, it seems that it's not GETTING any value by doing that add.php '&name=something' thingy...

Here is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text-html; charset=Windows-1252">
</HEAD>
<BODY>
<?
include('datastore.inc.php');
if (!isset($name)) {
echo "<B>Error: name not set.</B>";
exit;
}
$name = addslashes(trim($name));
$time = time();
$query = "INSERT INTO `names` VALUES ('', '$name', '$time')";
$result = mysql_query($query);
?>
</BODY>
</HTML>

Some that can tell whats wrong?

Thanx,
Ace




It's very simlpe use in command line double quotes, it's work.
Example: php.exe -f add.php "?name=aaa"

--
Sincerely,
Dmitriy S. Plakhotnik
AlarIT programmer
http://www.AlarIT.com
Dmitrit Plakhotnik
New php-forum User
New php-forum User
 
Posts: 13
Joined: Fri Nov 01, 2002 6:56 am


Return to PHP coding => General

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.