I am using AJAX to send values to PHP and retrieve the values from PHP. The problem is the value i am getting from PHP is viewed as undefined in AJAX. Please help me solve this
Just a point no-one else has covered yet: you need to use double quotes or concatenation here:
'select * from $channel'; // no
"select * from $channel"; // yes
'select * from '.$channel; // yes
Variables won't be resolved inside single quotes so you are trying to select from a table that is literally called $channel
.
Also please use some kind of validation on $channel
as what you have is very vulnerable to SQL injection attack.