merylvingien Posted November 20, 2009 Share Posted November 20, 2009 I know, i am boring you all now I have tried searching for this answer but i cant find the solution. There is something wrong with this code and i cant figure it out! if (strlen($adverttext) < 200) {$advertstrength = "4";} else if((strlen($adverttext) >= 200) && (strlen($adverttext) < 400)) {$advertstrength = "3";} else if ((strlen($adverttext) >= 400) && (strlen($adverttext) < 600)) {$advertstrength = "2";} else if (strlen($adverttext) >= 600) {$advertstrength = "1";} else Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/ Share on other sites More sharing options...
waynew Posted November 20, 2009 Share Posted November 20, 2009 What is going wrong? What do you expect to happen? And what is actually happening? Also, you didn't post the entire code block. What's in that last else statement? Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/#findComment-961958 Share on other sites More sharing options...
merylvingien Posted November 20, 2009 Author Share Posted November 20, 2009 Well without that piece of code in there the page works fine, if i add that code then the page outputs nothing, not even an error. if (strlen($adverttext) < 100) {echo 'error'; include("foot.html"); exit;} else if (strlen($adverttext) > 1000){echo 'error'; include("foot.html"); exit;} else if (strlen($phone) < {echo 'error'; include("foot.html"); exit;} else if (strlen($phone) > 16) {echo 'error'; include("foot.html"); exit;} else if (strlen($mobile) > 16) {echo 'error'; include("foot.html"); exit;} else if ($email == $row['email'] && md5($password) == $row['password']){ continue that works if (strlen($adverttext) < 100) {echo 'error'; include("foot.html"); exit;} else if (strlen($adverttext) > 1000){echo 'error'; include("foot.html"); exit;} else if (strlen($adverttext) < 200) {$advertstrength = "4";} else if((strlen($adverttext) >= 200) && (strlen($adverttext) < 400)) {$advertstrength = "3";} else if ((strlen($adverttext) >= 400) && (strlen($adverttext) < 600)) {$advertstrength = "2";} else if (strlen($adverttext) >= 600) {$advertstrength = "1";} else if (strlen($phone) < {echo 'error'; include("foot.html"); exit;} else if (strlen($phone) > 16) {echo 'error'; include("foot.html"); exit;} else if (strlen($mobile) > 16) {echo 'error'; include("foot.html"); exit;} else if ($email == $row['email'] && md5($password) == $row['password']){ continue that doesnt work! Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/#findComment-961965 Share on other sites More sharing options...
c-o-d-e Posted November 20, 2009 Share Posted November 20, 2009 What is your error, and what are you trying to do with the code. Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/#findComment-961975 Share on other sites More sharing options...
mikesta707 Posted November 20, 2009 Share Posted November 20, 2009 Without seeing more code, and a better description of what your problem is, and what you expect to happen, we can't really help you. THose if statements look OK, besides the fact that they are strangely formatted, and hard to tell if they are elseifs or else statements with a nested if inside of them Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/#findComment-961978 Share on other sites More sharing options...
merylvingien Posted November 20, 2009 Author Share Posted November 20, 2009 Well there is no error, the page just outputs nothing and wont update the database. What i am trying to achieve, is if someone enters less than 200 characters in their text, then in the control panel, it will flag up saying that their text is too short and is weak. they should consider updating it. Same sort of thing if the text is between 200 & 400 but its not so bad. if the text is between 400 & 600 then its quite good. if its above 600 then its exellent. Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/#findComment-961981 Share on other sites More sharing options...
rajivgonsalves Posted November 20, 2009 Share Posted November 20, 2009 first of all the formatting is really weird I had to really concentrate to have the heart to edit it , anyways this should work <?php if (strlen($adverttext) < 100) {echo 'error'; include("foot.html"); exit;} else if (strlen($adverttext) > 1000){echo 'error'; include("foot.html"); exit;} else if (strlen($adverttext) < 200) {$advertstrength = "4";} else if((strlen($adverttext) >= 200) && (strlen($adverttext) < 400)) {$advertstrength = "3";} else if ((strlen($adverttext) >= 400) && (strlen($adverttext) < 600)) {$advertstrength = "2";} else if (strlen($adverttext) >= 600) {$advertstrength = "1";} if (strlen($phone) < {echo 'error'; include("foot.html"); exit;} else if (strlen($phone) > 16) {echo 'error'; include("foot.html"); exit;} if (strlen($mobile) > 16) {echo 'error'; include("foot.html"); exit;} if ($email == $row['email'] && md5($password) == $row['password']){ } ?> Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/#findComment-961986 Share on other sites More sharing options...
mikesta707 Posted November 20, 2009 Share Posted November 20, 2009 I would suggest putting the else and the if on the same line. I suspect that php is reading the structure of your if statements incorrectly (or rather, not in the way you intended) is there any more code than this? if so please post it edit: yeah pretty much what raj wrote Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/#findComment-961990 Share on other sites More sharing options...
merylvingien Posted November 20, 2009 Author Share Posted November 20, 2009 Sorry its my crappy style of coding, but yes i beat you all too it I did exactly what you have suggested and that works out ok. Many thanks for the input Quote Link to comment https://forums.phpfreaks.com/topic/182299-solved-string-length-problem/#findComment-961998 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.