Re: [PHP] mail command failing

2010-06-29 Thread Ashley Sheridan
On Tue, 2010-06-29 at 10:00 -0700, Mike Wright wrote:

 Hi all,
 
 I'm very puzzled by this.  I've been using the php mail command for 
 years but now I can't get it to work and can't figure out how to 
 diagnose the problem.
 
 The code below was copied from the manual (addresses changed, etc); 
 php.ini has safe_mode off; binary is at /usr/sbin/sendmail.
 
 ?php
 ini_set(SMTP,localhost );
 ini_set('sendmail_from', 'mike.wri...@mailinator.com');
 
 $name = Mike Wright; //senders name
 $email = mike.wri...@mailinator.com; //senders e-mail adress
 $recipient = mike.wri...@mailinator.com; //recipient
 $body = The text for the mail...; //mail body
 $subject = Subject for review; //subject
 $header = From: $name $email\r\n; //optional headerfields
 
 $echo = mail($recipient, $subject, $body, $header) ? 'success':'fail';
 echo br/br/$echo;
 
 I can access the mail server with /usr/bin/mailx and by telnet 
 localhost 25.  I can also send mail using php by using 'exec ( echo 
 $body | mailx -s $subject $recipient)'.
 
 php-5.2.29 on fedora10 with apache 2.2.14.  Can this be selinux related?
 
 Any ideas or troubleshooting tips?
 
 Thanks,
 Mike Wright
 


The first ini_set variable you're setting I believe will only work for a
Windows server.

Aside from that, yes SELinux does prevent the mail command from sending
mail by default. I'm using Fedora 11, so I assume it will be similar;
there are config tools for setting SELinux policies, or you could even
turn it off (not advised on a live server). As a test, try turning it
off temporarily just to see if it is the culprit, then you can determine
what policy changes need to be made.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] mail command failing

2010-06-29 Thread Mike Wright

Ashley Sheridan wrote:

On Tue, 2010-06-29 at 10:00 -0700, Mike Wright wrote:


Hi all,

I'm very puzzled by this.  I've been using the php mail command for 
years but now I can't get it to work and can't figure out how to 
diagnose the problem.



php-5.2.29 on fedora10 with apache 2.2.14.  Can this be selinux related?



The first ini_set variable you're setting I believe will only work for a
Windows server.

Aside from that, yes SELinux does prevent the mail command from sending
mail by default. I'm using Fedora 11, so I assume it will be similar;
there are config tools for setting SELinux policies, or you could even
turn it off (not advised on a live server). As a test, try turning it
off temporarily just to see if it is the culprit, then you can determine
what policy changes need to be made.



Thanks, Ash, but no cigar.  Selinux is set disabled.  Absolutely baffled 
and confounded that there doesn't seem to be a way to diagnose the problem.


Mike

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] mail command failing

2010-06-29 Thread Bob McConnell
From: Ashley Sheridan

 On Tue, 2010-06-29 at 10:00 -0700, Mike Wright wrote:
 
 Hi all,
 
 I'm very puzzled by this.  I've been using the php mail command for 
 years but now I can't get it to work and can't figure out how to 
 diagnose the problem.
 
 The code below was copied from the manual (addresses changed, etc); 
 php.ini has safe_mode off; binary is at /usr/sbin/sendmail.
 
 ?php
 ini_set(SMTP,localhost );
 ini_set('sendmail_from', 'mike.wri...@mailinator.com');
 
 $name = Mike Wright; //senders name
 $email = mike.wri...@mailinator.com; //senders e-mail adress
 $recipient = mike.wri...@mailinator.com; //recipient
 $body = The text for the mail...; //mail body
 $subject = Subject for review; //subject
 $header = From: $name $email\r\n; //optional headerfields
 
 $echo = mail($recipient, $subject, $body, $header) ?
'success':'fail';
 echo br/br/$echo;
 
 I can access the mail server with /usr/bin/mailx and by telnet 
 localhost 25.  I can also send mail using php by using 'exec (
echo 
 $body | mailx -s $subject $recipient)'.
 
 php-5.2.29 on fedora10 with apache 2.2.14.  Can this be selinux
related?
 
 Any ideas or troubleshooting tips?
 
 
 The first ini_set variable you're setting I believe will
 only work for a Windows server.
 
 Aside from that, yes SELinux does prevent the mail command from
sending
 mail by default. I'm using Fedora 11, so I assume it will be similar;
 there are config tools for setting SELinux policies, or you could even
 turn it off (not advised on a live server). As a test, try turning it
 off temporarily just to see if it is the culprit, then you can
determine
 what policy changes need to be made.

Don't turn it off, set it for Permissive mode. It will both allow the
connection and log why it wouldn't allow it in normal operation. Then
you can review the logs and make the necessary adjustments.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mail command failing

2010-06-29 Thread Ashley Sheridan
On Tue, 2010-06-29 at 10:27 -0700, Mike Wright wrote:

 Ashley Sheridan wrote:
  On Tue, 2010-06-29 at 10:00 -0700, Mike Wright wrote:
  
  Hi all,
 
  I'm very puzzled by this.  I've been using the php mail command for 
  years but now I can't get it to work and can't figure out how to 
  diagnose the problem.
 
 
  php-5.2.29 on fedora10 with apache 2.2.14.  Can this be selinux related?
 
  
  The first ini_set variable you're setting I believe will only work for a
  Windows server.
  
  Aside from that, yes SELinux does prevent the mail command from sending
  mail by default. I'm using Fedora 11, so I assume it will be similar;
  there are config tools for setting SELinux policies, or you could even
  turn it off (not advised on a live server). As a test, try turning it
  off temporarily just to see if it is the culprit, then you can determine
  what policy changes need to be made.
  
 
 Thanks, Ash, but no cigar.  Selinux is set disabled.  Absolutely baffled 
 and confounded that there doesn't seem to be a way to diagnose the problem.
 
 Mike
 


I can only guess that PHP somehow isn't seeing the sendmail program for
some reason. Have you compared the output of a phpinfo() call on this
system and another where it is working to see if there are any obvious
differences in the server setups?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Mail Command Body Issue - Trying to use 'do while' loop

2009-09-12 Thread c...@hosting4days.com


On Sep 12, 2009, at 3:47 PM, c...@hosting4days.com wrote:

I'm having a problem with  mail body issue trying to use 'do while'  
loop in the $mail_body var.


this line:
do { echo $row_get1['name'] } while ($row_get1 = mysql_fetch_assoc 
($get1))


will show ok when it's on the page elsewhere (not in the $mail_body  
var) but typed like:


--- ok on web page (not email)
?php do {
echo $row_get1['vt_name']; } while ($row_get1 = mysql_fetch_assoc 
($get1)); ?


Q: i want TEXT LOOP TEXT - AM I MISSING some syntax characters  
like(; or??) somewhere or 


THANKS for your help - dave



I got it working like this

?php

$loop1 = '';

do {
$loop1 = $loop1.\n.$row_get1['vt_name'].' - ';
} while ($row_get1 = mysql_fetch_assoc($get1));



$mail_body = test \n\n.test2 .$loop1.Thanks
test xxx;  ?


Q: is this the best way?





- full email code 

?php
$mail_body = test \n\n.test2.do { echo 'test' } while  
($row_get1 = mysql_fetch_assoc($get1)).Thanks

test xxx;  ?

?php
$Name = test; //senders name
$email = t...@test.com; //senders e-mail adress
$recipientname = t...@test.com;
$recipient = t...@test.com; //recipient
$subject = test.
$header = From: . $Name .   . $email . \r\n; //optional  
headerfields

$fullto = $recipientname .   . $recipient . ;
//$fullto = $recipientname .   . $recipient . ., .$recip2;
ini_set('sendmail_from', 't...@test.com');

mail($fullto, $subject, $mail_body, $header); //mail command :)
?



Thanks,
c...@hosting4days.com






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





Thanks,
c...@hosting4days.com






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Execute command line as a different user

2008-07-07 Thread Daniel Brown
On Tue, Jul 1, 2008 at 1:17 PM, Matt palermo [EMAIL PROTECTED] wrote:
 My PHP is running as a user with limited rights.  I'd like to execute a
 command line as a different user.  I'm trying to delete a file and the PHP
 user doesn't have access to do this.  I know the username and password for
 the admin user that has rights to delete a file.  Is there a command I can
 use to make PHP run a delete command as the admin user?  If so, how can I do
 this?

You can always create a script and have crond handle it running as
the admin user, if you're on *NIX.  Otherwise, check into the Winblows
command `AT`.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Execute command line as a different user

2008-07-01 Thread Dan Joseph
On Tue, Jul 1, 2008 at 1:17 PM, Matt palermo [EMAIL PROTECTED] wrote:

 My PHP is running as a user with limited rights.  I'd like to execute a
 command line as a different user.  I'm trying to delete a file and the PHP
 user doesn't have access to do this.  I know the username and password for
 the admin user that has rights to delete a file.  Is there a command I can
 use to make PHP run a delete command as the admin user?  If so, how can I do
 this?

 Thanks,

 Matt

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


I did a quick check on php.net, there is a post on there that talks about
using sudo:


@exec(echo 'apache' | /usr/bin/sudo -u mail -S /var/www/html/mailset.sh
$name);

You may want to read thru it, php.net/exec, go to the user notes.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


Re: [PHP] Execute command from web browser

2008-05-04 Thread Craige Leeder
Well, you're missing a semi-colin after the exec() statement, and the echo.

If it wasn't the syntax error, make sure the program exists with file_exists();

- Craige

On Sat, May 3, 2008 at 11:28 PM,  [EMAIL PROTECTED] wrote:

  Hi all


  I try write a code to execute service in my server from web browser

  I write next

  /var/www/html/squidup.html
  ?
  exec ('/usr/bin/squid/sbin/squid')
  echo Squid UP
  ?

  but, don't work from web browser.

  What is wrong

  Thanks,

  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Execute command from web browser

2008-05-03 Thread Casey
On 5/3/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

  Hi all


  I try write a code to execute service in my server from web browser

  I write next

  /var/www/html/squidup.html
Should it be... squidup.php?
  ?
  exec ('/usr/bin/squid/sbin/squid')
  echo Squid UP
  ?

  but, don't work from web browser.

  What is wrong

  Thanks,


  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php




-- 
-Casey

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] simple command help

2008-03-01 Thread Shelley

Daniel Brown wrote:

On Fri, Feb 29, 2008 at 5:22 AM, Shelley [EMAIL PROTECTED] wrote:
  

Hi all,

 What's the command to use if I want to remove all the directories and
 files except 'a.gz' under a directory?



There isn't a command in PHP to do this.  You'd have to write a
script to handle that processing.

If you're looking for general Unix/Linux commands, you're in the
wrong place, but here's one possible way to do it:

sudo chattr +i /path/to/a.gz
rm -fR /path
sudo chattr -i /path/to/a.gz

If you have sudo access (or straight root access, in which case
you can su - to root and skip the 'sudo' part of the command), that
will set the file attribute to immutable, which means no one -
including root or the system itself - can modify or delete that file
unless they have the CAP_LINUX_IMMUTABLE capability (such as root) and
issue the 'chattr -i filename' command.

  

That's what I wanted. Thanks.
I have full priviledge of the directory.

--
Cheers,
Shelley

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] simple command help

2008-02-29 Thread Richard Heyes
What's the command to use if I want to remove all the directories and 
files except 'a.gz' under a directory?


There isn't one. If you're using *nix, you could try this:

exec('find ! -name a.gz -maxdepth 1 -exec rm -rf {} \;');

Or something like that. If you're on Windows you'll need someone else... :-)

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] simple command help

2008-02-29 Thread Daniel Brown
On Fri, Feb 29, 2008 at 5:22 AM, Shelley [EMAIL PROTECTED] wrote:
 Hi all,

  What's the command to use if I want to remove all the directories and
  files except 'a.gz' under a directory?

There isn't a command in PHP to do this.  You'd have to write a
script to handle that processing.

