Jump to content

Recommended Posts

Hello.  Im running the folloging code and its not doing quite what i want.  When i run a command through the shell_exec() function i want to decide what happens next, based on whethe anything was returned.  Eg, if the code is to create a file, and it works, there should be no responce, and thus i want to carry on, after deleting the database row.  However if something is retured, (for example, 'directory already exists') then i want it it update the database and break;

The problem is it alway reacts as if nothing has been returned.  Can anyone help?

[code]foreach($c as $value)
{
$return = shell_exec($value);

if ($return == "")
{
$remove = "DELETE FROM table WHERE id LIKE $id";
                pg_query($pg_connection, $remove);
}
Else
{
$error_report = "UPDATE table SET error = 'Error: ".$return."' WHERE id = '".$id."'";
break;
}
}[/code]


- Thanks
Link to comment
https://forums.phpfreaks.com/topic/33147-return-from-shell_exec-in-if-statment/
Share on other sites

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.