What could be wrong with this a tags link?

<a href="<?php "menu.php?id=". $_GET['id']. "".'&register='. $_GET['register'] ?>">

When I click on this link then it won’t take me to menu.php I don’t know what could be going wrong with the way it is script it.

help

You will need to print the string using echo.


<a href="<?php echo '/menu.php?id='. $_GET['id'].'&register='. $_GET['register'] ?>">


<?php
printf('<a href="/menu.php?id=&#37;d&register=%s">Register</a>', $_GET['id'], $_GET['register']);
?>

thank you guys!
I have encounter something similar


<?php 
$ids= (int) $_GET['ids'];
$id= (int) $_GET['id'];
?>	
<a href=<?php echo "cart.php?action=remove_item&ids=" . echo $ids; .'&qty=1'. '&register='. $_GET['register']. '&id='.intval($id).""?>>Remove</a>


The above is passing ids= empty! before going to cart.php as in above in the url ids has a value then when I click remove in cart.php is passes empty to cart.php again.

That’s because you have a syntax error immediately before the field is referenced. Get rid of the word “echo” that immediately precedes is as the dot before that is supposed to be concatenating it to the string that is already being echoed.

<?php echo "cart.php?action=remove_item&ids=" . $ids. '&qty=1'. '&register='. $_GET['register']. '&id='.intval($id).""?>>

the above is not working either. I have taken out the echo and don’t know what else could be wrong. I don’t know if that was the echo you meant!

You need to read the error messages php is giving you, it will point out these typos for you, as will most IDEs.


<?php
printf(
    '<a href="cart.php?action=remove_item&ids=&#37;s&qty=1&register=%s&id=%s">Remove</a>',
    $_GET['ids'],
    $_GET['register'],
    $_GET['id']
);
?>

i have used this printf but nothing has come out any error or anything like that. I have also have done a print_r($_GET) and it would show id variable coming empty.

thank you guys problems solved.
The printf() function made it. It printed the exact values it was picking up from the url where as as I had was passing it as empty when I knew there was values in the url.

Now I have a similar issue with a pagination script it just that it has a parse error and I can not see it, but I think the logic is ok.

 echo "<a href='{$_SERVER['PHP_SELF']}?currentpage=1&name=". $_POST['name']. '&zipcode=' $_POST['zipcode'] .'&state=' $_POST['state'] . '&food_types= ' $_POST['frmSearch']['food_types'][0]. '&offerings=' $_POST['frmSearch']['offerings'][0]"'
  ><<</a> ";

The whole script above is one line and that’s line 513 and the browsers display an parse error as:

Parse error: parse error, expecting ','' or ‘;’’ in C:\wamp\www
yhungry\indexpagination.php on line 513

it says it is missing a '," or ‘;" I don’t know where should it go. I have tried after [‘offereings’][0]";’ but it won’t work. That’s the only place my limited eyes can suspect of.

help

Try with a shorter string and gradually build it up, you’ll find the error. You need to spend a little time learning this, string concatenation is staple I’m afraid.

i have notice the concatenation irregularity in the code, but it seems not to be the issue here. since it keeps throwing the same undefined message. Right now every single variable is passing as undefined.

i think i should try printf() as in before

What undefined message?
When you get error messages, please post them, it makes it so much easier to understand the problem.
And please post your corrected code as well.

Now i don’t know if the logic is good now, because it’s not working properly the pagination links Help.


<?php 	
if ( trim($_POST['name']) == '' & $_POST['zipcode'] =='' & $_POST['state'] =='' & $_POST['frmSearch']['food_types'][0]=='' & $_POST['frmSearch']['offerings'][0]=='') // line 97