If you're looking for general Unix/Linux commands, you're in the
wrong place, but here's one possible way to do it:

sudo chattr +i /path/to/a.gz
rm -fR /path
sudo chattr -i /path/to/a.gz

If you have sudo access (or straight root access, in which case
you can su - to root and skip the 'sudo' part of the command), that
will set the file attribute to immutable, which means no one -
including root or the system itself - can modify or delete that file
unless they have the CAP_LINUX_IMMUTABLE capability (such as root) and
issue the 'chattr -i filename' command.

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] system command runs application, but application doesn't work correctly

2008-01-16 Thread Daniel Brown
On Jan 16, 2008 7:56 PM, Apple [EMAIL PROTECTED] wrote:
 Hello,

 I'm trying to run mencoder command line utility to encode videos.

 When I use these two command in terminal (through SSH), everything works fine.
 But when I run them from PHP script with system command, it doesn't work.
[snip]

Try replacing system() with die() and letting it print out the
information full command string.  That may give you an idea of a
variable that's either incorrect or undefined.  If you copy and paste
it and run the command from the command line and it works, then it may
be permissions issues.

One part of the snipped content that I noticed kept repeating is
the following (and actually ending with this line):
'VDecoder init failed :( Read DOCS/HTML/en/codecs.html'

Did you follow the advice and read that document?

Beyond that, it's a question that should probably instead be asked
on a mencoder mailing list, since PHP's system() function is working
correctly, but apparently isn't getting the information it needs to
pass stuff back-and-forth with the system.

-- 
/Dan

Daniel P. Brown
Senior Unix Geek and #1 Rated Year's Coolest Guy By Self Since
Nineteen-Seventy-[mumble].

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] system command

2007-10-27 Thread Instruct ICC

 Maybe something to do with the last line (but I get several lines)
 Return Values

 Returns the last line of the command output on success, and FALSE on failure.



 I have within a web page:
  $a=system('/usr/bin/lynx -dump http://api.hostip.info/country.php?ip='.$aa);
 ?
  .

 later I pickup the variable $a again ...

 The problem for me is that the line $a=system('/usr/bin/lynx -dump
 http://api.hostip.info/country.php?ip='.$aa); prints (before ) the
 result ($a). I need the variable within the program, but do not want to
 display it. It seems that 'system' includes an 'echo'

I always go back to the manual:
http://php.net/system
Maybe that built-in echo is related to this:
The system() call also tries to automatically flush the web server's output 
buffer after each line of output if PHP is running as a server module.

Check out the other Program Execution Functions functions http://php.net/exec 
particularly http://php.net/manual/en/function.exec.php

_
Peek-a-boo FREE Tricks  Treats for You!
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] system command

2007-10-26 Thread Instruct ICC

 Use double quotes to get the value of $a or else you get the literal string 
 $a.

 $aa=system(lynx -dump http://api.hostip.info/country.php?ip=$a,$location);
 or
 $aa=system('lynx -dump http://api.hostip.info/country.php?ip='.$a,$location);


 Thanks! 1st solution did not work for me, but the second one did.

 I still have a problem with it. It prints the info to the page. Can I
 suppress this somehow?

man lynx
?

I don't use lynx and I don't know what you mean by info to the page.
I tried
lynx -dump http://www.google.com
to try to see what you mean.

Maybe something to do with the last line (but I get several lines)
Return Values

Returns the last line of the command output on success, and FALSE on failure.

Sorry.

_
Climb to the top of the charts!  Play Star Shuffle:  the word scramble 
challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] system command

2007-10-26 Thread Ronald Wiplinger

Instruct ICC wrote:

Use double quotes to get the value of $a or else you get the literal string 
$a.

