how to make the response result at sEcho become not zero?
{"sEcho": 0,
i’ve been use this code but result still zero..
$sOutput .= '"sEcho": '.intval($_POST['sEcho']).', ';
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Okay, time to elevate this to an answer.
This line takes the output of the function
postVar, when given the paramater'sEcho', then takes that result and runs it through the built-in functionintval.That integer is then appended using the
.concatenation operator to the string'"sEcho":', which is then appended to the variable$sOutputintvalturns whatever it was passed into an integer. This is like casting. Pretty much any string is turned into zero.intval('YOUR FACE IS ON FIRE')will return 0,intval('')will return 0, etc.I don’t know where
postVaris, but I’m going to wager based on the provided example code link that it’s some ill-conceived wrapper around$_POST. So, another way to write it might be:The bottom line is that the thing being passed to
intvalis turned into zero. It’s very likely that the input named “sEcho” is not a string that can be turned into anything but zero.That’s where your zero is coming from.
To fix it, you need to pass something to
intvalthat won’t get turned into a zero.As a side-note, if you’re actually using the linked example code, you should probably be aware that the code in question is complete, utter garbage. It’s filled with bad practices, like persistent connections, the use of the outdated
mysqlextension, manual assembly of JSON strings, and the most horror of horrors, a poorly thought out Hungarian Notation style. Seriously, sEcho being a thing that was cast to an integer? Shouldn’t it be iEcho then? Sigh.