This is how I would do it, in mysql and PDO.
Mysql
/*In the deprecated mysql extension*/
$pid = "test123";
/*connecting*/
$conn = mysql_connect('localhost', 'user', 'password');
mysql_select_db('database');
/*If this comes from outside you need to escape it*/
$pid = mysql_real_escape_string($pid, $conn);
/*Putting backtick around columns that are reserved words*/
$result = mysql_query("SELECT `name` FROM my_table WHERE
`channel`= '$pid'", $conn);
$content = mysql_result($result, 0);
echo $content;
PDO
/*In PDO*/
$pid = "test123";
$pdo = new PDO("mysql:host=localhost;dbname=database", 'user', 'password');
/*Putting backtick around columns that are reserved words*/
$query = "SELECT `name` FROM my_table WHERE
`channel`= :pid";
$pdo_stmt = $pdo->prepare($query);
/*Prepared statements escape it for you*/
$pdo_stmt->bindValue(":pid", $pid);
$pdo_stmt->execute();
echo $pdo_stmt->fetchColumn();
mysql_*functions are deprecated as of PHP v5.5 and have been removed as of v7.0. They should not be used for new code and should be swapped out for mysqli or PDO equivalents as soon as possible.