Jump to content

[SOLVED] mysql query coming up empty -- why??


esscher

Recommended Posts

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

chemical%20table.png

 

Here is a picture of a row in the compounds table.

from%20compounds%20table.png]

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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