$aa=system(lynx -dump http://api.hostip.info/country.php?ip=$a,$location);
or
$aa=system('lynx -dump http://api.hostip.info/country.php?ip='.$a,$location);


  

Thanks! 1st solution did not work for me, but the second one did.

I still have a problem with it. It prints the info to the page. Can I
suppress this somehow?



man lynx
?

I don't use lynx and I don't know what you mean by info to the page.
I tried
lynx -dump http://www.google.com
to try to see what you mean.

Maybe something to do with the last line (but I get several lines)
Return Values

Returns the last line of the command output on success, and FALSE on failure.

  


I have within a web page:
?php
$a=system('/usr/bin/lynx -dump http://api.hostip.info/country.php?ip='.$aa);
?
H1 .

later I pickup the variable $a again ...

The problem for me is that the line $a=system('/usr/bin/lynx -dump 
http://api.hostip.info/country.php?ip='.$aa);  prints (before H1) the 
result ($a). I need the variable within the program, but do not want to 
display it. It seems that 'system' includes an 'echo'


bye

Ronald

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] system command

2007-10-25 Thread Ronald Wiplinger

Instruct ICC wrote:


  

Date: Thu, 25 Oct 2007 09:43:14 +0800
From: [EMAIL PROTECTED]
To: php-general@lists.php.net
Subject: [PHP] system command

I tried:

$a=$_SERVER[REMOTE_ADDR];
echo pREMOTE_ADDR=$abr;
if($a=192.168.250.108) {
$a=61.64.101.101;
}


$aa=system('lynx -dump http://api.hostip.info/country.php?ip=$a',$location);
echo pa=$abraa=$aabrlocation=$locationbr;

$aa=system('lynx -dump 
http://api.hostip.info/country.php?ip=61.64.101.101',$location);

echo pa=$abraa=$aabrlocation=$locationbr;


I get:

REMOTE_ADDR=192.168.250.108
XX

a=61.64.101.101
aa=XX
location=0
TW

a=61.64.101.101
aa=TW
location=0


as you can see, if I put the IP address in, I get the right answer (TW).

What am I doing wrong?

bye

Ronald


Use double quotes to get the value of $a or else you get the literal string 
$a.

$aa=system(lynx -dump http://api.hostip.info/country.php?ip=$a,$location);
or
$aa=system('lynx -dump http://api.hostip.info/country.php?ip='.$a,$location);

  

Thanks! 1st solution did not work for me, but the second one did.

I still have a problem with it. It prints the info to the page. Can I 
suppress this somehow?


bye

Ronald

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] system command

2007-10-24 Thread Instruct ICC



 Date: Thu, 25 Oct 2007 09:43:14 +0800
 From: [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Subject: [PHP] system command
 
 I tried:
 
 $a=$_SERVER[REMOTE_ADDR];
 echo pREMOTE_ADDR=$abr;
 if($a=192.168.250.108) {
 $a=61.64.101.101;
 }
 
 
 $aa=system('lynx -dump http://api.hostip.info/country.php?ip=$a',$location);
 echo pa=$abraa=$aabrlocation=$locationbr;
 
 $aa=system('lynx -dump 
 http://api.hostip.info/country.php?ip=61.64.101.101',$location);
 echo pa=$abraa=$aabrlocation=$locationbr;
 
 
 I get:
 
 REMOTE_ADDR=192.168.250.108
 XX
 
 a=61.64.101.101
 aa=XX
 location=0
 TW
 
 a=61.64.101.101
 aa=TW
 location=0
 
 
 as you can see, if I put the IP address in, I get the right answer (TW).
 
 What am I doing wrong?
 
 bye
 
 Ronald
Use double quotes to get the value of $a or else you get the literal string 
$a.

$aa=system(lynx -dump http://api.hostip.info/country.php?ip=$a,$location);
or
$aa=system('lynx -dump http://api.hostip.info/country.php?ip='.$a,$location);


_
Peek-a-boo FREE Tricks  Treats for You!
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us

Re: [PHP] IF command

2007-10-19 Thread Bill Allaire

On Oct 18, 2007, at 9:50 PM, Bastien Koert wrote:




Are you sure that the value is a string? If its numeric, then try  
the check without the quotes around the value




http://www.php.net/manual/en/language.operators.comparison.php
If you compare an integer with a string, the string is converted to  
a number. If you compare two numerical strings, they are compared as  
integers.


?php

$component_reference = 5;
if ( ($component_reference != 5) AND ($component_reference !=  
19) ) {

echo(I am not a 5 or a 19br);
}
else
echo(I am a 5 or a 19br);


$component_reference = 5;
if ( ($component_reference != 5) AND ($component_reference !=  
19) ) {

echo(I am not a 5 or a 19br);
}
else
echo(I am a 5 or a 19br);

$component_reference = 3;
if ( ($component_reference != 5) AND ($component_reference !=  
19) ) {

echo(I am not a 5 or a 19br);
}
else
echo(I am a 5 or a 19br);

$component_reference = 3;
if ( ($component_reference != 5) AND ($component_reference !=  
19) ) {

echo(I am not a 5 or a 19br);
}
else
echo(I am a 5 or a 19br);

?



The results:

I am a 5 or a 19
I am a 5 or a 19
I am not a 5 or a 19
I am not a 5 or a 19

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] IF command

2007-10-18 Thread Bastien Koert

Are you sure that the value is a string? If its numeric, then try the check 
without the quotes around the value
 
 
bastien From: [EMAIL PROTECTED] To: php-general@lists.php.net Date: Thu, 18 
Oct 2007 19:49:55 -0500 Subject: [PHP] IF command  When $component_reference 
is 5 or 19 I don't want the echo statement to  output to the screen. What is 
the correct syntax? What I have below isn't  working. Thanks for your help. 
Ron  if ( ($component_reference != 5) OR ($component_reference != 19) ) 
{ echo lia href=\index.php?request= . $request . \ .  
$component_name . /a; }  --  PHP General Mailing List 
(http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php 
_
Send a smile, make someone laugh, have some fun! Start now!
http://www.freemessengeremoticons.ca/?icid=EMENCA122

Re: [PHP] IF command

2007-10-18 Thread Carlos Martínez González
Hi, here is the code:

if ( ($component_reference != 5) AND ($component_reference != 19) ) {
echo lia href=\index.php?request= . $request . \ .
$component_name . /a;
}


2007/10/19, ron.php [EMAIL PROTECTED]:
 When $component_reference is 5 or 19 I don't want the echo statement to
 output to the screen.  What is the correct syntax?  What I have below isn't
 working.  Thanks for your help.  Ron

 if ( ($component_reference != 5) OR ($component_reference != 19) ) {
 echo lia href=\index.php?request= . $request . \ .
 $component_name . /a;
 }

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] IF command

2007-10-18 Thread Casey

if (!in_array($component_reference, array(5,17)))
// ...

More compact.


On Oct 18, 2007, at 5:49 PM, ron.php [EMAIL PROTECTED]  
wrote:


When $component_reference is 5 or 19 I don't want the echo statement  
to
output to the screen.  What is the correct syntax?  What I have  
below isn't

working.  Thanks for your help.  Ron

if ( ($component_reference != 5) OR ($component_reference !=  
19) ) {

echo lia href=\index.php?request= . $request . \ .
$component_name . /a;
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] PHP Command line script

2007-05-02 Thread Peter Lauri
Check the error from mysqli:

http://fi.php.net/manual/en/function.mysqli-error.php

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free

 -Original Message-
 From: Nathaniel Hall [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 01, 2007 10:13 PM
 To: php-general@lists.php.net
 Subject: [PHP] PHP Command line script
 
 I am attempting to run a script that will run from the command line
 nightly to update a field in a database.  I already created a script
 that would access the database and insert most of the information when a
 webpage is visited and I had no problems with it.  The command line
 script appears to fail on the prepare.  I have echo'ed the SQL statement
 to the screen, copied it, and run it on the MySQL server with no
 problems.  Any ideas?
 
 ?php
 $mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
 if (mysqli_connect_errno()) {
 echo Unable to connect to database.\n;
 exit;
 } else {
 $login = date('m\-d\-Y');
 if ($logout = $mysqli-prepare(UPDATE `mydb`.`authlog`
 SET `logout`  = ? WHERE `login` LIKE '$login%')) { // --- Will not go
 any further than here, even when hard coding the information.
 $logout-bind_param(s, date('m\-d\-
 Y\TH\:i\:s'));
 $logout-execute();
 $logout-close();
 }
 }
 $mysqli-close();
 ?
 
 --
 Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA
 Spider Security
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Command line script

2007-05-02 Thread Nathaniel Hall

Greg Donald wrote:


On 5/1/07, Nathaniel Hall [EMAIL PROTECTED] wrote:
 I am attempting to run a script that will run from the command line
 nightly to update a field in a database.  I already created a script
 that would access the database and insert most of the information when a
 webpage is visited and I had no problems with it.  The command line
 script appears to fail on the prepare.  I have echo'ed the SQL statement
 to the screen, copied it, and run it on the MySQL server with no
 problems.  Any ideas?

 ?php
 $mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
 if (mysqli_connect_errno()) {
 echo Unable to connect to database.\n;
 exit;
 } else {
 $login = date('m\-d\-Y');
 if ($logout = $mysqli-prepare(UPDATE `mydb`.`authlog`
 SET `logout`  = ? WHERE `login` LIKE '$login%')) { // --- Will not go
 any further than here, even when hard coding the information.
 $logout-bind_param(s, 
date('m\-d\-Y\TH\:i\:s'));

 $logout-execute();
 $logout-close();
 }
 }
 $mysqli-close();
 ?


Add full error reporting, then make sure you can see the errors, then
test to see if you have the mysqli extension:

error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
ini_set( 'log_errors', 1 );

if( !in_array( 'mysqli', get_loaded_extensions() ) )
{
die( 'no mysqli found' );
}


I get no errors and I have verified that mysqli is loaded.


Also, why do you need to escape the dashes in the date() calls?

 php -r 'echo date(Y-m-d);'
2007-05-01


Habit.

--
Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA
Spider Security

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Command line script

2007-05-02 Thread Richard Lynch
On Tue, May 1, 2007 3:13 pm, Nathaniel Hall wrote:
 ?php
 $mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
 if (mysqli_connect_errno()) {
 echo Unable to connect to database.\n;
 exit;
 } else {
 $login = date('m\-d\-Y');
 if ($logout = $mysqli-prepare(UPDATE
 `mydb`.`authlog`
 SET `logout`  = ? WHERE `login` LIKE '$login%')) { // --- Will not
 go
 any further than here, even when hard coding the information.
 $logout-bind_param(s,
 date('m\-d\-Y\TH\:i\:s'));
 $logout-execute();
 $logout-close();
 }

//ALWAYS do your error-checking!!!
  else{
die(mysqli_error());
  }

//You may want to put the query in $query so you can print that
//as part of the 'die' output

 }
 $mysqli-close();
 ?

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Command line script

2007-05-01 Thread Daniel Brown

   First and foremost, it's a VERY BAD idea to use root for MySQL.  If your
code isn't perfect (and even sometimes if it is), arbitrary commands and SQL
injection attacks could lead to migraines that no Tylenol will ever be able
to alleviate.

   Secondly, what error is the CLI kicking out when you run it from the
command line?

On 5/1/07, Nathaniel Hall [EMAIL PROTECTED] wrote:


I am attempting to run a script that will run from the command line
nightly to update a field in a database.  I already created a script
that would access the database and insert most of the information when a
webpage is visited and I had no problems with it.  The command line
script appears to fail on the prepare.  I have echo'ed the SQL statement
to the screen, copied it, and run it on the MySQL server with no
problems.  Any ideas?

?php
$mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
if (mysqli_connect_errno()) {
echo Unable to connect to database.\n;
exit;
} else {
$login = date('m\-d\-Y');
if ($logout = $mysqli-prepare(UPDATE `mydb`.`authlog`
SET `logout`  = ? WHERE `login` LIKE '$login%')) { // --- Will not go
any further than here, even when hard coding the information.
$logout-bind_param(s,
date('m\-d\-Y\TH\:i\:s'));
$logout-execute();
$logout-close();
}
}
$mysqli-close();
?

--
Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA
Spider Security

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


Re: [PHP] PHP Command line script

2007-05-01 Thread Nathaniel Hall

Daniel Brown wrote:


First and foremost, it's a VERY BAD idea to use root for MySQL.  
If your code isn't perfect (and even sometimes if it is), arbitrary 
commands and SQL injection attacks could lead to migraines that no 
Tylenol will ever be able to alleviate.
I changed the user I was connecting as in order to post.  I don't use 
root in the real code.


Secondly, what error is the CLI kicking out when you run it from 
the command line?
It doesn't give an error.  The only thing it does is continue on through 
the IF statement, which goes nowhere.  I have added an ELSE to the 
script and run it.  It ends up running the code in the ELSE.



$login = date('m\-d\-Y');
if ($logout = $mysqli-prepare(UPDATE `mydb`.`authlog` SET
`logout`  = ? WHERE `login` LIKE '$login%')) { // --- Will not
go any further than here, even when hard coding the information.
  $logout-bind_param(s, date('m\-d\-Y\TH\:i\:s'));
  $logout-execute();
  $logout-close();
}


--
Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA
Spider Security

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Command line script

2007-05-01 Thread Greg Donald

On 5/1/07, Nathaniel Hall [EMAIL PROTECTED] wrote:

I am attempting to run a script that will run from the command line
nightly to update a field in a database.  I already created a script
that would access the database and insert most of the information when a
webpage is visited and I had no problems with it.  The command line
script appears to fail on the prepare.  I have echo'ed the SQL statement
to the screen, copied it, and run it on the MySQL server with no
problems.  Any ideas?

?php
$mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
if (mysqli_connect_errno()) {
echo Unable to connect to database.\n;
exit;
} else {
$login = date('m\-d\-Y');
if ($logout = $mysqli-prepare(UPDATE `mydb`.`authlog`
SET `logout`  = ? WHERE `login` LIKE '$login%')) { // --- Will not go
any further than here, even when hard coding the information.
$logout-bind_param(s, date('m\-d\-Y\TH\:i\:s'));
$logout-execute();
$logout-close();
}
}
$mysqli-close();
?



Add full error reporting, then make sure you can see the errors, then
test to see if you have the mysqli extension:

error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
ini_set( 'log_errors', 1 );

if( !in_array( 'mysqli', get_loaded_extensions() ) )
{
   die( 'no mysqli found' );
}

Also, why do you need to escape the dashes in the date() calls?


php -r 'echo date(Y-m-d);'

2007-05-01



--
Greg Donald
http://destiney.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] HELO command when sending email using PHP

2007-03-28 Thread demo
please check the RFC 821, it shows the SMTP protocol. 

HELO domain.com
it should fill your Mail server domain in order to prevent email going through 
most of anti-spam.

- Original Message - 
From: Angelo Zanetti [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Wednesday, March 28, 2007 5:10 PM
Subject: [PHP] HELO command when sending email using PHP


 Hi all.
 
 I am sending emails using the SMTP connection with PHP using the 
 HTMLMimeMail class. Now there is a setting there for the HELO command 
 text, can anyone explain to me what this is and what it should be set to?
 
 TIA.
 -- 
 
 Angelo Zanetti
 Systems developer
 
 
 *Telephone:* +27 (021) 469 1052
 *Mobile:*   +27 (0) 72 441 3355
 *Fax:*+27 (0) 86 681 5885
 *
 Web:* http://www.zlogic.co.za
 *E-Mail:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] HELO command when sending email using PHP

2007-03-28 Thread Angelo Zanetti



demo wrote:
please check the RFC 821, it shows the SMTP protocol. 


HELO domain.com
it should fill your Mail server domain in order to prevent email going through 
most of anti-spam.
  

Thanks, so if Im running localhost, the HELO command will also be localhost?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] HELO command when sending email using PHP

2007-03-28 Thread demo
by the way, here is php issues maillist not EMAIL issues:)

if any problem with SMTP or email, please contact me directly

--
http://tssoft.3322.org:8080/2.1/
demo:demodemo
it's my email server developped by MSVC

- Original Message - 
From: Angelo Zanetti [EMAIL PROTECTED]
To: demo [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Wednesday, March 28, 2007 5:33 PM
Subject: Re: [PHP] HELO command when sending email using PHP


 
 
 demo wrote:
 please check the RFC 821, it shows the SMTP protocol. 

 HELO domain.com
 it should fill your Mail server domain in order to prevent email going 
 through most of anti-spam.
   
 Thanks, so if Im running localhost, the HELO command will also be localhost?
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] HELO command when sending email using PHP

2007-03-28 Thread demo
localhost is ok if u just send mail in the LAN.

if you send mail in the internet, it may not be ok, bcoz it will be cut by 
anti-spam.

most smtp servers always validate your HELO area and your DNS and check if 
them match.

- Original Message - 
From: Angelo Zanetti [EMAIL PROTECTED]
To: demo [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Wednesday, March 28, 2007 5:33 PM
Subject: Re: [PHP] HELO command when sending email using PHP


 
 
 demo wrote:
 please check the RFC 821, it shows the SMTP protocol. 

 HELO domain.com
 it should fill your Mail server domain in order to prevent email going 
 through most of anti-spam.
   
 Thanks, so if Im running localhost, the HELO command will also be localhost?
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] shell command

2005-11-18 Thread Jasper Bryant-Greene

John Taylor-Johnston wrote:

Hi,
I want to echo the location of head.jpg hidden in some deep dark 
recess of my server, unbeknownst to me.

Which shell command do I use? How do I echo it?
John



While this isn't really a PHP question...

On my machine, the following would work. I can't speak for your machine, 
though.


cd /; find -name head.jpg

--
Jasper Bryant-Greene
General Manager
Album Limited

+64 21 708 334
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shell command

2005-11-18 Thread Robert Cummings
On Sat, 2005-11-19 at 13:02, Jasper Bryant-Greene wrote:
 John Taylor-Johnston wrote:
  Hi,
  I want to echo the location of head.jpg hidden in some deep dark 
  recess of my server, unbeknownst to me.
  Which shell command do I use? How do I echo it?
  John
  
 
 While this isn't really a PHP question...
 
 On my machine, the following would work. I can't speak for your machine, 
 though.
 
 cd /; find -name head.jpg

Under linux:

locate head.jpg

This is better than find usually since the filesystem is usually indexed
nightly making lookup fast. If you just added the file though... you'll
need to use the aforementioned method :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Error Command failed for target 'ext/xml/xml.lo' during make process (Solaris 8)

2005-11-16 Thread Curt Zirzow
On Tue, Nov 15, 2005 at 09:20:54PM +0100, Age Bosma wrote:
 Hi,
 
 I'm trying to compile php 4.4.1 on Solaris 8 but I'm getting the error
 Command failed for target 'ext/xml/xml.lo' during the make process.
 
 [snip]
 /nfs/dm11-fs22/work/training/dj365/php-4.4.1/ext/xml/xml.c:1582:
 `XML_Char' undeclared (first use in this function)
 ...
 make: Fatal error: Command failed for target 'ext/xml/xml.lo'
 
 If I look in the 'ext/xml/' folder, there's no file called 'xml.lo'.
 What can be the problem here?

It is trying to make the xml.lo file, the errors prior to that
explain why.

 
 I used the following configuration with gcc 3.2.3:
 
 configure --prefix=/work/training/dg432/servsoft/php4
 --with-apxs2=/work/training/dg432/servsoft/apache2/bin/apxs
 --with-mysql=/work/training/dg432/servsoft/mysql4 --enable-calendar
 --enable-ftp --with-gettext --with-iconv
 --with-dom=/work/training/dg432/servsoft
 --with-dom-xslt=/work/training/dg432/servsoft

This is an odd configure line, i'm guessing this is some sort of
package thing.  At first glance at the the errors above, i would
guess that this package has some version issues.

 Except for gettext and iconv I manually compiled all packaged myself.
 
 In addition to this, I got two warnings during the configuration process:
 configure: warning: You will need bison 1.28 and configure: warning:
 You will need bison 1.28 if you want to regenerate the Zend parser
 (found 1.27)
 Could this have anything to do with it?

most likely not.

Curt.
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

[EMAIL PROTECTED] wrote:
I have two programs on two servers, and they both have similar problems. 
In each one, I use 'exec' to call a helper program.  In one case, it is 
ecasound, which I use to resample an mp3.  In the other, it is convert, 
which creates a thumbnail of a very large image the user has uploaded.  
In both cases, the exec command fails.  Not all the time, but some 
times.  In both cases, the command that is being called by exec will 
work fine at the command line.  I assume that there is some memory / 
resource limit that is being breached when this happens, but I don't 
know what it is, or how to tell php to allow my programs to run.  Any 
ideas?


Is it a disallowed function you your php.ini?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

[EMAIL PROTECTED] wrote:
I have two programs on two servers, and they both have similar problems. 
In each one, I use 'exec' to call a helper program.  In one case, it is 
ecasound, which I use to resample an mp3.  In the other, it is convert, 
which creates a thumbnail of a very large image the user has uploaded.  
In both cases, the exec command fails.  Not all the time, but some 
times.  In both cases, the command that is being called by exec will 
work fine at the command line.  I assume that there is some memory / 
resource limit that is being breached when this happens, but I don't 
know what it is, or how to tell php to allow my programs to run.  Any 
ideas?


Or is save mode on?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

Please reply to the list.

[EMAIL PROTECTED] wrote:
No, all of these things your are bringing up would cause the programs to 
NEVER work, not work some of the time or when the data they are 
processing is small.


Depends on the install.  My cli uses a different php.ini than the web one.

Did you check permissions?  Does the user which your web server is 
running as have execute permission on the app?



 On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:

I have two programs on two servers, and they both have similar 
problems. In each one, I use 'exec' to call a helper program.  In one 
case, it is ecasound, which I use to resample an mp3.  In the other, 
it is convert, which creates a thumbnail of a very large image the 
user has uploaded.  In both cases, the exec command fails.  Not all 
the time, but some times.  In both cases, the command that is being 
called by exec will work fine at the command line.  I assume that 
there is some memory / resource limit that is being breached when 
this happens, but I don't know what it is, or how to tell php to 
allow my programs to run.  Any ideas?



Or is save mode on?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com



--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst
I don't want to crowd the list up with dead ends, so I was trying to 
respond only to you.
  I'm not calling a php program from exec, I'm calling ecasound and 
convert.  For example, in the php code:


exec(convert $internalpath/$filename -resize 
{$thumbWidth}x{$thumbHeight} $internalpath/$thumbname, $out, $err);


doesn't always work, but with variables substituted on the command line:

bash:~ convert futon.jpg -resize 240x180 futon_thumb.jpg

will always work.

The same is true, on a different server, of my exec that calls ecasound, 
an mp3 processing utility.  Both of these could conceivably use a lot of 
resources, which is why I think php is killing them off some of the time.




On Wed, 21 Sep 2005, John Nichel wrote:


Please reply to the list.

[EMAIL PROTECTED] wrote:
No, all of these things your are bringing up would cause the programs to 
NEVER work, not work some of the time or when the data they are processing 
is small.


Depends on the install.  My cli uses a different php.ini than the web one.

Did you check permissions?  Does the user which your web server is running as 
have execute permission on the app?



 On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:

I have two programs on two servers, and they both have similar problems. 
In each one, I use 'exec' to call a helper program.  In one case, it is 
ecasound, which I use to resample an mp3.  In the other, it is convert, 
which creates a thumbnail of a very large image the user has uploaded. 
In both cases, the exec command fails.  Not all the time, but some times. 
In both cases, the command that is being called by exec will work fine at 
the command line.  I assume that there is some memory / resource limit 
that is being breached when this happens, but I don't know what it is, or 
how to tell php to allow my programs to run.  Any ideas?



Or is save mode on?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com



--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

[EMAIL PROTECTED] wrote:
I don't want to crowd the list up with dead ends, so I was trying to 
respond only to you.

snip

You'll get more chances at finding the solution to this with the list's 
eyes on it rather than just myself.  Plus, it provides an archive of the 
problem and the (if we find it) solution to the next person who comes along.


/snip
  I'm not calling a php program from exec, I'm calling ecasound and 
convert.  For example, in the php code:

snip

Understood, but if the web server doesn't have permission to execute the 
app, it won't.


/snip
exec(convert $internalpath/$filename -resize 
{$thumbWidth}x{$thumbHeight} $internalpath/$thumbname, $out, $err);


doesn't always work, but with variables substituted on the command line:

snip

Are you sure that the variables have value, and it is the value you 
want?  What is stored in $err when you try to execute this?  Echo that 
out, and it may tell you exactly what's going wrong.


/snip

bash:~ convert futon.jpg -resize 240x180 futon_thumb.jpg

will always work.

The same is true, on a different server, of my exec that calls ecasound, 
an mp3 processing utility.  Both of these could conceivably use a lot of 
resources, which is why I think php is killing them off some of the time.

snip

Try increasing the memory limit in your script with ini_set.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst
If the web server didn't have permission to execute the app, it would 
NEVER execute the app, not execute it some of the time.  In fact, it 
ALWAYS executes the app, it just doesn't always allow it to finish.
  I log all attempts to run these apps in order to debug, so I know that 
the command as passed from php will work in the command line.  I copy and 
paste the command from the log and it runs, even though it didn't complete 
execution when called from php.
  I have increased several parameters in php.ini, including memory limit 
and allowed execution time.  Nothing has helped.  The only thing that 
helps is if I wrap the app I want to run in a perl script and call the 
perl script from php.  That works more of the time, though it still often 
breaks.




 On 
Wed, 21 Sep 2005, John Nichel wrote:



[EMAIL PROTECTED] wrote:
I don't want to crowd the list up with dead ends, so I was trying to 
respond only to you.

snip

You'll get more chances at finding the solution to this with the list's eyes 
on it rather than just myself.  Plus, it provides an archive of the problem 
and the (if we find it) solution to the next person who comes along.


/snip
  I'm not calling a php program from exec, I'm calling ecasound and 
convert.  For example, in the php code:

snip

Understood, but if the web server doesn't have permission to execute the app, 
it won't.


/snip
exec(convert $internalpath/$filename -resize {$thumbWidth}x{$thumbHeight} 
$internalpath/$thumbname, $out, $err);


doesn't always work, but with variables substituted on the command line:

snip

Are you sure that the variables have value, and it is the value you want? 
What is stored in $err when you try to execute this?  Echo that out, and it 
may tell you exactly what's going wrong.


/snip

bash:~ convert futon.jpg -resize 240x180 futon_thumb.jpg

will always work.

The same is true, on a different server, of my exec that calls ecasound, an 
mp3 processing utility.  Both of these could conceivably use a lot of 
resources, which is why I think php is killing them off some of the time.

snip

Try increasing the memory limit in your script with ini_set.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

[EMAIL PROTECTED] wrote:
If the web server didn't have permission to execute the app, it would 
NEVER execute the app, not execute it some of the time.  In fact, it 
ALWAYS executes the app, it just doesn't always allow it to finish.
  I log all attempts to run these apps in order to debug, so I know that 
the command as passed from php will work in the command line.  I copy 
and paste the command from the log and it runs, even though it didn't 
complete execution when called from php.


What do the logs say??

  I have increased several parameters in php.ini, including memory limit 
and allowed execution time.  Nothing has helped.  The only thing that 
helps is if I wrap the app I want to run in a perl script and call the 
perl script from php.  That works more of the time, though it still 
often breaks.


Maybe the problem's not php but Apache (or whatever webserver you're 
using), as it has limits in place for these items too.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst

the logs say things like:
/kunden/homepages/12/d117065027/htdocs/software/ImageMagick-6.2.3/utilities/convert 
ib_images/Other_Spices_Basic_004.jpg -resize 180x120 ib_images/Other_Spices_Basic_004_thumb.jpg


this is a command I'm trying to get php to run.  I then cut and paste it 
to the command line, and it works fine.  the paths are fine too, otherwise 
it would never run, not run some of the time.
  Can you give me an example of an apache directive that would restrict 
php?




 On Wed, 21 Sep 2005, John 
Nichel wrote:



[EMAIL PROTECTED] wrote:
If the web server didn't have permission to execute the app, it would NEVER 
execute the app, not execute it some of the time.  In fact, it ALWAYS 
executes the app, it just doesn't always allow it to finish.
  I log all attempts to run these apps in order to debug, so I know that 
the command as passed from php will work in the command line.  I copy and 
paste the command from the log and it runs, even though it didn't complete 
execution when called from php.


What do the logs say??

  I have increased several parameters in php.ini, including memory limit 
and allowed execution time.  Nothing has helped.  The only thing that helps 
is if I wrap the app I want to run in a perl script and call the perl 
script from php.  That works more of the time, though it still often 
breaks.


Maybe the problem's not php but Apache (or whatever webserver you're using), 
as it has limits in place for these items too.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

[EMAIL PROTECTED] wrote:

the logs say things like:
/kunden/homepages/12/d117065027/htdocs/software/ImageMagick-6.2.3/utilities/convert 
ib_images/Other_Spices_Basic_004.jpg -resize 180x120 
ib_images/Other_Spices_Basic_004_thumb.jpg


this is a command I'm trying to get php to run.  I then cut and paste it 
to the command line, and it works fine.  the paths are fine too, 
otherwise it would never run, not run some of the time.
  Can you give me an example of an apache directive that would restrict 
php?


Timeout


 On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:

If the web server didn't have permission to execute the app, it would 
NEVER execute the app, not execute it some of the time.  In fact, it 
ALWAYS executes the app, it just doesn't always allow it to finish.
  I log all attempts to run these apps in order to debug, so I know 
that the command as passed from php will work in the command line.  I 
copy and paste the command from the log and it runs, even though it 
didn't complete execution when called from php.



What do the logs say??

  I have increased several parameters in php.ini, including memory 
limit and allowed execution time.  Nothing has helped.  The only 
thing that helps is if I wrap the app I want to run in a perl script 
and call the perl script from php.  That works more of the time, 
though it still often breaks.



Maybe the problem's not php but Apache (or whatever webserver you're 
using), as it has limits in place for these items too.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com




--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst
timeout isn't being used on either of these machines, and as far as I read 
it, the timeout directive would make the web server fail, producing an 
apache error or some strange behaviour on the client end.  Neither of 
these happens, the php script completes normally, but the exec command 
(and only these exec commands, I'm using others in the script that work 
fine) doesn't always complete.  Even if timeout was set to its normal 
default of 300 seconds, this all happens way before 300 seconds have 
passed.  The whole process takes about 20 or 30 seconds.



 On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:

the logs say things like:
/kunden/homepages/12/d117065027/htdocs/software/ImageMagick-6.2.3/utilities/convert 
ib_images/Other_Spices_Basic_004.jpg -resize 180x120 
ib_images/Other_Spices_Basic_004_thumb.jpg


this is a command I'm trying to get php to run.  I then cut and paste it to 
the command line, and it works fine.  the paths are fine too, otherwise it 
would never run, not run some of the time.
  Can you give me an example of an apache directive that would restrict 
php?


Timeout


 On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:

If the web server didn't have permission to execute the app, it would 
NEVER execute the app, not execute it some of the time.  In fact, it 
ALWAYS executes the app, it just doesn't always allow it to finish.
  I log all attempts to run these apps in order to debug, so I know that 
the command as passed from php will work in the command line.  I copy and 
paste the command from the log and it runs, even though it didn't 
complete execution when called from php.



What do the logs say??

  I have increased several parameters in php.ini, including memory limit 
and allowed execution time.  Nothing has helped.  The only thing that 
helps is if I wrap the app I want to run in a perl script and call the 
perl script from php.  That works more of the time, though it still often 
breaks.



Maybe the problem's not php but Apache (or whatever webserver you're 
using), as it has limits in place for these items too.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com




--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

[EMAIL PROTECTED] wrote:
timeout isn't being used on either of these machines, and as far as I 
read it, the timeout directive would make the web server fail, producing 
an apache error or some strange behaviour on the client end.  Neither of


How is timeout _not_ being used?  It's a core directive.  If the timeout 
is reached, the thread dies, along with anything running with it.


these happens, the php script completes normally, but the exec command 
(and only these exec commands, I'm using others in the script that work 
fine) doesn't always complete.  Even if timeout was set to its normal 
default of 300 seconds, this all happens way before 300 seconds have 
passed.  The whole process takes about 20 or 30 seconds.


Just to make sure I'm understanding you, you're hitting the php page in 
a browser, right?  Like you're going to http://www.yourhost.com/page.php 
where page.php contains somthing like...


?php

exec ( '/path/myapp', $out, $res );

?

Right?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst
as I said, the default timout is 300 seconds, a lot longer than my program 
takes to run, and I am pretty certain that if timeout were triggered, I'd 
see it in the client.
  Yeah, I'm using a browser on the php page, and everything seems to 
function fine from the browser to the server, it's after the server gets 
the uploaded file and begins to play with it that things become weird.


 On 
Wed, 21 Sep 2005, John Nichel wrote:



[EMAIL PROTECTED] wrote:
timeout isn't being used on either of these machines, and as far as I read 
it, the timeout directive would make the web server fail, producing an 
apache error or some strange behaviour on the client end.  Neither of


How is timeout _not_ being used?  It's a core directive.  If the timeout is 
reached, the thread dies, along with anything running with it.


these happens, the php script completes normally, but the exec command (and 
only these exec commands, I'm using others in the script that work fine) 
doesn't always complete.  Even if timeout was set to its normal default of 
300 seconds, this all happens way before 300 seconds have passed.  The 
whole process takes about 20 or 30 seconds.


Just to make sure I'm understanding you, you're hitting the php page in a 
browser, right?  Like you're going to http://www.yourhost.com/page.php where 
page.php contains somthing like...


?php

exec ( '/path/myapp', $out, $res );

?

Right?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

[EMAIL PROTECTED] wrote:
as I said, the default timout is 300 seconds, a lot longer than my 
program takes to run, and I am pretty certain that if timeout were 
triggered, I'd see it in the client.
  Yeah, I'm using a browser on the php page, and everything seems to 
function fine from the browser to the server, it's after the server gets 
the uploaded file and begins to play with it that things become weird.


What's the output of...

$output = shell_exec ( '/path/to/your/app' );
echo ( pre . $output . /pre );

...when it doesn't work?


 On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:

timeout isn't being used on either of these machines, and as far as I 
read it, the timeout directive would make the web server fail, 
producing an apache error or some strange behaviour on the client 
end.  Neither of



How is timeout _not_ being used?  It's a core directive.  If the 
timeout is reached, the thread dies, along with anything running with it.


these happens, the php script completes normally, but the exec 
command (and only these exec commands, I'm using others in the script 
that work fine) doesn't always complete.  Even if timeout was set to 
its normal default of 300 seconds, this all happens way before 300 
seconds have passed.  The whole process takes about 20 or 30 seconds.



Just to make sure I'm understanding you, you're hitting the php page 
in a browser, right?  Like you're going to 
http://www.yourhost.com/page.php where page.php contains somthing like...


?php

exec ( '/path/myapp', $out, $res );

?

Right?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com




--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst
convert doesn't produce any output regardless of whether it works or not. 
Ecasound produces output when it works, but when it doesn't, it produces 
no output.  Using php tricks to capture standard error also produces no 
output.




 On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:
as I said, the default timout is 300 seconds, a lot longer than my program 
takes to run, and I am pretty certain that if timeout were triggered, I'd 
see it in the client.
  Yeah, I'm using a browser on the php page, and everything seems to 
function fine from the browser to the server, it's after the server gets 
the uploaded file and begins to play with it that things become weird.


What's the output of...

$output = shell_exec ( '/path/to/your/app' );
echo ( pre . $output . /pre );

...when it doesn't work?


 On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:

timeout isn't being used on either of these machines, and as far as I 
read it, the timeout directive would make the web server fail, producing 
an apache error or some strange behaviour on the client end.  Neither of



How is timeout _not_ being used?  It's a core directive.  If the timeout 
is reached, the thread dies, along with anything running with it.


these happens, the php script completes normally, but the exec command 
(and only these exec commands, I'm using others in the script that work 
fine) doesn't always complete.  Even if timeout was set to its normal 
default of 300 seconds, this all happens way before 300 seconds have 
passed.  The whole process takes about 20 or 30 seconds.



Just to make sure I'm understanding you, you're hitting the php page in a 
browser, right?  Like you're going to http://www.yourhost.com/page.php 
where page.php contains somthing like...


?php

exec ( '/path/myapp', $out, $res );

?

Right?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com




--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread John Nichel

[EMAIL PROTECTED] wrote:
convert doesn't produce any output regardless of whether it works or 
not. Ecasound produces output when it works, but when it doesn't, it 
produces no output.  Using php tricks to capture standard error also 
produces no output.


Hopefully somebody else on the list can help.  Without any output/error 
messages, it's kind of hard to know what the problem is.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst

You're telling me.  That's why I think php or apache kills it.

On Wed, 21 Sep 2005, John Nichel wrote:


[EMAIL PROTECTED] wrote:
convert doesn't produce any output regardless of whether it works or not. 
Ecasound produces output when it works, but when it doesn't, it produces no 
output.  Using php tricks to capture standard error also produces no 
output.


Hopefully somebody else on the list can help.  Without any output/error 
messages, it's kind of hard to know what the problem is.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread Rasmus Lerdorf
[EMAIL PROTECTED] wrote:
 You're telling me.  That's why I think php or apache kills it.

I didn't really follow this, but typically you can debug exec problems
from the command line by switching to the web server user id and running
the exact same command.

-Rasmus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst
Yes, but that's been done.  Since these are shared servers, on one I am 
logged in as the user the web server is running as, on the other I can't 
su to nobody, but were there permissions errors, I would have been able to 
capture them.  If permissions caused this, it would fail every time, since 
I'm always writing to the same directory.  Instead it only fails some of 
the time.


 On Wed, 21 Sep 2005, Rasmus Lerdorf wrote:


[EMAIL PROTECTED] wrote:

You're telling me.  That's why I think php or apache kills it.


I didn't really follow this, but typically you can debug exec problems
from the command line by switching to the web server user id and running
the exact same command.

-Rasmus



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread rouvas
I am assuming that you get hold of the file through uploading it, correct?
So, when it fails maybe another upload (i.e. script invocation) is happening 
and the previous file gets lost/corrupted/whatever. Try to move the file to 
another dir (maybe /tmp) with a random name and see what happens.

Anyway, I think that this kind of thing should really be delegated to a 
cronjob.

-Stathis

On Wednesday 21 September 2005 20:45, [EMAIL PROTECTED] wrote:
 Yes, but that's been done.  Since these are shared servers, on one I am
 logged in as the user the web server is running as, on the other I can't
 su to nobody, but were there permissions errors, I would have been able to
 capture them.  If permissions caused this, it would fail every time, since
 I'm always writing to the same directory.  Instead it only fails some of
 the time.

   On Wed, 21 Sep 2005, Rasmus Lerdorf wrote:
  [EMAIL PROTECTED] wrote:
  You're telling me.  That's why I think php or apache kills it.
 
  I didn't really follow this, but typically you can debug exec problems
  from the command line by switching to the web server user id and running
  the exact same command.
 
  -Rasmus

 New Disorder Records - ten years of something:
 Coming soon, new Power Struggle CD.
 * Free Email with 5 megs, no ads
 * Internet Radio Station - upload your music, we'll put it in rotation
 * 100's of CDs for sale
 * videos, message board, byofl
 http://www.newdisorder.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst
php places uploaded files in the /tmp directory with a unique name, and 
when I copy them to my directory, I also guarantee a unique name for them. 
I have verified that this is all working.  I've patched this with a cron 
job that runs every minute, but it really should happen in php, so that 
the user can get immediate feedback on how the thumbnail looks or how the 
mp3 file sounds.


 On Wed, 21 Sep 2005, rouvas wrote:


I am assuming that you get hold of the file through uploading it, correct?
So, when it fails maybe another upload (i.e. script invocation) is happening
and the previous file gets lost/corrupted/whatever. Try to move the file to
another dir (maybe /tmp) with a random name and see what happens.

Anyway, I think that this kind of thing should really be delegated to a
cronjob.

-Stathis

On Wednesday 21 September 2005 20:45, [EMAIL PROTECTED] wrote:

Yes, but that's been done.  Since these are shared servers, on one I am
logged in as the user the web server is running as, on the other I can't
su to nobody, but were there permissions errors, I would have been able to
capture them.  If permissions caused this, it would fail every time, since
I'm always writing to the same directory.  Instead it only fails some of
the time.

  On Wed, 21 Sep 2005, Rasmus Lerdorf wrote:

[EMAIL PROTECTED] wrote:

You're telling me.  That's why I think php or apache kills it.


I didn't really follow this, but typically you can debug exec problems
from the command line by switching to the web server user id and running
the exact same command.

-Rasmus


New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread adriano ghezzi
did you tried to run the script from the shell as www-data user ?
(if not su www-data) an then run the script may be something regarding
permission

hth


2005/9/21, John Nichel [EMAIL PROTECTED]:
 [EMAIL PROTECTED] wrote:
  I have two programs on two servers, and they both have similar problems.
  In each one, I use 'exec' to call a helper program.  In one case, it is
  ecasound, which I use to resample an mp3.  In the other, it is convert,
  which creates a thumbnail of a very large image the user has uploaded.
  In both cases, the exec command fails.  Not all the time, but some
  times.  In both cases, the command that is being called by exec will
  work fine at the command line.  I assume that there is some memory /
  resource limit that is being breached when this happens, but I don't
  know what it is, or how to tell php to allow my programs to run.  Any
  ideas?

 Or is save mode on?

 --
 John C. Nichel
 ÜberGeek
 KegWorks.com
 716.856.9675
 [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command fails in php, works in the command line

2005-09-21 Thread ernst

yeah, if you look at the thread you will see that I've already done this.

On Wed, 21 Sep 2005, adriano ghezzi wrote:


did you tried to run the script from the shell as www-data user ?
(if not su www-data) an then run the script may be something regarding
permission

hth


2005/9/21, John Nichel [EMAIL PROTECTED]:

[EMAIL PROTECTED] wrote:

I have two programs on two servers, and they both have similar problems.
In each one, I use 'exec' to call a helper program.  In one case, it is
ecasound, which I use to resample an mp3.  In the other, it is convert,
which creates a thumbnail of a very large image the user has uploaded.
In both cases, the exec command fails.  Not all the time, but some
times.  In both cases, the command that is being called by exec will
work fine at the command line.  I assume that there is some memory /
resource limit that is being breached when this happens, but I don't
know what it is, or how to tell php to allow my programs to run.  Any
ideas?


Or is save mode on?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




New Disorder Records - ten years of something:
Coming soon, new Power Struggle CD.
* Free Email with 5 megs, no ads
* Internet Radio Station - upload your music, we'll put it in rotation
* 100's of CDs for sale
* videos, message board, byofl
http://www.newdisorder.com
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Split command problem

2005-04-11 Thread Jason Wong
On Monday 11 April 2005 09:27, Russ wrote:
 I have been trying to get the following code working. I keep getting an
 error on line nine. 

And the error is?

 It looks simular to the example in the PHP online
 manual. If I substitute a print command for line nine I get the correct
 information from $_POST[username]. I must be missing or have an extra a
 quote but I cannot figure out where.

 name($fname, $lname) = split('[/\s+/]', $_POST[username]);

split() probably uses POSIX regex and hence knows nothing about '\s'. Use 
preg_split() instead:

  list($fname, $lname) = preg_split('/\s+/', $_POST['username']);

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Split command problem

2005-04-11 Thread Prathaban Mookiah
I guess you are trying to create an array by the name 'name' and assign two 
elements to it by calling name($fname, $lname). Am I correct?

I think it does not work that way. Try list($fname, $lname) = ..
Then the variable $fname and $lname will contain the first and last names.

list($fname, $lname) = split('[/\s+/]', $_POST[username]);

Cheers,

Prathap


-- Original Message ---
From: Russ [EMAIL PROTECTED]
To: PHP General php-general@lists.php.net
Sent: Sun, 10 Apr 2005 18:27:34 -0700
Subject: [PHP] Split command problem

 I have been trying to get the following code working. I keep getting 
 an error on line nine. It looks simular to the example in the PHP 
 online manual. If I substitute a print command for line nine I get 
 the correct information from $_POST[username]. I must be missing or 
 have an extra a quote but I cannot figure out where.
 
 ?php
 //check for required fields from the form
 if ((!$_POST[username]) || (!$_POST[password])) {
   header(Location: memberlogin15.7.php);
   exit;
 } 
 if(preg_match(/[A-Z]/, substr($_POST[username], 0, 1)))
 {
 name($fname, $lname) = split('[/\s+/]', $_POST[username]);
 //echo First Name: $fname; Last Name: $lname\n;
 echo first letter is uppercase;
 }
 else
 {
 echo first letter is not uppercase;
 }
 
 Any help will be appreciated.
 -- 
 Russ
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
--- End of Original Message ---

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Split command problem

2005-04-10 Thread Greg Donald
On Apr 10, 2005 8:27 PM, Russ [EMAIL PROTECTED] wrote:
 I have been trying to get the following code working. I keep getting an error
 on line nine. It looks simular to the example in the PHP online manual. If I
 substitute a print command for line nine I get the correct information from
 $_POST[username]. I must be missing or have an extra a quote but I cannot
 figure out where.
 
 ?php
 //check for required fields from the form
 if ((!$_POST[username]) || (!$_POST[password])) {
header(Location: memberlogin15.7.php);
exit;
 }
 if(preg_match(/[A-Z]/, substr($_POST[username], 0, 1)))
 {
 name($fname, $lname) = split('[/\s+/]', $_POST[username]);

Where is your 'name' function and what does it do?

I'd do:

$name = explode( ' ', $_POST[ 'username' ] );
echo First Name: $name[0] Last Name: $name[1];

 //echo First Name: $fname; Last Name: $lname\n;
 echo first letter is uppercase;
 }
 else
 {
 echo first letter is not uppercase;
 }


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] exec command

2005-04-07 Thread Philip Hallstrom
You might find that get_current_user() is easier...
http://www.php.net/manual/en/function.get-current-user.php
On Wed, 6 Apr 2005, cragland wrote:
when running a simple php script, below, with exec, I recieve:
sh: /whoami: No such file or directory
?php
// outputs the username that owns the running php/httpd process
// (on a system with the whoami executable in the path)
echo exec('whoami');
?
Thanks very much,
cole
mailto:[EMAIL PROTECTED]
MMS firstam.com made the following
annotations on 04/06/2005 05:37:11 PM
--
THIS E-MAIL MESSAGE AND ANY FILES TRANSMITTED HEREWITH, ARE INTENDED SOLELY FOR THE 
USE OF THE INDIVIDUAL(S) ADDRESSED AND MAY CONTAIN CONFIDENTIAL, PROPRIETARY OR 
PRIVILEGED INFORMATION.  IF YOU ARE NOT THE ADDRESSEE INDICATED IN THIS MESSAGE (OR 
RESPONSIBLE FOR DELIVERY OF THIS MESSAGE TO SUCH PERSON) YOU MAY NOT REVIEW, USE, 
DISCLOSE OR DISTRIBUTE THIS MESSAGE OR ANY FILES TRANSMITTED HEREWITH.  IF YOU RECEIVE 
THIS MESSAGE IN ERROR, PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE THIS MESSAGE 
AND ALL COPIES OF IT FROM YOUR SYSTEM.
==
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] exec command

2005-04-06 Thread Mike
 when running a simple php script, below, with exec, I recieve:
 sh: /whoami: No such file or directory
 
 ?php
 // outputs the username that owns the running php/httpd 
 process // (on a system with the whoami executable in the 
 path) echo exec('whoami'); ?
 

You may want to try using the full path to the whoami command. 

Try 

echo exec('/usr/bin/whoami'); 

Or wherever it sits on your machine.

If you don't know the user that PHP runs as, how do you know what it's PATH
variable is... 

-M

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] php command

2005-03-23 Thread Mikey
I think what you need to do is look at the sockets section of the manual.

Regards,

Mikey 

 -Original Message-
 From: D A GERM [mailto:[EMAIL PROTECTED] 
 Sent: 23 March 2005 14:46
 To: php-general@lists.php.net
 Subject: [PHP] php command
 
 is there a command that will allow me to connect to another 
 box and execute commands?
 
 for instance, I want to create an automated php script that 
 will connect to a unix box and run a series of commands. I 
 believe that ssh2_exec() and ssh2_shell() are not supported 
 in the 4.3.4 version of php I am running.
 
 I thought of exec(); i could telnet in to the box but I 
 didn't know if another exec() statement would pass the 
 aurguments to the original telnet session set up in a 
 previous exec() statement.
 
 --
 PHP General Mailing List (http://www.php.net/) To 
 unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] setcookie command

2005-01-24 Thread Greg Donald
On Mon, 24 Jan 2005 07:24:19 -0800 (PST), Reza Milan
[EMAIL PROTECTED] wrote:
 Dear sir,
 
 When I use setcookie command I recieve the following message error:
 
 Warning: Cannot modify header information - headers already sent by (output 
 started at C:\Inetpub\wwwroot\test.php:9) in C:\Inetpub\wwwroot\test.php on 
 line 15

Do not set cookies after you have ouput anything, set them before.  Or
use the output buffering functions.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] setcookie command

2005-01-24 Thread Richard Lynch
Reza Milan wrote:
 Dear sir,

 When I use setcookie command I recieve the following message error:

 Warning: Cannot modify header information - headers already sent by
 (output started at C:\Inetpub\wwwroot\test.php:9) in
 C:\Inetpub\wwwroot\test.php on line 15

 WinXp - IE 6
 On Localhost and Server

When a web page is sent from the web server to the browser, there are
*TWO* distinct sections sent out.

First, is the 'headers', which are called 'headers' because they come at
the head (beginning) of the data.

Then comes a blank line, to signify the END of headers.

Finally, the 'body' comes out, which is what you see when you do View
Source -- It's the actual HTML.

Headers include meta-information such as the type of Content (text/html or
image/jpeg or image/gif or ...)

In your case, test.php has something on line 9 that is sending out some
HTML (or blank lines or ...)

Once that happens, PHP has to dump out all the headers collected so far,
and then a blank line, and then start your content.

If you try to set a cookie *AFTER* that, when the headers are already
gone, and the blank line has gone out to signify the end of headers, IT'S
TOO LATE.

You have to re-arrange your code to get the Cookies and any other headers
to happen *FIRST* and then your HTML after that.

You can cheat and turn on output buffering, but that comes with its own
performance penalties and issues.

You'll probably have a cleaner, more clear, more easily maintained body of
PHP code if you arrange your headers to come out first anyway.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Executing command in Linux

2005-01-18 Thread Richard Lynch
Rosen wrote:
 Hi,
 I have this problem:
 Linux Red Hat 7.3 server and PHP 4.3.8  MySQL 4. When I Try to execute
 linux command - nothing happens and in Apache logs I see Access denied.
 This is about permissions in executing this command.

 My question is can I execute a linux command via PHP ( this is command
 allowed only for root user ) ?

 P.S. I own this server - i.e. I have user  pass for root.

The PHP user is not root.

The PHP user should *NOT* be root.

Either make that command available to the PHP user, or don't use that
command.

Options for making that command available to the PHP user abound, and
include:
chmod so 'w'orld can eXecute.
Add 'php' group w/ PHP user in it, and chgrp/chmod so 'g'roup can execute.
Use sudo to allow PHP user to run that one command.

Exactly how you choose to do this depends more on your risk assessment,
skill level, and what you are doing than anything else -- None of which
are PHP-related strictly-speaking.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Executing command in Linux

2005-01-15 Thread Bret Hughes
On Sat, 2005-01-15 at 11:57, Rosen wrote:
 Hi,
 I have this problem:
 Linux Red Hat 7.3 server and PHP 4.3.8  MySQL 4. When I Try to execute
 linux command - nothing happens and in Apache logs I see Access denied.
 This is about permissions in executing this command.
 
 My question is can I execute a linux command via PHP ( this is command
 allowed only for root user ) ?
 
 P.S. I own this server - i.e. I have user  pass for root.


I use sudo for these situations.  use visudo to establish that the user
that owns the apache process ( I can't remember if RHL 7.3 was nobody or
if the had switched to apache by then ).

THen you can use exec(sudo yourCommandThatMustBeRunAsRoot arg1 arg2);

man pages for sudo, sudoers and visudo  are good resources.  I am pretty
sure 7.3 had the rpm available.

visudo MUST be used to edit the sudoers file.  you can add the following
line to get you started

apache  ALL=(root) NOPASSWD:yourCommandThatMustBeRunAsRoot, someotherCmd

What this says is let the user apache run yourCommandThatMustBeRunAsRoot
and someotherCmd without having to enter a passwd.  There are some
things you can do to limit the arguments that can be passed to the
commands see the man pages.

Very cool stuff with finegrained permission on what can be run by who.

Bret

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Exec() command on UNIX

2004-12-01 Thread Greg Donald
On Wed, 1 Dec 2004 16:18:01 +0700, Sitthipong Thuetham [EMAIL PROTECTED] 
wrote:
 Dear PHP support,
 
 I have a question on an exec() command, if I would like to switch user right 
 on Unix server, what command should I use?
 
 example: on the UNIX shell will be like below
 $su root
 Password:'password'
 
 but when I tried running exec() command on PHP, I couldn't do that
 exec(su root);
 
 I can't sent a password thru the exec() command, any way to do that?


You might want to look at sudo, you can provide temporary root access
with no password.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Exec() command on UNIX

2004-12-01 Thread Richard Lynch
Sitthipong Thuetham wrote:
 I have a question on an exec() command, if I would like to switch user
 right on Unix server, what command should I use?

 example: on the UNIX shell will be like below
 $su root
 Password:'password'

 but when I tried running exec() command on PHP, I couldn't do that
 exec(su root);

 I can't sent a password thru the exec() command, any way to do that?

Probably best to use 'sudo' in the shell to make the script run with the
rights of the user you want, or some similar shell-action.

You may also want to examine the Apache 2 directives that let a Module (EG
PHP) run as a specific user under certain circumstances.  I have not
investigated this avenue myself, but would surmise that you could restrict
this to a specific script in a specific directory, and could give over the
PHP thread to be run by some special user.  While I'm not certain, I'd be
willing to bet cold hard cash that doing this and using root as that
special user is a REALLY BAD IDEA.  You'd need to set up a new user with
*JUST* enough permission on the system to do the bare minimum of what you
need that user to do to get the task accomplished.

If, however, you are stuck on a server where you don't HAVE access to a
shell and/or httpd.conf...

Well, first, start looking for a new host where you DO have access to a
shell, at least.

In the meantime, you can sometimes do like this:

exec(echo _password_ | command $arg1 $arg2);

Note, however, that su itself specifically prohibits doing this from a
non TTY shell (EG from PHP) to prevent you from doing this inherently very
dangerous action.

Also note that depending on the version of PHP and other factors I never
quite figured out back in the day (PHP 3  PHP 4) sometimes stdout/stdin
were bound up by PHP and sometimes not, so that the shell echo and |
trick would only work on some versions/servers.  Some PHP Developers
claimed this was simply not true, however, despite my experience.  YMMV.
:-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php command to open a url?

2004-10-31 Thread Lists
 header (Location: ./);
 exit;
I use the above at the end of a authorization script, to direct back to 
a page.

On Oct 31, 2004, at 12:03 PM, Ken Tozier wrote:
I've been looking around in the php documentation for a couple of 
hours now but can't seem to find any functions to open a url in the 
current browser window. Does php allow this? If so, could someone 
point me to a link?

Basically what I'm trying to do is loop back in a login form until a 
user enters a valid username/password and then redirect to that user's 
personal info page.

Thanks for any help
Ken
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Command Line Scripts 'Aborting' at end ...

2004-10-28 Thread Curt Zirzow
* Thus wrote Marc G. Fournier:
 
 Note that the following is based on php installed via the FreeBSD ports 
 system ...
 
 
 
 I'm getting a core file, but if I try:
 
 gdb /usr/local/bin/php php.core ... its definitely not looking good:
 
 s# gdb /usr/local/bin/php php.core
 ...
 
 Core was generated by `php'.
 Program terminated with signal 6, Abort trap.
 Reading symbols from /usr/lib/libcrypt.so.2...done.
 Reading symbols from /usr/lib/libm.so.2...done.
 Reading symbols from /usr/lib/libc.so.4...done.
 Reading symbols from /usr/local/lib/php/20020429/interbase.so...done.
 Reading symbols from /usr/local/firebird/lib/libfbembed.so.1...Deprecated 
 bfd_read called at 
 /usr/src/gnu/usr.bin/binutils/gdb/../../../../contrib/gdb/gdb/dwarf2read.c 
 line 3049 in dwarf2_read_section
 Error while reading shared library symbols:
 Dwarf Error: Cannot handle DW_FORM_strp in DWARF reader.
 Reading symbols from /usr/lib/libncurses.so.5...done.
 Error while reading shared library symbols:
 ì: No such file or directory.
 Error while reading shared library symbols:
 ynamic: No such file or directory.
 Segmentation fault (core dumped)

Interesting core dump :)

Try running php directly from gdb instead of reading the core file:
  % gdb /usr/loca/bin/php
  ...
   run script.php
  ...
   bt
 
See if that produces a better backtrace.


 
 mod_php4 appears to work fine, just the command line version seems to be 
 off ... and its running, producing expected output, its just that last 
 'Abort' that tends to screw things up a bit ...

My bet is you have a buggy library somewhere, ncurses being a
viable candidate since it does not get loaded in  mod_php4.


Curt
-- 
Quoth the Raven, Nevermore.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Command Line Scripts 'Aborting' at end ...

2004-10-27 Thread Greg Donald
On Wed, 27 Oct 2004 13:44:54 -0300 (ADT), Marc G. Fournier
[EMAIL PROTECTED] wrote:
 
 Not sure how to debug ... help?

You said you installed in via ports, so did you happen to check the
'debug' option when you installed it?

[ ] DEBUG Enable debug

Just a question.. as that might help explain more what's going on.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Command Line Scripts 'Aborting' at end ...

2004-10-27 Thread Greg Donald
On Wed, 27 Oct 2004 13:44:54 -0300 (ADT), Marc G. Fournier
[EMAIL PROTECTED] wrote:
 
 I have a really simple PHP script that, when you run it, generates an
 Abort at the end of it:
 
 ams# /tmp/test.php
 testAbort (core dumped)

I just installed php4-cgi on a FreeBSD 4.10 system I have.  The same
test.php script runs fine for me.

 cat test.php
#!/usr/local/bin/php
?php
echo test;
?

 ./test.php
Content-type: text/html
X-Powered-By: PHP/4.3.9

test


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Command Line Scripts 'Aborting' at end ...

2004-10-27 Thread Marc G. Fournier
I just did a reinstall from ports, and it works now as well ... maybe a 
stale library for one of hte modules :(

thanks ...
On Wed, 27 Oct 2004, Greg Donald wrote:
On Wed, 27 Oct 2004 13:44:54 -0300 (ADT), Marc G. Fournier
[EMAIL PROTECTED] wrote:
I have a really simple PHP script that, when you run it, generates an
Abort at the end of it:
ams# /tmp/test.php
testAbort (core dumped)
I just installed php4-cgi on a FreeBSD 4.10 system I have.  The same
test.php script runs fine for me.
cat test.php
#!/usr/local/bin/php
?php
   echo test;
?
./test.php
Content-type: text/html
X-Powered-By: PHP/4.3.9
test
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Marc G. Fournier   Hub.Org Networking Services (http://www.hub.org)
Email: [EMAIL PROTECTED]   Yahoo!: yscrappy  ICQ: 7615664
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] System Command and snmp commands

2004-10-26 Thread Mulley, Nikhil

Tring Tring .


Just to ring please help me.
I am giving to out print_r($ret) then it returns 1 at 

exec(' snmpget -v 2c -c public 10.103.16.14  sysUpTime.0',$ret);

--Nikhil



-Original Message-
From: Mulley, Nikhil [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 26, 2004 12:41 PM
To: [EMAIL PROTECTED]
Subject: [PHP] System Command and snmp commands


Hi All,
 
I want to use system command to perform snmp queries on a remote machine and the 
problem is that I want to store the output /result in an Array , so that I can later 
use it for parsing purposes.I know I could use exec and passthru statements 
actually,But I am unable to store the result in the array or I am unsure whether the 
result is not getting stored in the array 
 
 
Here is the code 
 
 
?php
exec(' snmpget -v 2c -c public 10.103.16.14  sysUpTime.0',$ret);
list($a)=split('[,]',$ret);
echo $a[0];
 
?  
 
Point me , if any thing wrong in the code
 
Please help me.
 
 
Thanks,
Nikhil.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] system command

2004-08-24 Thread Daniel Schierbeck
Ron Clark wrote:
Capture the output in 
the $output variable then ob_clean to empty the output buffer before 
printing the the desired message.
ob_get_clean() is preferable:
$output = ob_get_clean(); // Gets the buffered output and cleans the buffer
--
Daniel Schierbeck
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] system command

2004-08-24 Thread ron clark
Daniel Schierbeck wrote:
Ron Clark wrote:
Capture the output in the $output variable then ob_clean to empty the 
output buffer before printing the the desired message.

ob_get_clean() is preferable:
$output = ob_get_clean(); // Gets the buffered output and cleans 
the buffer

Didn't need the contents of the buffer. All I needed was the last line 
which was contained in $output = system().

--
Ron Clark
System Administrator/Web Coordinator
Armstrong Atlantic State University
11935 Abercorn Street 
Savannah, Ga 31419
Phone: 912 961 3234
Fax: 912 927 5353

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] system command

2004-08-24 Thread Daniel Schierbeck
Ron Clark wrote:
Daniel Schierbeck wrote:
Ron Clark wrote:
Capture the output in the $output variable then ob_clean to empty the 
output buffer before printing the the desired message.

ob_get_clean() is preferable:
$output = ob_get_clean(); // Gets the buffered output and cleans 
the buffer

Didn't need the contents of the buffer. All I needed was the last line 
which was contained in $output = system().

Sorry, my bad...
--
Daniel Schierbeck
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] system command

2004-08-23 Thread John Holmes
From: ron clark [EMAIL PROTECTED]
I an trying to add virus scanning to the file upload section of our portal 
using uvscan. The virus scanning is working properly using a system call , 
but I am having problems with formatting the output. I need to check the 
return value and if it is not a 0, I want to create a custom message. The 
problem is, when using system the output of the call is flushed to the 
browser before I can write the custom message so I have the uvscan message 
and then my custom message.
You can use output_buffering to capture the output, or use a different 
method to make the call, i.e. backticks or exec(), which allow you to 
capture the output before it's displayed.

---John Holmes... 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] system command

2004-08-23 Thread Jason Wong
On Tuesday 24 August 2004 03:49, ron clark wrote:
 I an trying to add virus scanning to the file upload section of our
 portal using uvscan. The virus scanning is working properly using a
 system call , but I am having problems with formatting the output. I
 need to check the return value and if it is not a 0, I want to create a
 custom message. The problem is, when using system the output of the call
 is flushed to the browser before I can write the custom message so I
 have the uvscan message and then my custom message.

The system() function has a few siblings, check them out.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Democracy is a process by which the people are free to choose the man who
will get the blame.
-- Laurence J. Peter
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re:[PHP] system command

2004-08-23 Thread ron clark
John Holmes wrote:
From: ron clark [EMAIL PROTECTED]
I an trying to add virus scanning to the file upload section of our 
portal using uvscan. The virus scanning is working properly using a 
system call , but I am having problems with formatting the output. I 
need to check the return value and if it is not a 0, I want to create 
a custom message. The problem is, when using system the output of the 
call is flushed to the browser before I can write the custom message 
so I have the uvscan message and then my custom message.

You can use output_buffering to capture the output, or use a different 
method to make the call, i.e. backticks or exec(), which allow you to 
capture the output before it's displayed.

---John Holmes...

Thanks John. Was a simple fix. Turn output buffering on to prevent the 
output of the system command going to the browser. Capture the output in 
the $output variable then ob_clean to empty the output buffer before 
printing the the desired message.

--
Ron Clark
System Administrator/Web Coordinator
Armstrong Atlantic State University
11935 Abercorn Street 
Savannah, Ga 31419
Phone: 912 961 3234
Fax: 912 927 5353

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Linux command in PHP

2004-05-12 Thread Jay Blanchard
[snip]
Today I tried to add another  option, that gives sound and send email.
The script works ok when I run from  shell. But when I add the code to 
cronjob, the email is send but NO SOUND. Any ideas what can cause such 
problem?

# Below the code that start the xmms sound
$alert = /usr/bin/xmms /home/mike/Desktop/song1.mp3;
`$alert';
[/snip]

The problem is caused by bad code. See http://www.php.net/exec

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Linux command in PHP

2004-05-12 Thread Curt Zirzow
* Thus wrote Mike Mapsnac ([EMAIL PROTECTED]):
 I have script  that basically process a file. If  something found in the 
 file, the script send email.
 
 Today I tried to add another  option, that gives sound and send email.
 The script works ok when I run from  shell. But when I add the code to 
 cronjob, the email is send but NO SOUND. Any ideas what can cause such 
 problem?
 
 # Below the code that start the xmms sound
 $alert = /usr/bin/xmms /home/mike/Desktop/song1.mp3;

 `$alert';

This is an X problem, not php. xmms has no clue what :display to 
run xmms on.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] system command?

