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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL_queries not displaying on Browser

Status
Not open for further replies.

cmarchman

Programmer
Jun 18, 2004
56
US
Hi. I have a problem with a Fedora Core 3 server build running Apache 2.0.52-3, PHP 4.3.9-3, MySQL-server 3.23.58-13. It also has the php-mysql-4.3.9-3 installed.

The problem - bringing up Mozilla browser on localhost (for testiing purposes) the index.php page displayes fine, except the mysql_query results do not show up. Nothing within the PHP tags show up, not even errors.

I've substituted the phpinfo (); within the php tags and it displayed the php info page with no problems. So, I can only think that it has to do with mysql or Mozilla.

Here is a sample code:


<?php

$command = "/usr/bin/mysql -u root -pfr33bas3 < mydbtest.txt | sed /Database/d | sed /mysql/d | sed /test/d | sed /snort/d | sed /snortcenter/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", "xxxxxxxx");
$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>";
}
?>


I have had this working on other systems, mainly RH builds, so I know it works.

Also, this is being run from a VMWare image, but I'm not sure if that would make a difference.

Thanks in advance,

cmarchman
 
run that script using php from command line and see what happens. at the prompt do

php abovescript.php
 
azzazzello,

Whoa! What a mess. I see now that it is a PHP issue.
Look at what I got back:

PHP Notice: Constant MYSQL_ASSOC already defined in Unknown on line 0
PHP Notice: Constant MYSQL_NUM already defined in Unknown on line 0
PHP Notice: Constant MYSQL_BOTH already defined in Unknown on line 0
PHP Notice: Constant MYSQL_CLIENT_COMPRESS already defined in Unknown on line 0PHP Notice: Constant MYSQL_CLIENT_INTERACTIVE already defined in Unknown on line 0
PHP Notice: Constant MYSQL_CLIENT_IGNORE_SPACE already defined in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_connect in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_pconnect in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_close in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_select_db in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_create_db in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_drop_db in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_query in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_unbuffered_query in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_db_query in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_list_dbs in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_list_tables in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_list_fields in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_list_processes in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_error in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_errno in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_affected_rows in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_insert_id in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_result in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_num_rows in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_num_fields in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fetch_row in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fetch_array in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fetch_assoc in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fetch_object in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_data_seek in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fetch_lengths in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fetch_field in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_field_seek in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_free_result in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_field_name in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_field_table in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_field_len in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_field_type in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_field_flags in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_escape_string in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_real_escape_string in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_stat in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_thread_id in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_client_encoding in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_ping in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_get_client_info in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_get_host_info in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_get_proto_info in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_get_server_info in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_info in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fieldname in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fieldtable in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fieldlen in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fieldtype in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_fieldflags in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_selectdb in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_createdb in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_dropdb in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_freeresult in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_numfields in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_numrows in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_listdbs in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_listtables in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_listfields in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_db_name in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_dbname in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_tablename in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - mysql_table_name in Unknown on line 0
PHP Warning: mysql: Unable to register functions, unable to load in Unknown on line 0
Content-type: text/html
X-Powered-By: PHP/4.3.9


Do you know what's going on, or should I post this on the PHP forum?

Thanks for that great troubleshooting tip!!!

cmarchman
 
I would suspect that there is something wierd going on with php-mysql module...but that is my stab in the dark. Post it on the PHP forum - I am sure someone will be able to tell you what's wrong in a jiffy. Some smart cookies here :)
 
Okay, the PHP folks helped me with the errors and we've cleaned them out. I'm still not getting the mysql_connect or mysql_query results displayed on the browser.

When I "View Source" on the page - I do not see the PHP or MySQL lines at all.

When I run the script from the command line, i.e. php file.php - everything runs as it should, but no display on browser.

I'm losing hair fast (fortunately I started with the greys first).

Could it be some mysql permissions problem that could cause this? I know I grasping at straws here, but it is for a proof-of-concept for my office.

Thanks,

cmarchman
 
When I "View Source" on the page - I do not see the PHP or MySQL lines at all.
The PHP is processed by the server, which replaces it with its output before returning the page to the client. Therefore you would never see PHP code in your browser.
 
When I said that I meant to say that nothing within the area of the PHP or MySQL shows up. At least there should have the results showing up.

Also, when I reviewed the Apache error_log I noticed that errors in the mysql statements. I've corrected those where no errors appear, however still no results get returned to the browser.

Thanks,

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