2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 18, 2017   (RSS)

Hi, All. I have a code snippet in need of conversion for MySQLi.

I've used the following code (probably derived from an old forum post) to present a list of blog month + year archive links. After updating to PHP 7 this code causes the error "UNCAUGHT_EXCEPTION: Call to undefined function mysql_query()".

<?php
$query = "SELECT DATE_FORMAT(pubDate, '%M %Y') as dateAndYear, YEAR(pubDate) as year, MONTH(pubDate) as month FROM cmsb_blog GROUP BY dateAndYear ORDER BY pubDate DESC";
$result = mysql_query($query) or die("MySQL Error: ". htmlspecialchars(mysql_error()) . "\n");
 while ($record = mysql_fetch_assoc($result)):
?>

Simply changing mysql to mysqli isn't enough. I think it needs some further editing and am wondering if anyone here could offer assistance?

~ Deborah