2004-05-11 Thread Jason Wong
On Monday 10 May 2004 23:00, Jas wrote:

 I didn't sent off list, always to php.general in reply to whatever
 message thread I am in.  In any event, I have tried safe mode = On and
 safe mode = Off with the 4 commands I listed in my last thread and my
 actual code is using an echo = textarea$tailed/textarea;

  echo = textarea$tailed/textarea;

is not good code. Please learn some basic PHP first!

 I even tried to remove the -f and replaced it with a -n 600 (for six
 hundred lines to be output) and it still wont place the $tailed var into
 the textarea.  It will output to the screen but not to the textarea, I
 am just going to scrap it and try it a different way.

Each of the 4 commands I listed in my last thread has a different 
functionality. As you have noted one of them just outputs directly whatever 
system function is being executed. Read the descriptions of the 'commands' 
carefully and choose the one appropriate for the job.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
We don't know who it was that discovered water, but we're pretty sure
that it wasn't a fish.
-- Marshall McLuhan
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] system command?

2004-05-10 Thread Jay Blanchard
[snip]
Anyone know what this wouldn't work?  I have tried using a couple of 
functions defined at http://us2.php.net/manual/en/ref.exec.php and none 
seem to have the desired effect.

?php
$tailed = shell_exec('tail -f /path/to/log');
//$tailed = exec('tail -f /path/to/log');
//$tailed = system('tail -f /path/to/log');
print = textarea$tailed/textarea;
?
[/snip]

