Stats: 3,187,893 members, 7,933,302 topics. Date: Wednesday, 28 August 2024 at 12:38 AM |
Nairaland Forum / Science/Technology / Programming / Help! Php If Else Logs Out For Months Of August And September (1041 Views)
Freshly Spammed SHOPWITHSCRIP Logs Available / Shopwithscrip: Logs Available And How To Use / Finally Got A Badass Laptop After Months Of Saving, Come Celebrate With Me(pics) (2) (3) (4)
Help! Php If Else Logs Out For Months Of August And September by uvalued(m): 2:02am On Sep 01, 2017 |
Hello all. am calculating the session eg 2017/2018 by the current date dd-mm-yyyy after exploding it. however when it comes to august and september it log out. below is the problem i did for jan -july, but august 08 & september 09 it logs out. $seg takes in mm(month) after exploding the current date. eg jan is 01, july is 07
|
Re: Help! Php If Else Logs Out For Months Of August And September by uvalued(m): 10:15am On Sep 01, 2017 |
32 views and no response ![]() |
Re: Help! Php If Else Logs Out For Months Of August And September by Nobody: 10:31am On Sep 01, 2017 |
Because with Xdebug or Zend Debugger you can stop and debug and see what's going on, you should be able to trace and solve this |
Re: Help! Php If Else Logs Out For Months Of August And September by SoftEng: 11:48am On Sep 01, 2017 |
TL; DR Removing the zeros trailing each number in your else if condition The Issue The issue is with the way you represent the numbers (i.e. 01, 02, 03 and so on) in the if condition. Integer number are usually not represented that way in code. It was strange to see that php allowed it. After some little experiment in PHP REPL and a little online search, I realised that I you prefix an integer with zero in PHP, it menas that the number is an 'octal' (base ![]() From the stack overflow link below, it looks like error such as the one described above was ignored in PHP 5, however, in PHP 7, codes with such errors produces an error message https://stackoverflow.com/questions/40735963/parse-error-invalid-numeric-literal The Solution In essence, to resolve the bug in your code, remove the trailing zero before each number (in the if-condition) in your code. Your code should be: ... else if ($seg == 1 || $seg == 2 || $seg == 3 || $seg == 4 || $seg == 5 || $seg == 6 || $seg == 7 || $seg == 8 || $seg == 9) { ... } ... |
Re: Help! Php If Else Logs Out For Months Of August And September by uvalued(m): 12:33pm On Sep 02, 2017 |
thanks guys... got it solved after much prayers ... got inspired to coment all to '08' '09' and eureka solved...nevertheless will take your opinion to heart. thanks |
Re: Help! Php If Else Logs Out For Months Of August And September by Codenister: 8:38am On Sep 05, 2017 |
uvalued:On a side note, find better names for your variables. Your code is somewhat hard to read |
(1) (Reply)
Fresh Graduate Programmers Needed For A Permanent Role / Little Challenge With Client,please Help Resolve / How To Use Both Django And Node.js
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13 |