I'll try to make it short.
When i set flash data like this
$this->session->set_flashdata('testing', $somevariable);
I should get something like this in session:
'flash:new:testing' => string 'Test'
And this works.
When I make a new server request it should say
'flash:old:testing' => string 'Test'
I don't get to this part. Even at first request (while it is still "new") i get boolean (false) when trying to get flashdata.
I should mention this is working in wamp, but not on my live site.
Any ideas?
Thanks in advance
It seems strange !
Maybe you should check the value of var_dump($somevariable) in your live site.
Related
I've noticed a wierd behavior of php curl GET query to Cloudflare API https://api.cloudflare.com/client/v4/zones
When using Postman — everything is okay and it show correct response
But when trying to get via PHP it returns '1' for some reason. Here is my code and logs:
Also tried to pass in body, but it didn't work too
Please, help me to figure out the problem and fix it. Thanks!
p.s. i've also tried to pass urlencoded variable, but this also has no effect
The problem was in logs — i've just forgot to add second true parameter to print_r so it'll return the output
I have an issue with post variables in Codeigniter, for now I fixed it, but I'm not sure if this is fine, in other words, I'd really like to know why I had issue only on hosting server, not on local.
The problem:
I wanted more secure script so I replaced $_POST/$_GET with $this->input->post and $this->input->get, like in this example:
if(!empty($this->input->get('endDate'))){
$data['datepicker'] = $this->input->get('thisDate');
}
this was all working fine on my localhost, but I assume it is wrong way, as when I deployed to the hosting server, I've got ajax parse error from validation engine that I'm using, I couldn't log in the system, getting all the time ajax parse error, and somehow figured out that whenever I checked if empty$this->input->post('var) or the same with get, was wrong.
I have checked the input class from Codeigniter and figured out, that $this->input->post is returning true/false, so I changed the scripts in the format like this:
if(!($this->input->get('endDate'))){
$data['datepicker'] = $this->input->get('thisDate');
}
this worked fine.
I'm still wondering - why the code worked on the localhost, but it didn't on the server or what is the best way to check if the POST/GET variable is empty or not.Seems I really miss something out.
Thank you.
Consider that checking for empty($this->post->get('var')) will always return false, no matter if the POST/GET exists, so it might be for that reason only. - So i'm not sure why you got the error on a different environment, but the first statement is wrong, it's exactly like writing if(true)
Also, I'd check for a strong assertion of false for inputs, You never know when you might need a zero as an input and if you're used to this practice, you might get an accidental false.
I'm using the following in my php code:
$file="query.txt";
$f=fopen($file,'a');
fwrite($f,"Query String:".$_SERVER['QUERY_STRING']."\n");
fclose($f);
It never returns anything. I'm simply trying to record the queried url when someone visits (i.e. http://example.com/index.php?q=string. Other $_SERVER fields seem to work just fine, it only seems to be the query string that doesn't work. Maybe there's something I need to setup in my .htaccess?
I'm hoping someone has an answer to how to get this to information to show.
This solved the problem:
$_SERVER['REDIRECT_QUERY_STRING']
solution from https://stackoverflow.com/a/11618256/1125006
i have session code
it's working fine
but some friend told me this code should not work !
but it's work fine with me !
i try code on localhost
so my question is , if i uploaded this code to my server
it will work fine like localhost ?
or will not work like my friend said ?
my code is
session_start();
$_SESSION['news'][] = 'First';
$_SESSION['news'][] = 'Second';
print_r($_SESSION['news']);
its print
Array ( [0] => First [1] => Second )
and that's what i want !
it's fine ..
Yes it will work definitely.
Or to be more safe you can do like following before assigning it values.
$_SESSION['news'] = array();
Your friend is wrong. You can use arrays as session variables.
For supporting arguments, please see array as session variable and Can I Store An Array In A Session?.
It seems okay to me. There's no reason why it shouldn't work on your server.
After 5 hours of tests ,,
it's seems not work like my friend said !
he was right
for first time i used this way , i got an error
but i ingored it , because it's did not happin again !
but the error is show in first time only !
i browsed the page from another browser
i got that error !
i forget to save the error , but it's say you can not use empty []
after all , iam now use it as numbers
and thank you again and sorry for my language
Using twitterauth to try to post status updates. This is my code (which returns a 403 error from twitter when I try to post it):
$fact = "This is a status update. http://onth.is/iss" ;
$parameters = array('status' => $fact);
However, if I do this:
$parameters = array('status' => "This is a status update. http://onth.is/iss");
It post perfectly fine. I know it has something to do wit the URL, because if I remove it from the first code it works.
Any tips? Thanks in advance!
If you are referring to the twitteroath library then I don't see anything wrong with your code. However, you can speed things up a little bit by doing:
$parameters["status"] = "This is a status update. http://onth.is/iss";
The two statements are identical, except that the latter will create a syntax error :)
My guess would be that you need to urlencode() the string before sending it to Twitter, but not knowing the library you are using, I can't say for sure.