Is PHP running in safe mode? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] system command?

2004-05-10 Thread Adam Voigt
I believe when you add the -f flag, the tail command doesn't exit, it
just keeps printing as data is appended to the log, did you try dropping
the -f flag?


On Mon, 2004-05-10 at 10:15, Jas wrote:
 Anyone know what this wouldn't work?  I have tried using a couple of 
 functions defined at http://us2.php.net/manual/en/ref.exec.php and none 
 seem to have the desired effect.
 
 ?php
 $tailed = shell_exec('tail -f /path/to/log');
 //$tailed = exec('tail -f /path/to/log');
 //$tailed = system('tail -f /path/to/log');
 print = textarea$tailed/textarea;
 ?
 
 Thanks in advance,
 Jas
-- 

Adam Voigt
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] system command?

2004-05-10 Thread Daniel Purdy
[snip]
 Anyone know what this wouldn't work?  I have tried using a couple of
 functions defined at http://us2.php.net/manual/en/ref.exec.php and
none 
 seem to have the desired effect.
 
 ?php
 $tailed = shell_exec('tail -f /path/to/log');
 //$tailed = exec('tail -f /path/to/log');
 //$tailed = system('tail -f /path/to/log');
 print = textarea$tailed/textarea;
 ?
[/snip]

Take a look at your print statement, print =
textarea$tailed/textarea;
That should throw a parse error. Try print(textarea . $tailed .
/textarea); HTH!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] system command?

