Lost in PHP (part 1) ---- Sequle to Lost in Query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now I m perplexed time 10!

   I run the code that follows.... this time providing a query string
of admin_template.php?api=101

I have an if statement that tests if $_GET['api'] == 0 .... if it is
true I have it listing options, else it queries the database with that
ID and loads the associated file.

However it does not seem to execute the else.... 

I: thought that the value may of been wrong so I used        echo 
$_GET['api']; and it returned 101

what am i doing wrong?




------------------------CODE-----------------------------
<html>
<head>
<title>CB12M CERT TEAM ADMINISTRATION SCREEN</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?PHP 
	require 'mod/db_access.php';
	
	echo 'this is a test of the system <br>'. $_GET["api"] ;

	if(!isset($_GET['api']) || (isset($_GET['api']) &&
((strlen(trim(urldecode($_GET['api']))) == 0) ||
(!is_int($_GET['api'])))))
		$_GET['api']=0;

	if((isset($_GET['api']) && ((strlen(trim(urldecode($_GET['api']))) ==
0) || (!is_int($_GET['api'])))))
		echo '<strong> ERROR: </strong> the page identifier provided is not
valid. Please try again.';
	
	
	if($_GET['api'] == 0)
	{
		$admin_get_options_query_text = "Select * from adminpage";
		$admin_get_options_results_reference =
mysql_query($admin_get_options_query_text,$db_access) or die("Admin
Get Options: ". mysql_error());

		if(mysql_num_rows($admin_get_options_results_reference)>0)
		{	
?>

			<table width="600">
			<TR> <TD> Link </TD> <TD> DESCRIPTION </TD></TR>
<?PHP
			while($admin_get_options_result =
mysql_fetch_assoc($admin_get_options_results_reference)){
				echo '<TR> <TD>';
				echo '<a href="?api='.urlencode($admin_get_options_result['adminpageid']).'">
Click Here </a> </td>';
				echo '<TD>'.$admin_get_options_result['description'].'</TD></TR>';
			}
			
			Mysql_free_result($admin_get_options_results_reference);

?>

			</table>
	
<?PHP 
		}
	}
	else
	{
	  $admin_get_page_query_text = "Select * from adminpage Where
adminpageid =". $_GET['api']. " LIMIT 1";
	  $admin_get_page_results_reference =
mysql_query($admin_get_page_query_text,$db_access) or die("Admin Get
Page: ". mysql_error());
	  $admin_get_page_result = mysql_fetch_row($admin_get_page_result_reference);

	  if (mysql_num_rows($admin_get_page_results_reference) > 0)
	  {
	  	require "mod/admin/".trim(strtolower($admin_get_page_result[1]));
	  }
	  else
	  {
	  	echo "ERROR: Invalid Admin Page Requested <br>";
		echo 'Please Try Again ... <a href="admin_template.php?api=0"> Click
Here </a>';
	  }
	  
	}	
?>
</body>
</html>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux