The query below worked when it contained just one variable ($MyURL). But when I added $MySection, I started getting this error message:
PDOStatement::bindParam() expects parameter 3 to be long, string given in...
I know how to add multiple values in a query that fetches an array, but this kind of query is confusing for me. What am I doing wrong?
$sql= "SELECT COUNT(URL) AS num FROM pox_topics
WHERE URL = :MyURL AND Site = 'PX' AND Section = ':MySection' AND Live != 0";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':MyURL',$MyURL,':MySection',$MySection,PDO::PARAM_STR);
$stmt->execute();
$Total = $stmt->fetch();
EDIT:
I've tried the following query with PDO::PARAM_STR following $MyURL, $MySection and following both of them...
$sql= "SELECT COUNT(URL) AS num FROM pox_topics
WHERE URL = :MyURL AND Site = 'PX' AND Section = :MySection AND Live != 0";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':MyURL',$MyURL,PDO::PARAM_STR);
$stmt->bindParam(':MySection',$MySection);
$stmt->execute();
$Total = $stmt->fetch();
But I'm getting this error message: "Invalid parameter number: number of bound variables does not match number of tokens"