2004-05-10 Thread John Nichel
Jas wrote:
Anyone know what this wouldn't work?  I have tried using a couple of 
functions defined at http://us2.php.net/manual/en/ref.exec.php and none 
seem to have the desired effect.

?php
$tailed = shell_exec('tail -f /path/to/log');
//$tailed = exec('tail -f /path/to/log');
//$tailed = system('tail -f /path/to/log');
print = textarea$tailed/textarea;
?
Thanks in advance,
Jas
'tail -f' won't exit.

--
John C. Nichel
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] system command?

2004-05-10 Thread Jay Blanchard
[snip]
It is now... but it still doesn't work.  I have tried passthru(), 
exec(), shell_exec()  system() trying to tail -f a log file into a 
textarea box and I get nothing or the output is put in the headers and 
stops the rest of the page from loading.  I am at a loss.

Jay Blanchard wrote:

 [snip]
 Anyone know what this wouldn't work?  I have tried using a couple of 
 functions defined at http://us2.php.net/manual/en/ref.exec.php and
none 
 seem to have the desired effect.
 
 ?php
 $tailed = shell_exec('tail -f /path/to/log');
 //$tailed = exec('tail -f /path/to/log');
 //$tailed = system('tail -f /path/to/log');
 print = textarea$tailed/textarea;
 ?
 [/snip]
 
 Is PHP running in safe mode? 
