crawlerbasher Posted June 5, 2007 Share Posted June 5, 2007 Well I'm kind of lost on this one. I've been looking all over to try and find a way to remove all cracters accept numbers from a verable. And I'm kind of new, when it comes to removing certain caracters from the verable. an eg would be $id = 00289 // Good verable $id = ".Some hacking going on." // Bad Verable So since I only need numbers to past though the verable, any idea of the best way to solve this? Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/ Share on other sites More sharing options...
Lumio Posted June 5, 2007 Share Posted June 5, 2007 If you only want to check if it's a number, use is_numeric <?php $var = 1; if (is_numeric($var)) echo 'is number'; else echo 'is not a number'; $var = 'hello world'; if (is_numeric($var)) echo 'is number'; else echo 'is not a number'; ?> If you only want to accept a number use intval that converts strings into numbers: <?php $var = 'hello'; $var = intval($var); //becomes 0 $var = '23'; $var = intval($var); //becomes 23 ?> Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268309 Share on other sites More sharing options...
crawlerbasher Posted June 5, 2007 Author Share Posted June 5, 2007 I'll give that a go, I was messing around with that earlyer and could not get it to work, I wounder if the format of the coding is the same. Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268310 Share on other sites More sharing options...
Lumio Posted June 5, 2007 Share Posted June 5, 2007 Can you show some of your code? Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268312 Share on other sites More sharing options...
crawlerbasher Posted June 5, 2007 Author Share Posted June 5, 2007 Well this is my code and still not working. <?php include("../header.php"); $id = $_GET['id']; if (is_numeric($id)) { echo "<p align=\"center\">\n"; echo "<img src=\"http://www.stateofmind.me.uk/images/cineworld/starwars/DSC".$id.".jpg\" alt=\"DSC".$id."\" border=\"0\" />\n"; echo "<br />\n"; echo $id; echo "<br /><br />\n"; echo "<a href=\"/cineworld/startwars.php\">Back</a>\n"; echo "</p>"; } else { echo "That is not a numeric value\n"; } include("../footer.php"); ?> with number string and caracters it still outpost as that is not a numeric value. Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268316 Share on other sites More sharing options...
Lumio Posted June 5, 2007 Share Posted June 5, 2007 do you get any error messages... if so, please give us those errors. Otherwise we can't really help you. It works for me. Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268323 Share on other sites More sharing options...
crawlerbasher Posted June 5, 2007 Author Share Posted June 5, 2007 The only error message are from the include function which is because for that pertiacal header and footer, are not on the site, I'm just testing the main code it self. Which gives these message: $id = 00127 // output is: That is not a numeric value $id = test // output is: That is not a numeric value Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268325 Share on other sites More sharing options...
Lumio Posted June 5, 2007 Share Posted June 5, 2007 comment the includings out.. I mean: //include(...) Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268329 Share on other sites More sharing options...
crawlerbasher Posted June 5, 2007 Author Share Posted June 5, 2007 I have its just the same kind of custom error message of That is not a numeric value with both numric and alpha caracters. But part from that there is no error in the phrashing of the code. Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268331 Share on other sites More sharing options...
Lumio Posted June 5, 2007 Share Posted June 5, 2007 So it is working? Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268334 Share on other sites More sharing options...
crawlerbasher Posted June 5, 2007 Author Share Posted June 5, 2007 lol it is now, it was a simple typeo in the url that was corsing the probble And thank you for help me get though this. Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268337 Share on other sites More sharing options...
Lumio Posted June 5, 2007 Share Posted June 5, 2007 ok... please click on TOPIC SOLVED Quote Link to comment https://forums.phpfreaks.com/topic/54273-solved-no-number-in-verable-error-message-output/#findComment-268344 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.