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.PHP Code:<a href="<?php "menu.php?id=". $_GET['id']. "".'®ister='. $_GET['register'] ?>">
help
| SitePoint Sponsor |
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.PHP Code:<a href="<?php "menu.php?id=". $_GET['id']. "".'®ister='. $_GET['register'] ?>">
help
You will need to print the string using echo.
PHP Code:<a href="<?php echo '/menu.php?id='. $_GET['id'].'®ister='. $_GET['register'] ?>">
PHP Code:<?php
printf('<a href="/menu.php?id=%d®ister=%s">Register</a>', $_GET['id'], $_GET['register']);
?>
@AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.
thank you guys!
I have encounter something similar
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.PHP Code:<?php
$ids= (int) $_GET['ids'];
$id= (int) $_GET['id'];
?>
<a href=<?php echo "cart.php?action=remove_item&ids=" . echo $ids; .'&qty=1'. '®ister='. $_GET['register']. '&id='.intval($id).""?>>Remove</a>

Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
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!PHP Code:<?php echo "cart.php?action=remove_item&ids=" . $ids. '&qty=1'. '®ister='. $_GET['register']. '&id='.intval($id).""?>>
You need to read the error messages php is giving you, it will point out these typos for you, as will most IDEs.
PHP Code:<?php
printf(
'<a href="cart.php?action=remove_item&ids=%s&qty=1®ister=%s&id=%s">Remove</a>',
$_GET['ids'],
$_GET['register'],
$_GET['id']
);
?>
@AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.
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.
PHP Code: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:
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.Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\nyhungry\indexpagination.php on line 513
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.
@AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.
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.
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
Now i don't know if the logic is good now, because it's not working properly the pagination links Help.
when I come from index.php to the page above indexpagination.php then automatically it will display this undefined index.PHP Code:<?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>
then when I click the > at the pagination link it will display that all the indexes in the links are undefined.Notice: Undefined index: offerings in C:\wamp\www\nyhungry\indexpagination.php on line 548
>
Notice: Undefined index: offerings in C:\wamp\www\nyhungry\indexpagination.php on line 550
>>
<br />
<b>Notice</b>: Undefined index: name in <b>C:\wamp\www\nyhungry\indexpagination.php</b> on line <b>97</b><br />
<br />
<b>Notice</b>: Undefined index: zipcode in <b>C:\wamp\www\nyhungry\indexpagination.php</b> on line <b>97</b><br />
<br />
<b>Notice</b>: Undefined index: state in <b>C:\wamp\www\nyhungry\indexpagination.php</b> on line <b>97</b><br />
<br />
<b>Notice</b>: Undefined index: frmSearch in <b>C:\wamp\www\nyhungry\indexpagination.php</b> on line <b>97</b><br />
<br />
<b>Notice</b>: Undefined index: frmSearch in <b>C:\wamp\www\nyhungry\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?
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
it's comins as
vardump
print_rvar_dump
array(0) {
}
print_r
Array
(
)
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.
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
mmmPHP Code:&name=". $_POST['name']. '&zipcode=' . $_POST['zipcode'] .'&state=' . $_POST['state'] . '&food_types= ' . $_POST['frmSearch']['food_types'][0]. '&offerings=' . $_POST['frmSearch']['offerings'][0]."'
let me do the var dump with $_GET
So you found the problem. There are no $_POST variables passed on to the script, and you are using them nevertheless.
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
Btw, if those values are being passed by the link, then you should use $_GET instead of $_POST
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
Do a print_r of $_REQUEST and see what it contains.
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
below is an print_r and a var_dump of $_REQUEST after paginating when coming from the form then the only difference is the submit index that will show up.
Array
(
[currentpage] => 2
[name] =>
[zipcode] => 10468
[state] =>
[food_types] => Array
[offerings] =>
)
array(7) {
["currentpage"]=>
string(1) "2"
["name"]=>
string(0) ""
["zipcode"]=>
string(5) "10468"
["state"]=>
string(0) ""
["food_types"]=>
string(6) " Array"
["offerings"]=>
string(0) ""
}
It looks like there's no such thing as a $_REQUEST['frmSearch'], so maybe you should try
$_REQUEST['food_types'][0]
and
$_REQUEST['offerings'][0]
instead.
Although 'offerings' doesn't seem to be an array, it's empty.
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
look at it now it is an array. It just going crazy and heated right now.
I have taken out the ["frmsearch"] but still it will display some undifined messages!
that's the var_dump below.
array(6) {
["name"]=>
string(0) ""
["zipcode"]=>
string(5) "10468"
["state"]=>
string(0) ""
["frmSearch"]=>
array(2) {
["food_types"]=>
array(1) {
[0]=>
string(1) "5"
}
["offerings"]=>
array(1) {
[0]=>
string(1) "5"
}
}
Bookmarks