[/snip]

a. safe mode must be OFF
b. you must remove the = from the print statement, should be thrwoing
a syntax erro
c. get rid of the -f as it will not continue to update the text area
d. do not reply off-list unless requested

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] system command?

2004-05-10 Thread Jas
I didn't sent off list, always to php.general in reply to whatever 
message thread I am in.  In any event, I have tried safe mode = On and 
safe mode = Off with the 4 commands I listed in my last thread and my 
actual code is using an echo = textarea$tailed/textarea;

I even tried to remove the -f and replaced it with a -n 600 (for six 
hundred lines to be output) and it still wont place the $tailed var into 
the textarea.  It will output to the screen but not to the textarea, I 
am just going to scrap it and try it a different way.

Cheers,
Jas
Jay Blanchard wrote:

[snip]
It is now... but it still doesn't work.  I have tried passthru(), 
exec(), shell_exec()  system() trying to tail -f a log file into a 
textarea box and I get nothing or the output is put in the headers and 
stops the rest of the page from loading.  I am at a loss.

Jay Blanchard wrote:


[snip]
Anyone know what this wouldn't work?  I have tried using a couple of 
functions defined at http://us2.php.net/manual/en/ref.exec.php and
none 

seem to have the desired effect.

?php
$tailed = shell_exec('tail -f /path/to/log');
//$tailed = exec('tail -f /path/to/log');
//$tailed = system('tail -f /path/to/log');
print = textarea$tailed/textarea;
?
[/snip]
Is PHP running in safe mode? 
[/snip]

