December 21st, 2012, 05:44 PM
My cronjob has starting giving me the following warning:
Warning: str_pad() expects parameter 4 to be long, string given in ....
it references the following lines of code:
$lastphotoname = $filedirectory . $filename . "_" . str_pad($lastphotonum, 7, "0", STR_PAD_LEFT) . ".jpg";
$nextphotoname = $filedirectory . $filename . "_" . str_pad($nextphotonum, 7, "0", STR_PAD_LEFT) . ".jpg";
Any ideas as to why I get the warnings ?
It appears that my host upgraded the php version to 5.3.19 the day before my warnings started to appear .... but not sure why that would have anything to do with it ......
December 21st, 2012, 05:59 PM
December 21st, 2012, 08:22 PM
December 21st, 2012, 08:55 PM
Are you absolutely sure that the error is recent and coming from exactly those two lines? And that the code is exactly what you posted? Please check again. Because PHP just told you that those constants do exist; if they didn't then PHP would treat them as literal strings (with a warning) causing the error you see.
December 21st, 2012, 09:26 PM
My cronjob has been running 4 times a day for over a year and never complained - then several days ago I started getting this message ....
Sometimes when I get an error the lines don't always match up with the line numbers I see in TextWrangler but in this case I am sure in that these two lines of code are the only two lines of code that use str_pad ....
I cut and pasted the code right out of my source code ... so it is definitely the correct code ....
Like you - it doesn't make sense to me either .....
The code changes the home page picture on my website - rotating amongst 11 pictures - it has been changing the picture that whole time and what is weird is that it still is - so does this error not actually stop the code from executing correctly ? Could it be that it has always had this warning and the host site just turned on the piece that gives me my errors ? But even so - what is the warning about - the code looks perfectly fine to me -
December 21st, 2012, 10:21 PM
Yeah, it could be that the new installation just changed the error reporting settings. Actually that happens very often - we regularly see people who tell of brand new errors in scripts that were working "perfectly" before.
But in your case I don't see anything wrong... No offense but past experience tells me that there's something important you're not telling us (unintentionally, I'm sure).
If you try running the file manually yourself does it still complain? And perhaps a more obvious question, what does
output and are there any errors with it?
December 22nd, 2012, 05:13 PM
ran the code manually and it ran fine - no errors
the echo str_padLeft returned: 0
what is even weirder is that the next time my routine ran from the cronjonb it did not send me any warnings .... just as they mysteriously started appearing, they have mysteriously disappeared ..... maybe it had something to do with Mayans
any thoughts .....