//$strZipCode == '' && $strState == '' $arrFoodTypes =='' && $arrOfferings == '') 
{

 echo '<div id="tresuno">';
 var_dump($_POST);
 echo'<p class="tremendi">No results for your match please try again!</p>

<div id="tresdo">
<a href="index3.php"><< Go Back</a>

</div>';} else {

var_dump($_POST);
    $strName = isset($_POST['name'])?mysql_real_escape_string($_POST['name']):'';
    $strZipCode = isset($_POST['zipcode'])?mysql_real_escape_string($_POST['zipcode']):'';
    $strState = isset($_POST['state'])?mysql_real_escape_string($_POST['state']):'';
    $arrFoodTypes = isset($_POST['frmSearch']['food_types'])?$_POST['frmSearch']['food_types']:array();
    $arrOfferings = isset($_POST['frmSearch']['offerings'])?$_POST['frmSearch']['offerings']:array();


<div id=pagination>
<?php //
//$arr= $arr= array( 'name'=>$strName,'zipcode'=>$strZipCode, 'state'=> $strState,'food_types'=> $arrFoodTypes, 'offerings'=>$arrOfferings);
//$query3 = http_build_query($arr);

/******  build the pagination links ******/
// range of num links to show
$range = 4;

// if not on page 1, don't show back links
if ($currentpage > 1) {
   // show << link to go back to page 1  
   echo "<a href='{$_SERVER['PHP_SELF']}?currentpage=1&name=". $_POST['name']. '&zipcode=' . $_POST['zipcode'] .'&state=' . $_POST['state'] . '&food_types= ' . $_POST['frmSearch']['food_types'][0]. '&offerings=' . $_POST['frmSearch']['offerings'][0]."'
  ><<</a> ";
   
   // get previous page num
   $prevpage = $currentpage - 1;
   // show < link to go back to 1 page http_build_query( $strName,$strZipCode, $strState, $arrFoodTypes, $arrOfferings)
   echo  " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage&name=". $_POST['name']. '&zipcode=' . $_POST['zipcode'] .'&state=' . $_POST['state'] . '&food_types= ' . $_POST['frmSearch']['food_types'][0]. '&offerings=' . $_POST['frmSearch']['offerings'][0]."'><</a> ";
} // end if 

// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {

   // if it's a valid page number...
   if (($x > 0) && ($x <= $totalpages)) {
      // if we're on current page...
      if ($x == $currentpage) { 
         // 'highlight' it but don't make a link
         echo " [<b >$x</b>] ";
      // if not current page...
	  
      }
	 
	  else {
         // make it a link http_build_query( $strName,$strZipCode, $strState, $arrFoodTypes, $arrOfferings)
         echo  " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
      } // end else
   } // end if 

} 
// end for
                 
// if not on last page, show forward and last page links        
if ($currentpage != $totalpages) {
   // get next page
   $nextpage = $currentpage + 1;
    // echo forward link for next page http_build_query( $strName,$strZipCode, $strState, $arrFoodTypes, $arrOfferings)
   echo  " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&name=". $_POST['name']. '&zipcode=' . $_POST['zipcode'] .'&state=' . $_POST['state'] . '&food_types= ' . $_POST['frmSearch']['food_types'][0]. '&offerings=' . $_POST['frmSearch']['offerings'][0]."'>></a> ";// line 548
   // echo forward link for lastpage http_build_query( $strName,$strZipCode, $strState, $arrFoodTypes, $arrOfferings)
   echo  " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&name=". $_POST['name']. '&zipcode=' . $_POST['zipcode'] .'&state=' . $_POST['state'] . '&food_types= ' . $_POST['frmSearch']['food_types'][0]. '&offerings=' . $_POST['frmSearch']['offerings'][0]."'>>></a> ";
} // line 550 end if


}
?>
 }
</div>
<div class="clearer"></div>
</div>
</div>

when I come from index.php to the page above indexpagination.php then automatically it will display this undefined index.

Notice: Undefined index: offerings in C:\wamp\www
yhungry\indexpagination.php on line 548
>
Notice: Undefined index: offerings in C:\wamp\www
yhungry\indexpagination.php on line 550
>>

then when I click the > at the pagination link it will display that all the indexes in the links are undefined.

<br />

<b>Notice</b>: Undefined index: name in <b>C:\wamp\www
yhungry\indexpagination.php</b> on line <b>97</b><br />
<br />
<b>Notice</b>: Undefined index: zipcode in <b>C:\wamp\www
yhungry\indexpagination.php</b> on line <b>97</b><br />
<br />
<b>Notice</b>: Undefined index: state in <b>C:\wamp\www
yhungry\indexpagination.php</b> on line <b>97</b><br />

<br />
<b>Notice</b>: Undefined index: frmSearch in <b>C:\wamp\www
yhungry\indexpagination.php</b> on line <b>97</b><br />
<br />
<b>Notice</b>: Undefined index: frmSearch in <b>C:\wamp\www
yhungry\indexpagination.php</b> on line <b>97</b><br />

Undefined index means this

$_POST[‘frmSearch’][‘offerings’][0]

isn’t set.
I see you’re doing a var_dump($_POST). What does it contain?

it’s comins as

vardump

var_dump

array(0) {

}

print_r

print_r

Array

(
)

So you found the problem. There are no $_POST variables passed on to the script, and you are using them nevertheless.

when i set it then it won’t show the undefined: offerings, But it shouldn’t display this error because sometimes users input will not include the offerings.

well…

that undefined message will goes away once it set to the else statement because in the else statement there is a test to if isset then else null. but right now is trying to get the indexes defined from the form to the pagination links and then return those fields defined.

Some where in between the form and the pagination links the value is getting lost or the set up of the logic in the pagination links is wrong.

Btw, if those values are being passed by the link, then you should use $_GET instead of $_POST

i should pass it on through the pagination links rights?

it is true is passing as empty. well then the logic or set up in here is wrong

&name=". $_POST['name']. '&zipcode=' . $_POST['zipcode'] .'&state=' . $_POST['state'] . '&food_types= ' . $_POST['frmSearch']['food_types'][0]. '&offerings=' . $_POST['frmSearch']['offerings'][0]."'

mmm