Current location: Hot Scripts Forums » Programming Languages » PHP » a small problem and urgent


a small problem and urgent

Reply
  #1 (permalink)  
Old 08-25-06, 03:17 AM
mohit's Avatar
mohit mohit is offline
Newbie Coder
 
Join Date: Jul 2006
Location: India
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
a small problem and urgent

greetings to all

when i'm passing this parameter to executable and i'm catching this value in executable and i'm writing these variable value in text file via executable or say executable writting these variable value in text file. but it is not working ...
Code:
exec('search.pl $stringData $stringval',$output);
or
$output = shell_exec('search.pl $stringData $stringval');
i'm getting in return this
"$stringData$stringval" instead of it's value
where
$stringData="mohit";
$stringval=0;

can you help me where i'm going wrong.

thanks
mohit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-25-06, 03:19 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Try using double quotes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-25-06, 03:35 AM
mohit's Avatar
mohit mohit is offline
Newbie Coder
 
Join Date: Jul 2006
Location: India
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
yes it worked but when i used like this
Code:
$output = shell_exec('search.pl $stringData $stringval');

where
$stringData=" ";
$stringval=0;
i.e. when one parameter is blank then i got problem because in exe i'm handling like this
Code:
 $q=$ARGV[0];
 $offset=$ARGV[1];
so when passing both parameter then it's ok. but in case of single..you can imagine..

so what to do now...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-25-06, 04:08 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
just check if both vars are not empty:
PHP Code:

if(!empty(trim($stringData)) && !empty(trim($stringval))){

  
shell_exec("search.pl $stringData $stringval");

trim is used to remove whitespace at the beginning and at the end of a string

Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 08-25-06, 04:18 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
empty() and trim() won't work together like that. You have to trim the variable outside the empty().
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 08-25-06, 04:24 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
Quote:
Originally Posted by nico_swd
empty() and trim() won't work together like that. You have to trim the variable outside the empty().
why's that? i didn't know that
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 08-25-06, 04:31 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
This is the error that PHP returns when trying to do so.

Quote:
Fatal error: Can't use function return value in write context in C:\xampp\htdocs\random_scripts\empty_trim.php on line 6
Stupid thing. Would be pretty handy if it worked.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 08-25-06, 05:04 AM
mohit's Avatar
mohit mohit is offline
Newbie Coder
 
Join Date: Jul 2006
Location: India
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
this thing also not working

if (!empty($stringData) && !empty($stringval))

overall mean i need to check it before calling.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 08-25-06, 05:09 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
If $stringval is set to 0, like in the example above, then empty() will return true as well. You could try this:

PHP Code:

if (trim($stringval) != '' AND trim($stringData) != '')) 

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 08-25-06, 05:11 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
a little too late

can you post the code you're using right now? it should work, unless you made a mistak somewhere else in your code
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem working with createimagefromjpeg URGENT!! debasys PHP 2 06-03-06 01:45 AM
DTS speed problem! Naresh Rohra Visual Basic 1 03-01-06 09:47 AM
Urgent: Appending path for DLLs instread of using the real one chuck59 Visual Basic 0 10-29-05 03:19 AM
Small but urgent help needed GemiLinge PHP 3 10-04-05 09:15 AM
Urgent! Update fields problem Ogmios PHP 1 05-12-04 01:59 AM


All times are GMT -5. The time now is 12:16 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.