esscher Posted February 6, 2008 Share Posted February 6, 2008 This is my first post here, so if I make an error or don't post enough information, I appologize.. I am a newbie php coder, and am designing a database of plant chemicals. I have one database called phytotest that has hundreds of tables of chemicals. Each chemical has its own table. Then I have a table called compounds in the same database of the physical properties of each of the chemicals. Here is a picture from navicat of a chemical table called ascorbic-acid Here is a picture of a row in the compounds table. Now here is the script: <?php session_start( ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Chemicals in Plant</title> </head> <?php $host="localhost"; $db_user="root"; $db_password="blmt153SET"; $database="phytotest"; $database2="privatedb_backup"; $link1=mysql_connect($host,$db_user,$db_password); mysql_select_db($database,$link1); $result=mysql_query("show tables from phytotest",$link1); while ($tablerow=mysql_fetch_row($result)) //this loop goes through each table { $result2=mysql_query("select plant_source from `$tablerow[0]`",$link1); echo mysql_error(); while ($plantrow=mysql_fetch_row($result2)) //this loop gets all the plants for the current chemical { if ($plantrow[0] == $_POST["inputplant"]) // this conditional checks the current plant against the user inputted plant. if they match it will print the current chemical to the screen. { echo $tablerow[0] . "<br>"; $result3=mysql_query("select * from compounds"); echo mysql_error(); while ($chemprop_row=mysql_fetch_assoc($result3)); { print_r($chemprop_row); } } } } ?> <a href="http://66.87.141.7/phytobase/p2/home.php">Phytobase Home</a> <body> </body> </html> The main problem I am having, is I am not getting any rows of results from the $result3 query. I have tested the simple query "select * from compounds" at the mysql prompt and get the expected results, but nothing from the php script. Is it ok to have 3 mysql queries in memory at the same time? Scott Link to comment https://forums.phpfreaks.com/topic/89745-solved-mysql-query-coming-up-empty-why/ Share on other sites More sharing options...
esscher Posted February 6, 2008 Author Share Posted February 6, 2008 Please disregard the password.. newbie mistake.. it has been changed! Link to comment https://forums.phpfreaks.com/topic/89745-solved-mysql-query-coming-up-empty-why/#findComment-459900 Share on other sites More sharing options...
esscher Posted February 6, 2008 Author Share Posted February 6, 2008 It seems the picture from the compounds table did not work.. Here is it: Link to comment https://forums.phpfreaks.com/topic/89745-solved-mysql-query-coming-up-empty-why/#findComment-459904 Share on other sites More sharing options...
schilly Posted February 6, 2008 Share Posted February 6, 2008 is it possible it is not getting into the if statement? if ($plantrow[0] == $_POST["inputplant"]) Link to comment https://forums.phpfreaks.com/topic/89745-solved-mysql-query-coming-up-empty-why/#findComment-459947 Share on other sites More sharing options...
esscher Posted February 6, 2008 Author Share Posted February 6, 2008 Nope, because the line: echo $tablerow[0] . "<br>"; prints what its supposed to. Link to comment https://forums.phpfreaks.com/topic/89745-solved-mysql-query-coming-up-empty-why/#findComment-459970 Share on other sites More sharing options...
schilly Posted February 6, 2008 Share Posted February 6, 2008 semicolon on while loop while ($chemprop_row=mysql_fetch_assoc($result3)); Link to comment https://forums.phpfreaks.com/topic/89745-solved-mysql-query-coming-up-empty-why/#findComment-459992 Share on other sites More sharing options...
esscher Posted February 6, 2008 Author Share Posted February 6, 2008 Great catch. thank you so much Scott Link to comment https://forums.phpfreaks.com/topic/89745-solved-mysql-query-coming-up-empty-why/#findComment-460034 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.