a. safe mode must be OFF
b. you must remove the = from the print statement, should be thrwoing
a syntax erro
c. get rid of the -f as it will not continue to update the text area
d. do not reply off-list unless requested
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] system command?

2004-05-10 Thread Jay Blanchard
[snip]
I didn't sent off list, always to php.general in reply to whatever 
message thread I am in.  In any event, I have tried safe mode = On and 
safe mode = Off with the 4 commands I listed in my last thread and my 
actual code is using an echo = textarea$tailed/textarea;

?php
$tailed = shell_exec('tail -f /path/to/log');
//$tailed = exec('tail -f /path/to/log');
//$tailed = system('tail -f /path/to/log');
print = textarea$tailed/textarea;
?
[/snip]

?php
$tailed = shell_exec('tail /path/to/log');
print = textarea$tailed/textarea;
?

I can only think that it must be a permissions issue. What happens if
you run the script from the command line?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] system command?

2004-05-10 Thread Jay Blanchard
[snip]
I didn't sent off list
[/snip]

I am in an relatively crappy mood this day, you may want to NOT refute
something I have said and in essence call me a liar. You'll get little
help that way.

P.S. Stop top posting too.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] system command?

2004-05-10 Thread Adam Voigt
lol

On Mon, 2004-05-10 at 11:16, Jay Blanchard wrote:
 [snip]
 I didn't sent off list
 [/snip]
 
 I am in an relatively crappy mood this day, you may want to NOT refute
 something I have said and in essence call me a liar. You'll get little
 help that way.
 
 P.S. Stop top posting too.
-- 

Adam Voigt
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] system command?

2004-05-10 Thread Jay Blanchard
[snip]
?php
$tailed = shell_exec('tail /path/to/log');
print = textarea$tailed/textarea;
?
[/snip]

I forgot to take out the =

?php
$tailed = shell_exec('tail /path/to/log');
print = textarea$tailed/textarea;
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Str_Replace Command

2004-02-02 Thread Jason Wong
On Tuesday 03 February 2004 00:14, Christopher J. Crane wrote:

   $StockURL =
 http://finance.yahoo.com/d/quotes.txt?s=xrx,ikn,dankyf=sl1e=.txt;;
   $StockResults = implode('', file($StockURL));
   $Rows = split(\n, $StockResults);
   foreach($Rows as $Row) { echo str_replace('',,$Row).br\n; }
   foreach($Rows as $Row) { str_replace('',,$Row); echo $Row.br\n; }

str_replace() RETURNS the replaced string. It does not alter $Row.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Spiritual leadership should remain spiritual leadership and the temporal
power should not become too important in any church.
- Eleanor Roosevelt
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Str_Replace Command

2004-02-02 Thread Christopher J. Crane
Ok I got around it by the following, but now I have a new problem. I can not
get the two dimensional array working. I want to later be able to output a
variable like this $TickerData[IKN] and it will output the associated
$Price.

  $StockURL =
http://finance.yahoo.com/d/quotes.txt?s=xrx,ikn,dankyf=sl1e=.txt;;
  $StockResults = implode('', file($StockURL));
  $Rows = split(\n, $StockResults);
  foreach($Rows as $Row) {
list($Symbol, $Price) = split(,, $Row);
   $Symbol = str_replace('', , $Symbol);
   $TickerData = array($Symbol=$Ticker);
}
  print_r($TickerData);
  echo $TickerData[IKN].br\n;




Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Tuesday 03 February 2004 00:14, Christopher J. Crane wrote:

$StockURL =
  http://finance.yahoo.com/d/quotes.txt?s=xrx,ikn,dankyf=sl1e=.txt;;
$StockResults = implode('', file($StockURL));
$Rows = split(\n, $StockResults);
foreach($Rows as $Row) { echo str_replace('',,$Row).br\n; }
foreach($Rows as $Row) { str_replace('',,$Row); echo
$Row.br\n; }

 str_replace() RETURNS the replaced string. It does not alter $Row.

 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Spiritual leadership should remain spiritual leadership and the temporal
 power should not become too important in any church.
 - Eleanor Roosevelt
 */

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Str_Replace Command

2004-02-02 Thread Jason Wong
On Tuesday 03 February 2004 00:52, Christopher J. Crane wrote:
 Ok I got around it by the following, but now I have a new problem. I can
 not get the two dimensional array working. I want to later be able to
 output a variable like this $TickerData[IKN] and it will output the
 associated $Price.

   print_r($TickerData);

So what does the above show? If it isn't what you expect, figure out *why*. 
Like how is $TickerData being assigned.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
We have phasers, I vote we blast 'em!
-- Bailey, The Corbomite Maneuver, stardate 1514.2
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Str_Replace Command

2004-02-02 Thread Christopher J. Crane
Well this is it and it is really got me...
Echoing out the $Symbol and $Price works just fine one row about the
$TickerData array assignment. Yet it outputs nothing.
Array ( [] = ) is what I get. If I change the line to
$TickerData = array ($Symbol = $Price); I get nothing, or the same
result. If I change the line to
$TickerData = array ('$Symbo'l = '$Price'); I get the following
Array ( [$Symbol] = $Price ) which tells me the assignment works, but it
seems like the $Symbol and $Price variable are blank when assigning to the
array. I know that they are not blank since they echoed out just fine one
line above.GRR



  $StockURL =
http://finance.yahoo.com/d/quotes.txt?s=xrx,ikn,dankyf=sl1e=.txt;;
  $StockResults = implode('', file($StockURL));
  $Rows = split(\n, $StockResults);
  foreach($Rows as $Row) {
list($Symbol, $Price) = split(,, $Row);
 $Symbol = str_replace('', , $Symbol);
echo $Symbol. - .$Price.br\n;
$TickerData = array ($Symbol = $Price);
}
  print_r($TickerData);



Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Tuesday 03 February 2004 00:52, Christopher J. Crane wrote:
  Ok I got around it by the following, but now I have a new problem. I can
  not get the two dimensional array working. I want to later be able to
  output a variable like this $TickerData[IKN] and it will output the
  associated $Price.

print_r($TickerData);

 So what does the above show? If it isn't what you expect, figure out
*why*.
 Like how is $TickerData being assigned.

 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 We have phasers, I vote we blast 'em!
 -- Bailey, The Corbomite Maneuver, stardate 1514.2
 */

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Str_Replace Command

2004-02-02 Thread Jason Wong
On Tuesday 03 February 2004 01:09, Christopher J. Crane wrote:
 Well this is it and it is really got me...
 Echoing out the $Symbol and $Price works just fine one row about the
 $TickerData array assignment. Yet it outputs nothing.
 Array ( [] = ) is what I get. If I change the line to
 $TickerData = array ($Symbol = $Price); I get nothing, or the same
 result. If I change the line to
 $TickerData = array ('$Symbo'l = '$Price'); I get the following
 Array ( [$Symbol] = $Price ) which tells me the assignment works, but it
 seems like the $Symbol and $Price variable are blank when assigning to the
 array. I know that they are not blank since they echoed out just fine one
 line above.GRR

Are you sure that the line: echo $Symbol ...
is displaying something sensible for each $Row?

You're overwriting $TickerData at each iteration of the foreach-loop thus if 
your last $Row doesn't contain something sensible neither would $TickerData.

You probably want to use this assignment instead:

  $TickerData[$Symbol] = $Price;

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
TANSTAAFL
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Str_Replace Command

2004-02-02 Thread Matt Matijevich
snip
  $StockURL =
http://finance.yahoo.com/d/quotes.txt?s=xrx,ikn,dankyf=sl1e=.txt;;
  $StockResults = implode('', file($StockURL));
  $Rows = split(\n, $StockResults);
  foreach($Rows as $Row) {
list($Symbol, $Price) = split(,, $Row);
 $Symbol = str_replace('', , $Symbol);
echo $Symbol. - .$Price.br\n;
$TickerData = array ($Symbol = $Price);
}
  print_r($TickerData);
/snip

why not replace:
$TickerData = array ($Symbol = $Price);

that line reassigns $TickerData to a array with one element in it
everytime you call it.  The last time through your loop, $Symbol = ''
and $Price = '', so you get Array ( [] = ) when you print_r

with this:
$TickerData[$Symbol] = $Price;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  1   2   >