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 Quote Link to comment 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 } Quote Link to comment 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 Quote Link to comment 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); ?> Quote Link to comment 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!#"; Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted May 31, 2008 Author Share Posted May 31, 2008 thankyou everyone Quote Link to comment 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.