Kristian_C Posted January 3, 2007 Share Posted January 3, 2007 Hey, im kind of new when it comes to functions like Round() Sterlen() +++ so was just wondering of someone chould help me out. Look'ed at the functions at the w3schools page, but dident understand so much, like how i can use sterlen to check lenght of a selected number like etc : i have a site, with a login function but ive just set the limit of max char inside the sql db. And not the textfield. I know i can use max char there to but its better for me to use other functions that i may need to use on other things that dont limmit of max char etc.If some one chould help me out with this i whould be verry verry happy :)Thanks.->Kristian_C Link to comment Share on other sites More sharing options...
justsomeguy Posted January 3, 2007 Share Posted January 3, 2007 You can use strlen to check the length of a string. So this:strlen($_POST['info']);would give the length (number of characters) of whatever is in $_POST['info']. If you want to take a certain part of it, such as the first 50 characters, then you use substr to get the substring. So this would get the first 50 characters starting at character 0:substr($_POST['info'], 0, 50); Link to comment Share on other sites More sharing options...
Kristian_C Posted January 3, 2007 Author Share Posted January 3, 2007 Hmm, thanks, but if i like did something like this :if($_post['reg']){$bruker=$_post['bruker'];if(sterlen($bruker > 50){echo"Username is to long.";whould that work? if not what do i do? Link to comment Share on other sites More sharing options...
aspnetguy Posted January 3, 2007 Share Posted January 3, 2007 if(isset($_POST['reg'])){ $bruker=$_POST['bruker']; if(strlen($bruker) > 50) { echo "Username is too long."; }} Link to comment Share on other sites More sharing options...
Kristian_C Posted January 3, 2007 Author Share Posted January 3, 2007 if(isset($_POST['reg'])){ $bruker=$_POST['bruker']; if(strlen($bruker) > 50) { echo "Username is too long."; }} Thanks mate ->Kristian_C Link to comment Share on other sites More sharing options...
Kristian_C Posted January 5, 2007 Author Share Posted January 5, 2007 Hey again, i need some help with the round() function.Lets say i want to duplicate $anumber with 10, will that be = round(10*$anumber); ? i tried it but dident work, its just a simple ting like : if($_POST['test']){$money=$fetch->money;$exp=$fetch->exp;$nmoney=round($exp+$money /10);mysql_query("UPDATE test SET money='$money' WHERE id='$id'");echo"Testing Complete";[code]Just something like that not quite shure that i acutally know what im doing here but ive seen some exaples here and there so tested but dident work.->Kritsian_C Link to comment Share on other sites More sharing options...
justsomeguy Posted January 8, 2007 Share Posted January 8, 2007 The code works, it just might not be doing what you are expecting.First, you might be getting a different result with the math. So change this:$nmoney=round($exp+$money /10);To one of these (whichever you meant):$nmoney=round(($exp+$money) /10);$nmoney=round($exp+($money /10));Second, you save that as a variable called $nmoney, but in the query you use $money. Link to comment Share on other sites More sharing options...
Kristian_C Posted January 9, 2007 Author Share Posted January 9, 2007 Aha thanks for beeing verry verry helpfull .. I think i should turn down the codeing speed and try to understand things abit more before i use it, just hate reading about things like to test it myself and just ask for help if i need it but reading should be a think i must start with soon... Have tried to use the php manual 1000times when i need some questions answerd but the answers i get from there i cant understand so really dont know what to do hehe...so thanks again ->Kristian_C Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now