Does something like this exist to grab only the last 4 characters of a parameter?
right(($_GET['col33']),4)
Where the number "123456789" would equal "6789"
| SitePoint Sponsor |
Does something like this exist to grab only the last 4 characters of a parameter?
right(($_GET['col33']),4)
Where the number "123456789" would equal "6789"



hthPHP Code:sub_str($_GET['col33'], -1, 4);





wrong...right...PHP Code:sub_str($_GET['col33'], -1, 4);
cheersPHP Code:substr($_GET["col33"], -4);
![]()



wrong
i should test my code when i'm a little bit tipsyPHP Code:substr($_GET['col33'], -4);
![]()
I tried it out but I'm getting this error:
Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in c:\inetpub\wwwroot\test2\411.php on line 36
I don't see any problem with the code. Is there one? Line 36 is the first instance of the "substr" entry. Here's what surrounds line 36:
$startRow_Recordset2 = $pageNum_Recordset2 * $maxRows_Recordset2;
$a1__Recordset2 = '-1';
if (isset(substr($_GET['col19'], -4))) {
$a1__Recordset2 = substr($_GET['col19'], -4);



substr() returns a string, and isset() expects a $variable.PHP Code:if (isset(substr($_GET['col19'], -4))) {
so if you wan't to check that $_GET['col19'] is set and at least 4 chars long use
hthPHP Code:if(isset($_GET['col19'] && strlen($_GET['col19']) > 3)
{
$a1__Recordset2 = substr($_GET['col19'], -4);
}
Edit:
post #300![]()





?
what is that???PHP Code:$startRow_Recordset2 = $pageNum_Recordset2 * $maxRows_Recordset2;
$a1__Recordset2 = '-1'; # why that here???
if(isset(substr($_GET['col19'], -4))) {
$a1__Recordset2 = substr($_GET['col19'], -4); # and then here again???
maybe this will help...
cheersPHP Code:if(!empty($_GET["col19"])) {
$a1__Recordset2 = substr($_GET['col19'], -4);
}
![]()
May be this:
if(!empty($_GET["col19"],-4))
{
$a1__Recordset2 = substr($_GET['col19'], -4);
}
Ravi





how can be if(!empty($_GET["bla"], -4)) ?
hth
cheersPHP Code:if(strlen($_GET["col19"]) > 4) {
$a1__Recordset2 = substr($_GET['col19'], -4);
}
![]()
This bit of code is from dreamweaver mx 2004. I've tested out:
<?php echo substr($_GET['col19'], -4); ?> on the screen and it gives the correct results. But when I put in dreamweaver's recordset builder and put in :
substr($_GET['col19'], -4)
as a "runtime" value in the variables box, this is where it fails.
May I have the coding ur using in Dreamweaver and in the PHP file.
Ravi
Bookmarks