Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No data displayed from PHP script

Status
Not open for further replies.

cmarchman

Programmer
Jun 18, 2004
56
US
I've done the searching and even in the "View Source" the results do not show up. When I run the script from the command line the results look fine, no errors.

The browser is Mozilla running on Fedora 3.

The code:


<?php

$command = "/usr/bin/mysql -u root -pxxxxxxxx < mydbtest.txt | sed /Database/d | sed /mysql/d | sed /test/d";
$dblist = exec($command, $db);

foreach($db as $list) {

print "The following link is for the Results contained in Database <a href=ipsh.php?database=$list>$list</a> scanned on:<br>";
mysql_connect("xxx.xxx.xxx.xxx", "root", "xxxxxxx");
$timedate = mysql_query(
"select timestamp from $list.timestamps where id = 1");

while ($row = mysql_fetch_assoc($timedate)) {

$date = $row["timestamp"];
print "<b>$date</b>";

}
print "<br><br><br><br>";
}
?>

This whole area does not show up in "View Source" or the browser, but run command line and everything looks good.

Any assistance will be greatly appreciated.

Thanks,


cmarchman
 
I intuit it's a permission problem. The web server is trying to run the command as one user, but when you run it form the command-line, you're running it as another.

What do your Apache logs say about all this?

If there's no errors there, do a simpler test. If you run the following script:

Code:
<?php
print exec ('/usr/bin/mysql -v');
?>

what do you get?




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
sleipnir214,

Everything is being run as root rwxr_xr_x and I don't get anything from the code you provided.

Thanks,

cmarchman
 
Are you sure about "everything is run as root"? The Apache web server usually runs as the user "nobody" or maybe " If you're running it as "root" and you're connected to any network, you've opened up a BIG security hole on your machine.

Ken
 
Okay, in the httpd.conf file the User and Group was set to "apache". I did change them to "nobody", then restarted httpd and mysqld - still no display.

As far as the httpd running as root, should I change the owner to nobody?

Thanks,

cmarchman
 
No don't change any owner ships.

Does the "standard" test program produce results?
Code:
<?
phpinfo();
?>

Also, what are you trying to accomplish with your code? Perhaps there is a better/different way of doing it.

Ken
 
kenrbnsn,

The "standard" test returned the expected php info page, so I know that php works. I've got a thread rs\unning in the MySQL forum as well to try both ends of the spectrum.

I've had this same setup running on other systems, which is why I'm at a loss.

As far as what I'm trying to accomplish, this is a site for taking Nessus scanned data that is in the MySQL db and display the data in researchable form. I know all the commands are good as they have worked previously. If I can get this one part to display on the initial page, then I know the rest will fall into place as it should.

Thanks,

cmarchman
 
I'm still not convinced it's not a permissions problem.

Get logged onto your system as root. "su" to login as the user apache. Then try to run the script from the command line. What do you get?


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
The apache account is not currently available.

cmarchman
 
I have been. I've tried running it as root and as the only other user on the system. Still the same results.

I've logged in as the user - ran the script - no output.
I've logged in as root - ran the script - no output.
I've logged in as the user - su to root - ran the script - no output.

cmarchman
 
Problem solved. Here's the resolution that helped me out:

It seems that the default build of Fedora Core 3 will implement the SELinux module that causes Apache to not recognize other programs until the proper permissions are setup between Apache and the connecting programs. I really didn't have time to get too involved in researching this, so in the interim, as this is a test system, I simply rebuilt the Fedora Core 3 without the SELinux support and everything started talking with each other.

Thanks for all the useful info and help.

Thanks,

cmarchman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top