torres Posted March 8, 2004 Share Posted March 8, 2004 Hi all freaks!! I'm working on a Local Commerce WebGIS application for a final master thesis and i'm having troubles with the dynamic links. I have the following database structure: Comercial categories ID_CAT Categorie Comercial Sub-Categories ID_CAT ID_SUB_CAT Sub_Categorie (and then the comercial stores table wich dont matter for this case) When i try to make dynamic link with the ID_CAT to the Sub_Categorie matching the same ID_CAT i get the following error: Parse error: parse error, unexpected T_STRING, expecting ']' in C:\ServidorGis\web\Database\subcategorias.php on line 14 the code for the subcategories.php is: (line 14 is in bold) can anyone please tell me what am i doing wrong?? Thanks in advance! Torres, Portugal ********************************************** <?php require_once('../Connections/MySQL_connection.php'); ?> <?php $colname_Subcategorias = "1"; if (isset($_GET['categorias_link'])) { $colname_Subcategorias = (get_magic_quotes_gpc()) ? $_GET['categorias_link'] : addslashes($_GET['categorias_link']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_Subcategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s' ORDER BY Nome_Sub_Cat ASC", $colname_Subcategorias); $Subcategorias = mysql_query($query_Subcategorias, $MySQL_connection) or die(mysql_error()); $row_Subcategorias = mysql_fetch_assoc($Subcategorias); $totalRows_Subcategorias = mysql_num_rows($Subcategorias); $colname_Subcategorias = "1"; if (isset($_GET['<?php echo $row_Categorias['ID_Cat']; ?> '])) { $colname_Subcategorias = (get_magic_quotes_gpc()) ? $_GET['<?php echo $row_Categorias['ID_Cat']; ?>'] : addslashes($_GET['<?php echo $row_Categorias['ID_Cat']; ?>']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_Subcategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s'", $colname_Subcategorias); $Subcategorias = mysql_query($query_Subcategorias, $MySQL_connection) or die(mysql_error()); $row_Subcategorias = mysql_fetch_assoc($Subcategorias); $totalRows_Subcategorias = mysql_num_rows($Subcategorias); $colname_Subcategorias ="1"; if (isset($_GET['<?php echo $row_Categorias['ID_Cat']; ?>'])) { $colname_Subcategorias = (get_magic_quotes_gpc()) ? $_GET['<?php echo $row_Categorias['ID_Cat']; ?>'] : addslashes($_GET['<?php echo $row_Categorias['ID_Cat']; ?>']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_Subcategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s'", $colname_Subcategorias); $Subcategorias = mysql_query($query_Subcategorias, $MySQL_connection) or die(mysql_error()); $row_Subcategorias = mysql_fetch_assoc($Subcategorias); $totalRows_Subcategorias = mysql_num_rows($Subcategorias); $colname_Subcategorias ="1"; if (isset($_GET['<?php echo $row_Categorias['ID_Cat']; ?>'])) { $colname_Subcategorias = (get_magic_quotes_gpc()) ? $_GET['<?php echo $row_Categorias['ID_Cat']; ?>'] : addslashes($_GET['<?php echo $row_Categorias['ID_Cat']; ?>']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_Subcategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s'", $colname_Subcategorias); $Subcategorias = mysql_query($query_Subcategorias, $MySQL_connection) or die(mysql_error()); $row_Subcategorias = mysql_fetch_assoc($Subcategorias); $totalRows_Subcategorias = mysql_num_rows($Subcategorias); $colname_SubCategorias ="1"; if (isset($_GET['<?php echo $row_Categorias['ID_Cat']; ?> '])) { $colname_SubCategorias = (get_magic_quotes_gpc()) ? $_GET['<?php echo $row_Categorias['ID_Cat']; ?>'] : addslashes($_GET['<?php echo $row_Categorias['ID_Cat']; ?>']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_SubCategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s'", $colname_SubCategorias); $SubCategorias = mysql_query($query_SubCategorias, $MySQL_connection) or die(mysql_error()); $row_SubCategorias = mysql_fetch_assoc($SubCategorias); $totalRows_SubCategorias = mysql_num_rows($SubCategorias); $colname_SubCategorias ="1"; if (isset($_GET['<?php echo $row_Categorias['ID_Cat']; ?>'])) { $colname_SubCategorias = (get_magic_quotes_gpc()) ? $_GET['<?php echo $row_Categorias['ID_Cat']; ?>'] : addslashes($_GET['<?php echo $row_Categorias['ID_Cat']; ?>']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_SubCategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s'", $colname_SubCategorias); $SubCategorias = mysql_query($query_SubCategorias, $MySQL_connection) or die(mysql_error()); $row_SubCategorias = mysql_fetch_assoc($SubCategorias); $totalRows_SubCategorias = mysql_num_rows($SubCategorias); $colname_SubCategorias ="1"; if (isset($_SESSION['<?php echo $row_Categorias['ID_Cat']; ?>'])) { $colname_SubCategorias = (get_magic_quotes_gpc()) ? $_SESSION['<?php echo $row_Categorias['ID_Cat']; ?>'] : addslashes($_SESSION['<?php echo $row_Categorias['ID_Cat']; ?>']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_SubCategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s'", $colname_SubCategorias); $SubCategorias = mysql_query($query_SubCategorias, $MySQL_connection) or die(mysql_error()); $row_SubCategorias = mysql_fetch_assoc($SubCategorias); $totalRows_SubCategorias = mysql_num_rows($SubCategorias); $colname_SubCategorias ="1"; if (isset($_GET['<?php echo $row_Categorias['ID_Cat']; ?>'])) { $colname_SubCategorias = (get_magic_quotes_gpc()) ? $_GET['<?php echo $row_Categorias['ID_Cat']; ?>'] : addslashes($_GET['<?php echo $row_Categorias['ID_Cat']; ?>']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_SubCategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s'", $colname_SubCategorias); $SubCategorias = mysql_query($query_SubCategorias, $MySQL_connection) or die(mysql_error()); $row_SubCategorias = mysql_fetch_assoc($SubCategorias); $totalRows_SubCategorias = mysql_num_rows($SubCategorias); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style1 {font-family: Verdana, Arial, Helvetica, sans-serif} --> </style> </head> <body> <table width="228" border="1" cellspacing="2" cellpadding="2"> <tr> <th width="216" scope="col"><span class="style1">Sub-Categorias Comerciais </span></th> </tr> <?php do { ?> <tr> <td><?php echo $row_Subcategorias['Nome_Sub_Cat']; ?></td> </tr> <?php } while ($row_Subcategorias = mysql_fetch_assoc($Subcategorias)); ?> </table> </body> </html> <?php mysql_free_result($Subcategorias); mysql_free_result($SubCategorias); ?> ********************************************************* Quote Link to comment Share on other sites More sharing options...
Websitenoobie Posted March 10, 2004 Share Posted March 10, 2004 O I might see your problem! if (isset($_GET['<?php echo $row_Categorias['ID_Cat']; ?> '])) I think your single quotes are confusing it... also try taking out the <?php echo... reading through your code it is unneeded. The ; or the ?> could be confusing it considering you have so many of the <?php open if (isset($_GET["$row_Categorias['ID_Cat']"])) Quote Link to comment Share on other sites More sharing options...
torres Posted March 10, 2004 Author Share Posted March 10, 2004 Hi all! Thank you very much noobie! It worked!! The problem was that, as you know (i didn't), dreamweaver don't delete unnecessary code generated after arranging and re-arranging url parameters for the dinamic links!! So...i've tryed to rebuild my sub_cat php page and it worked!! the new code is: <?php require_once('../Connections/MySQL_connection.php'); ?> <?php $colname_Subcategorias = "1"; if (isset($_GET['categoria_link'])) { $colname_Subcategorias = (get_magic_quotes_gpc()) ? $_GET['categoria_link'] : addslashes($_GET['categoria_link']); } mysql_select_db($database_MySQL_connection, $MySQL_connection); $query_Subcategorias = sprintf("SELECT * FROM com_sub_cat WHERE ID_Cat = '%s'", $colname_Subcategorias); $Subcategorias = mysql_query($query_Subcategorias, $MySQL_connection) or die(mysql_error()); $row_Subcategorias = mysql_fetch_assoc($Subcategorias); $totalRows_Subcategorias = mysql_num_rows($Subcategorias); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style1 {font-family: Verdana, Arial, Helvetica, sans-serif} --> </style> </head> <body> <table width="207" border="1" cellspacing="2" cellpadding="2"> <tr> <th width="195" scope="col"><div align="center" class="style1">Sub-Categorias Comerciais </div></th> </tr> <?php do { ?> <tr> <td><a href="lojas.php?sub_categorias=<?php echo $row_Subcategorias['ID_Sub_Cat']; ?>"><?php echo $row_Subcategorias['Nome_Sub_Cat']; ?></a></td> </tr> <?php } while ($row_Subcategorias = mysql_fetch_assoc($Subcategorias)); ?> </table> </body> </html> <?php mysql_free_result($Subcategorias); ?> *********************************************** Cheers!! Long Life to phpfreaks.com!! António Portugal, Europe torrezzzz@hotmail.com Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.