running into issues querying a custom table and getting results.
As of Wordpress 3.9, I can no longer run mysql_query(), and have to use $wpdb->query();
So keeping that in mind:
Old Code:
<?php
if (!empty($_GET['msg'])) {
global $wpdb;
$vuser_id = $_GET['id'];
$sql = "SELECT * FROM wp_quiz WHERE quiz_id='$vuser_id'";
$query = mysql_query($sql);
$result = mysql_fetch_assoc($query);
$total = $result['total_count'];
Updating it what I think would be proper:
<?php
if (!empty($_GET['msg'])) {
global $wpdb;
$vuser_id = $_GET['id'];
$sql = "SELECT * FROM wp_quiz WHERE quiz_id='$vuser_id'";
$query = $wpdb->query($sql);
$result = mysql_fetch_assoc($query);
$total = $result['total_count'];
and var_dumping $result gives me NULL
and I'm now getting the error:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, integer given in on line 16
I've tried using $wpbd->get_row($sql); $wpdb->get_results($sql); all come back null.
If I exit( $sql ); I can see that the query is being ran correctly
SELECT * FROM wp_quiz WHERE quiz_id='5925' and if I run this directly into phpmyadmin, it gives me the correct results.
I'm not sure what I'm doing wrong.
mysql_functions in WordPress, use$wpdb, or in general, as the mysql extension is deprecated, use PDO or Mysqli instead ifwpdbisn't available