$_POST variables acting like freaking GHOSTS! - $20 for fix!
Posted: Tue Jan 18, 2011 3:35 pm
Hello!
I've been struggling with this problem for over a week now - and I finally crawl the cross and ask for help. Because I'm 100% and totally lost on this issue. On my website I use lots of forms, obviously. The thing is, around a week ago these forms started acting really weird - not just "mentally unstable"-weird, I mean weird by the core defintion of that word!
Basically, at first it seemed random when a variable would lose and not lose its content. But I have isolated a couple of incidents where certain things happen. Let's take this code as our starting point:
This code will always lose the content of the variable, but FIRST when it is executed in the query. The query will run without errors, but $name will be inserted as empty. Nothing weird in that, could happen to anybody, right? BUT, I tried echo the content of $name JUST before the query - it HAS content. Now, if I submit the very same form and run the very same code this snippet WILL work right:
So it only runs the query if something exists in $name - works fine, and even executes the query everytime (which it wouldn't if $name was empty which it APPEARS to be when $name && is not validated in front of the query). If I do nothing else but removing $name && again, the error re-occurs and the data will be lost. I'm 100% sure no "stupid mistake" is involved in this, as I said I've been error isolating over a week now.
Also, I could of course just do the $name && in front of all queries, but I dont want that. I want my code to work - and I want to understand WHY it works.
If I do this:
$name will be perfectly echoed - So my logic tells me query is the thing that doesn't function. But yet it does update the information whenever I had the $name && in front. And replacing $name with static text in the query will also execute perfectly (and of course update the information).
Another weird thing I'm not 100% sure is related to this, is that I can execute this code:
This will correctly show -- then the content of the POST variable and then --. HOWEVER, if I open to view the source there's only the dashes.. So the source code will show: ----
WHILE in the render there is the content of the $POST variable.. How is this even possible? It shouldnt be to my understanding. This only happens in Google Chrome, in Firefox and IE it shows up correctly in the source code.
I've never seen anything like this in my 7 years of PHP programming, and I really hope someone can help me out. This is holding back the project of my life which Ive been working on for over 2 years now. And it has spread to all corners of my app :-/ I have too been thinking virus, but then again, how can I virus on the server side make the browser act weird - and how can a client side virus make the database lose information?
I also tried a complete server move and messed around with magic_gpc and register_global. Feels like I've tried everything possible several times.
I'm really lost. I'm so lost I will pay $20 for the solution (via Paypal) - if several people contribute to the actual fix the amount will be split.
I've been struggling with this problem for over a week now - and I finally crawl the cross and ask for help. Because I'm 100% and totally lost on this issue. On my website I use lots of forms, obviously. The thing is, around a week ago these forms started acting really weird - not just "mentally unstable"-weird, I mean weird by the core defintion of that word!
Basically, at first it seemed random when a variable would lose and not lose its content. But I have isolated a couple of incidents where certain things happen. Let's take this code as our starting point:
Code: Select all
$name = $_POST['setname'];
mysql_query("UPDATE em_database_content SET name='$name' WHERE id='$id'");Code: Select all
$name = $_POST['setname'];
$name && mysql_query("UPDATE em_database_content SET name='$name' WHERE id='$id'");Also, I could of course just do the $name && in front of all queries, but I dont want that. I want my code to work - and I want to understand WHY it works.
If I do this:
Code: Select all
$name = $_POST['setname'];
mysql_query("UPDATE em_database_content SET name='$name' WHERE id='$id'");
echo $name;Another weird thing I'm not 100% sure is related to this, is that I can execute this code:
Code: Select all
echo "--" . $_POST['setname'] . "--";WHILE in the render there is the content of the $POST variable.. How is this even possible? It shouldnt be to my understanding. This only happens in Google Chrome, in Firefox and IE it shows up correctly in the source code.
I've never seen anything like this in my 7 years of PHP programming, and I really hope someone can help me out. This is holding back the project of my life which Ive been working on for over 2 years now. And it has spread to all corners of my app :-/ I have too been thinking virus, but then again, how can I virus on the server side make the browser act weird - and how can a client side virus make the database lose information?
I also tried a complete server move and messed around with magic_gpc and register_global. Feels like I've tried everything possible several times.
I'm really lost. I'm so lost I will pay $20 for the solution (via Paypal) - if several people contribute to the actual fix the amount will be split.