0

I currently use this code:

if(isset($_POST['url']) && isset($_POST['trefwoorden']) )
{
  mysql_connect('localhost', 'crawler', 'whathasbeenseencannotbeunseen');
  mysql_select_db("crawler");
  mysql_query("INSERT INTO jobs (jobID, url, trefwoorden) VALUES ('', '".$_POST['url']."', '".$_POST['trefwoorden']."')");
  $output = shell_exec("./content.php " .mysql_insert_id());
  echo $output;

}

In my content.php I have the following code:

#!/usr/bin/php
<?php
echo 'HET WERKT';
?>

Now I want to see if my shell_exec actually works by filling in the form and submitting it: but it doesn't echo anything at all.

Did I write wrong code?

hakre
  • 193,403
  • 52
  • 435
  • 836
  • Did you install the CLI (command-line interface) to PHP? Does /usr/bin/php exist? Is content.php executable? Did you try to run it from the shell? – Edgar Bonet Oct 04 '10 at 09:41
  • I might tell a mistake but shouldn't it be `$output = shell_exec("./content.php");$output .= mysql_insert_id();` ? 'Cause it doesn't seem to me that `mysql_insert_id()` is a part of the shell cmd... I might be wrong, enlight me! http://www.php.net/manual/en/function.shell-exec.php – Shikiryu Oct 04 '10 at 10:57

3 Answers3

1

Try this. This may help you.

shell_exec('usr/local/bin/php -l content.php'. mysql_insert_id())

or

shell_exec('usr/local/bin/php -content.php'. mysql_insert_id())

All the best.

Thanks,

Kanji

  • Also not working for me, got some random tests working but my actual code won't start. Will reply if any of your code work :)! –  Oct 04 '10 at 12:47
0

.. Maybe this will work for you:

shell_exec('php -l content.php'. mysql_insert_id())

Or;

  1. PHP is running in safe_mode
  2. Apache does not have the permissions to execute the script
Bas van Dorst
  • 6,632
  • 3
  • 17
  • 12
  • Doesn't give my echo back, returns: no errors detected in content.php –  Oct 04 '10 at 11:29
0

Why do you invoke a PHP file and not including it?

Besides, I agree with Chouchenos because this line of code:

shell_exec('php -l content.php'. mysql_insert_id())

will execute like this "php -l content.php132" if mysql_insert_id() returns the id 132.

This might be a problem because content.php132 might not be existant.

рüффп
  • 5,172
  • 34
  • 67
  • 113
ITroubs
  • 11,094
  • 4
  • 27
  • 25
  • Because i need to get a process on the background to speed up my process of crawling webpage. –  Oct 04 '10 at 14:28
  • hmm try this mysql_query("INSERT INTO jobs (jobID, url, trefwoorden,used) VALUES ('', '".$_POST['url']."', '".$_POST['trefwoorden']."',0)"); and add a line in that takes the lowes jobID that is not used to the content.php and lat it work on that job. – ITroubs Oct 04 '10 at 14:37