Twilight Zone - Will need anger management soon!

This problem is straight out of the twilight zone. I don’t expext to get an answer because the problem doesn’t even make sense.

I was up all last night trying to complete some code. But it wouldn’t work. I woke up this morning thinking that after a break, the solution will be staring at me in the face. I was wrong.

During testing, I echo this code:

echo $_POST[‘category’];

It returns:

2-category.php

That part makes sense!

So I add this code:

$fetch_category = $_POST[‘category’];
echo $fetch_category;

Now the script has a corinary and says:

Notice: Undefined variable: fetch_category… etc…

I tried to work out what the deal is for hours. I EVEN retyped the whole code manually (instead of copy and paste), just in case there was some character wrong that I was blind to. But, the problem is the same.

So, I figure: Ok, the server must have its wires crossed or something. So I restarted the server. I still have the same problem.

I am completely and utterly out of solutions, and if I can’t work out what the deal is, I am going to have to completely restart the code which will take me all day.

But I don’t see how {{{{anything}}}} in the code could possibly cause that problem!

If:

echo $_POST[‘category’];

returns:

2-category.php

THEN echo $_POST[‘category’]; {{{IS}}} 2-category.php

and this:

$fetch_category = $_POST[‘category’];
echo $fetch_category;

SHOULD BLOOMIN’ WORK!!!

($^%@#^u@!

kick (&$^(&#% spit *&$#$# PUNCH!

Ok there goes 24 hours. Lovely! Just what I needed!

By the way, if I rewrite the whole page from scratch and I get the same problem, you’ll probably see me on CNN or something, with a police psychologist trying to talk me down…

Yes… and it has a coronary… and soon I am going to, if the code doesn’t start making sense.

Anyway, I have totally started rewriting the entire page.

Something, somewhere is just making php go spastic. I am sick of dealing with it. So, I’ll start again, should be done in a few hours. I am not spending another 24 hours trying to work out something that can’t be worked out.

I really hate coding. I only do it because I have to…

I did check to see if it exists.

During testing, I echo this code:

echo $_POST[‘category’];

It returns:

2-category.php

And your entire code is

echo $_POST['category'];
$fetch_category = $_POST['category'];
echo $fetch_category;

with no other code in between?

Well in your code do you have a check to see if the post variable is present first? Try adding $fetch_category = ‘’; at the top of your script and see what happens. Remember its a notice, not a error/warning. If that doesnt work going to see more of the code.

Again your problem is a notice, its saying the variable has not been defined yet. We need to see more code to help you out on this. Just because the value of post echos out correctly doesnt mean the variable was defined.

In order for that example to work you need to also have a form which does a POST.

You could also be dealing with local browser caches, which need to be cleaned out.


<form method=POST action= "">
<input id="category" name="category" value="mycat">
<input type="submit">
<?php
if( isset( $_POST['category'] ){

$cat = $_POST['category'];

echo "Your chosen category is $cat";

} else {

echo "Press submit first" ;

}

?>
</form>

This is one reason why many people when fiddling around with forms would change all of the above POST references to GET, so they can just mess with the arguments in the URL string and press refresh to be sure they are getting false results from F5 refreshes.

Then change them back to POST when all is looking good.

Can you post your whole page (in [ php ] tags), that way we can look to see what’s going on…