paulman888888 Posted May 31, 2008 Share Posted May 31, 2008 This is my script and i would like to limit how long the name can be, i would like the maxium name lengh to be 14. <?php // Insert a row of information into the table "example" mysql_query("INSERT INTO example (name, score) VALUES('" . mysql_real_escape_string($_GET['name']) . "', '" . mysql_real_escape_string($_GET['score']) . "')") or die('Theres an error.# Please try again.#'); echo "Score Uploaded!#"; ?> Thankyou Link to comment https://forums.phpfreaks.com/topic/108115-solved-quick-question/ Share on other sites More sharing options...
metrostars Posted May 31, 2008 Share Posted May 31, 2008 if(strlen($_GET['name']) > 14) {echo "Name must be less than 14 characters";} else { rest of script } Link to comment https://forums.phpfreaks.com/topic/108115-solved-quick-question/#findComment-554152 Share on other sites More sharing options...
paulman888888 Posted May 31, 2008 Author Share Posted May 31, 2008 nice idea this this script is going to viewed on a apaliction. Is there a way of just not saveing the rest of the charerters after 14 Link to comment https://forums.phpfreaks.com/topic/108115-solved-quick-question/#findComment-554154 Share on other sites More sharing options...
Prismatic Posted May 31, 2008 Share Posted May 31, 2008 nice idea this this script is going to viewed on a apaliction. Is there a way of just not saveing the rest of the charerters after 14 <?php $name = substr($_GET['name'], 0, 14); ?> Link to comment https://forums.phpfreaks.com/topic/108115-solved-quick-question/#findComment-554156 Share on other sites More sharing options...
metrostars Posted May 31, 2008 Share Posted May 31, 2008 <?php // Insert a row of information into the table "example" mysql_query("INSERT INTO example (name, score) VALUES('" . mysql_real_escape_string(substr($_GET['name'], 0, 14)) . "', '" . mysql_real_escape_string($_GET['score']) . "')") or die('Theres an error.# Please try again.#'); echo "Score Uploaded!#"; Link to comment https://forums.phpfreaks.com/topic/108115-solved-quick-question/#findComment-554157 Share on other sites More sharing options...
paulman888888 Posted May 31, 2008 Author Share Posted May 31, 2008 thankyou everyone Link to comment https://forums.phpfreaks.com/topic/108115-solved-quick-question/#findComment-554205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.