Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL PARAMETERS IN PHP 1

Status
Not open for further replies.

hebisr3

Programmer
Feb 17, 2004
5
US
I have been following a tutorial on Setting up a search page: I wanted to know if you can check the following syntax: (You would think a step by step tutorial would successfully work)

Here's the story:
See site
I followed the tutorial successfully all the way to the above page ( My search criteria works).

The Issue: I was told to enter the following hyperlink setting/parameter
details.php? petID=<?php echo $row_rsResults['ID']; ?

Which resulted in the following error on my localhost apache server:

STRANGE HUH?

The objective: getting the detail page to display the full information on all cats.

I've tried manually entering in this hyperlink and it still doesnt work

I'm quite new to this....be gentle......thanks alot in advance

Code:
<?php require_once('Connections/connPets.php'); ?> 

<?php 

$maxRows_rsResults = 10; 

$pageNum_rsResults = 0; 

if (isset($HTTP_GET_VARS['pageNum_rsResults'])) { 

_ $pageNum_rsResults = $HTTP_GET_VARS['pageNum_rsResults']; 

} 

$startRow_rsResults = $pageNum_rsResults * $maxRows_rsResults; 



$colname_rsResults = "1"; 

if (isset($HTTP_GET_VARS['petBreed'])) { 

_ $colname_rsResults = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['petBreed'] : addslashes($HTTP_GET_VARS['petBreed']); 

} 

mysql_select_db($database_connPets, $connPets); 

$query_rsResults = sprintf("SELECT * FROM adoption_list WHERE breed = '%s'", $colname_rsResults); 

$query_limit_rsResults = sprintf("%s LIMIT %d, %d", $query_rsResults, $startRow_rsResults, $maxRows_rsResults); 

$rsResults = mysql_query($query_limit_rsResults, $connPets) or die(mysql_error()); 

$row_rsResults = mysql_fetch_assoc($rsResults); 



if (isset($HTTP_GET_VARS['totalRows_rsResults'])) { 

_ $totalRows_rsResults = $HTTP_GET_VARS['totalRows_rsResults']; 

} else { 

_ $all_rsResults = mysql_query($query_rsResults); 

_ $totalRows_rsResults = mysql_num_rows($all_rsResults); 

} 

$totalPages_rsResults = ceil($totalRows_rsResults/$maxRows_rsResults)-1; 

?> 

<html> 

<head> 

<title>The Results of your Search</title> 

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 

<link href="pet_styles.css" rel="stylesheet" type="text/css"> 

</head> 



<body bgcolor="#ffdab9"> 

<table width="500" border="0" cellspacing="0" cellpadding="10"> 

_ <tr> 

_ _ <td width="146">BREED</td> 

_ _ <td width="164"> 

<div align="center">NAME</div></td> 

_ _ <td width="130"> 

<div align="center">AGE</div></td> 

_ </tr> 

</table> 

<br> 

<?php do { ?> 

<table width="543" border="0" cellspacing="0" cellpadding="5"> 

_ 

_ <!--DWLayoutTable--> 

_ <tr> 

_ _ <td height="28"> <h3 align="center">&nbsp;</h3></td> 

_ _ <td> <h3 align="center">&nbsp;</h3></td> 

_ _ <td width="185" valign="top"> <h3 align="center">&nbsp;</h3></td> 

_ </tr> 

_ <tr> 

_ _ <td height="25"> <p align="center"><?php echo $row_rsResults['breed']; ?></p></td> 

_ _ <td> <p align="center"><a href="details.php?petID=<?=$row_rsResults['ID']?>"><?php echo $row_rsResults['name']; ?></a></p></td> 

_ _ <td valign="top"> <p align="center"><?php echo $row_rsResults['age']; ?></p></td> 

_ _ </tr> 

</table> 

<?php } while ($row_rsResults = mysql_fetch_assoc($rsResults)); ?> 

</body> 

</html> 

<?php 

mysql_free_result($rsResults); 

?>


The Details.php
Code:
<?php require_once('Connections/connPets.php'); ?> 

<?php 

$colname_rsDetails = "1"; 

if (isset($HTTP_GET_VARS['petID'])) { 

_ $colname_rsDetails = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['petID'] : addslashes($HTTP_GET_VARS['petID']); 

} 

mysql_select_db($database_connPets, $connPets); 

$query_rsDetails = sprintf("SELECT breed, name, age, personality, petPic FROM adoption_list WHERE petID = %s", $colname_rsDetails); 

$rsDetails = mysql_query($query_rsDetails, $connPets) or die(mysql_error()); 

$row_rsDetails = mysql_fetch_assoc($rsDetails); 

$totalRows_rsDetails = mysql_num_rows($rsDetails); 

?>
 
I'm assuming this code is designed to show a list of animals and then you can click an id to get more details?!

Ah, have you got short tags and asp tags enabled in php so you can just use the <?=$value ?> tags. if not then you may need to enable them or change all <? references to
<?php.....
 
Hi there I am not sure I understand
Does this mean that I should enable this in the php.ini file? Please advise I am using an OSX platform to achieve this.Thanks alot in advance.
 
yes, in the php ini file there is an option for using asp style tags. you will need to enable this to use the <?=$var?> command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top