Jump to content

return from shell_exec in if statment.


the_oliver

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.