Using PHP’s var_dump() to Display SQL Query Results

Using the power of PHP’s var_dump() displays structured information about one or more expressions that includes its type and value. By definition var_dump() is a debugging tool, which displays structured information about any PHP variable. Below is a handy bit of code using var_dump() to test and verify that a SQL query contains data and view the contents using PHP:


$sql = mysql_query("SELECT * FROM your_table WHERE key = 'value'");
$assoc = mysql_fetch_assoc($sql);

// Dump variable containing the result of the MySQL query
var_dump($assoc);

Continue reading Using PHP’s var_dump() to Display SQL Query Results