I am really struggling with PDO. I have looked at so many posts and tutorials on the web and am just getting more confused. (It was much easier to write plain mysql queries)
I currently have
[php]$studyname = $wpdb->get_row(“SELECT * FROM variants WHERE variant = ‘$surname’”);[/php]
This works perfectly and returns the results I expect.
But I need to sanitise $surname before I use it in the query.
So I have tried
[php]
$sql = “SELECT * FROM ‘variants’ WHERE variant = ‘$surname’”;
$result = $wpdb->prepare($sql);
$result->execute();
$studyname = $result->fetch(PDO::FETCH_ASSOC);
[/php]
and many variants and this just throws various errors. I am not sure whether this is me or Wordpress, I suspect me not understanding PDO.
Anyone got any suggestions?