PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kampuz
Forum Newbie
Posts: 7 Joined: Thu Aug 04, 2005 5:19 am
Post
by kampuz » Thu Aug 04, 2005 6:00 am
I'm making my first steps on the php world and I'm having some problems in my first php website.
I want to make a page where I have my "
thumbnails " with direct links to the details pages.
The problem is that I get an error I and don't know how to fix it. In this exemple you can see that the only link that works correctly is the first one, the others are broken. Even If I use the navigation bar it wont work.
If I go directly to the
details page the navigation works just fine.
You can take a look at the code
here .
Anyone has some hint to fix this problem? I have read a lot about this but I didn't found a solution...
Help me please
Thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Aug 04, 2005 7:15 am
his code (linked to in his post)
Code: Select all
<?php require_once('Connections/bdducampus.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_teste = 1;
$pageNum_teste = 0;
if (isset($_GET['pageNum_teste'])) {
$pageNum_teste = $_GET['pageNum_teste'];
}
$startRow_teste = $pageNum_teste * $maxRows_teste;
$colname_teste = "1";
if (isset($_GET['1'])) {
$colname_teste = (get_magic_quotes_gpc()) ? $_GET['1'] : addslashes($_GET['1']);
}
mysql_select_db($database_bdducampus, $bdducampus);
$query_teste = sprintf("SELECT * FROM tbl_modelos_mod WHERE restaurantes_mod = '%s'", $colname_teste);
$query_limit_teste = sprintf("%s LIMIT %d, %d", $query_teste, $startRow_teste, $maxRows_teste);
$teste = mysql_query($query_limit_teste, $bdducampus) or die(mysql_error());
$row_teste = mysql_fetch_assoc($teste);
if (isset($_GET['totalRows_teste'])) {
$totalRows_teste = $_GET['totalRows_teste'];
} else {
$all_teste = mysql_query($query_teste);
$totalRows_teste = mysql_num_rows($all_teste);
}
$totalPages_teste = ceil($totalRows_teste/$maxRows_teste)-1;
$queryString_teste = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_teste") == false &&
stristr($param, "totalRows_teste") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_teste = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_teste = sprintf("&totalRows_teste=%d%s", $totalRows_teste, $queryString_teste);
// *** Move To Specific Record: declare variables
$MM_rs = &$teste;
$row_MM_rs = &$row_teste;
$MM_rsCount = $totalRows_teste;
$MM_uniqueCol = "id_mod";
$MM_paramName = "id_mod";
$MM_paramIsDefined = ($MM_paramName != "" && isset($HTTP_GET_VARS[$MM_paramName]));
// *** Move To Specific Record: handle detail parameter
if ($MM_paramIsDefined && $MM_rsCount != 0) {
// get the value of the parameter
$param = $HTTP_GET_VARS[$MM_paramName];
// find the record with the unique column value equal to the parameter value
do {
if ($row_MM_rs[$MM_uniqueCol] == $param) break;
} while($row_MM_rs = mysql_fetch_assoc($MM_rs));
}
?>
<!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>Untitled Document</title>
</head>
<body>
<?php do { ?>
<p><?php echo $row_teste['titulo_mod']; ?></p>
<p><img src="/images/catalogo/<?php echo $row_teste['imagemgrande_mod']; ?>" /></p>
<p><?php echo $row_teste['largura_mod']; ?></p>
<?php } while ($row_teste = mysql_fetch_assoc($teste)); ?>
<p> </p>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_teste > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_teste=%d%s", $currentPage, 0, $queryString_teste); ?>">First</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center"><?php if ($pageNum_teste > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_teste=%d%s", $currentPage, max(0, $pageNum_teste - 1), $queryString_teste); ?>">Previous</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_teste < $totalPages_teste) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_teste=%d%s", $currentPage, min($totalPages_teste, $pageNum_teste + 1), $queryString_teste); ?>">Next</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center"><?php if ($pageNum_teste < $totalPages_teste) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_teste=%d%s", $currentPage, $totalPages_teste, $queryString_teste); ?>">Last</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table></body>
</html>
<?php
mysql_free_result($teste);
?>
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Thu Aug 04, 2005 7:24 am
In your gallery you have links like ?id_mod
In your detail you use $_GET['l']...
So you need to change one of them
dreamline
Forum Contributor
Posts: 158 Joined: Fri May 28, 2004 2:37 am
Post
by dreamline » Thu Aug 04, 2005 8:11 am
LOL overread that part, so timvw you beat me to it..
kampuz
Forum Newbie
Posts: 7 Joined: Thu Aug 04, 2005 5:19 am
Post
by kampuz » Thu Aug 04, 2005 10:31 am
Sorry man but I'm really newbie in php.
The code for the gallery is:
Code: Select all
<?php require_once('Connections/bdducampus.php'); ?>
<?php
$colname_teste2 = "1";
if (isset($_GET['1'])) {
$colname_teste2 = (get_magic_quotes_gpc()) ? $_GET['1'] : addslashes($_GET['1']);
}
mysql_select_db($database_bdducampus, $bdducampus);
$query_teste2 = sprintf("SELECT * FROM tbl_modelos_mod WHERE restaurantes_mod = '%s'", $colname_teste2);
$teste2 = mysql_query($query_teste2, $bdducampus) or die(mysql_error());
$row_teste2 = mysql_fetch_assoc($teste2);
$totalRows_teste2 = mysql_num_rows($teste2);
?>
<!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>Untitled Document</title>
</head>
<body>
<table >
<tr>
<?php
$teste2_endRow = 0;
$teste2_columns = 3; // number of columns
$teste2_hloopRow1 = 0; // first row flag
do {
if($teste2_endRow == 0 && $teste2_hloopRow1++ != 0) echo "<tr>";
?>
<td><a href="/teste.php?id_mod=<?php echo $row_teste2['id_mod']; ?>"><img src="/images/catalogo/<?php echo $row_teste2['imagempequena_mod']; ?>" /></a></td>
<?php $teste2_endRow++;
if($teste2_endRow >= $teste2_columns) {
?>
</tr>
<?php
$teste2_endRow = 0;
}
} while ($row_teste2 = mysql_fetch_assoc($teste2));
if($teste2_endRow != 0) {
while ($teste2_endRow < $teste2_columns) {
echo("<td> </td>");
$teste2_endRow++;
}
echo("</tr>");
}?>
</table>
</body>
</html>
<?php
mysql_free_result($teste2);
?>
The code present here was generated by dreamweaver. Can anyone be more specific in which lines should I change the code?
Thanks again and sorry for the stupid question but I really need to get that fixed asap.
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Thu Aug 04, 2005 8:50 pm
Yeah, and i need 115 million euros.. ASAP...
Code: Select all
<a href="/teste.php?id_mod=<?php echo $row_teste2['id_mod']; ?>">
This means, when you enter teste.php there will be a $GET['id_mod'], but no $_GET['l']. And teste.php uses $_GET['l'], not $_GET['id_mod'].
So it should work if you change your code to:
Code: Select all
<a href="/teste.php?l=<?php echo $row_teste2['id_mod']; ?>">
kampuz
Forum Newbie
Posts: 7 Joined: Thu Aug 04, 2005 5:19 am
Post
by kampuz » Fri Aug 05, 2005 7:06 am
Thanks for the hint but it didn't worked...
With your suggestion only the first link works. When I click in the other links I get a white screen.
kampuz
Forum Newbie
Posts: 7 Joined: Thu Aug 04, 2005 5:19 am
Post
by kampuz » Wed Aug 24, 2005 10:16 am
Any more hints?!
I really don't know how to fix this
neophyte
DevNet Resident
Posts: 1537 Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota
Post
by neophyte » Wed Aug 24, 2005 10:31 am
The are plenty of php gallery systems out there.
php simple gallery, or GOOP gallery (that's mine: see my signature).
Debugging: everyone has to deal with this at some point. The thing to do is track all your variables. Make sure they are showing up where you expect them to. I suggest going through your code and make sure everything is doing what is supposed. Echo out your variables to the screen at different points. This way you can eliminate different possibilities until you find the right one. If you didn't write your code and you have no idea what it means. I suggest getting a different gallery solution.
Hope that helps
kampuz
Forum Newbie
Posts: 7 Joined: Thu Aug 04, 2005 5:19 am
Post
by kampuz » Mon Sep 05, 2005 2:54 am
I didn't made any part of the code, dreamweaver did it. I really don't understand very much of the code.
From that pre-made gallerys, I think they are very complex for the results that I want.
Thanks anyway