Code check: calling simple PHP function doesn't work

I’m trying to trigger this function:

<?php
function messageNoResults() {
echo "<script>document.getElementById('messages').innerHTML = '<p>There are no results for that combo.</p>'<script>";
}
?>

I’m calling this function like this after two table queries have completed along with their mysql_num_count:

if ($counta == 0 && $countb == 0) { messageNoResults(); }

The message should be inserted at the top of the page:

<!-- warning messages displayed here -->
<div id="messages" style="color:red; text-align:center; visibility:visible;"></div>

I can successfully echo each of these counts, and they will return 0 each, but the function is not called. Any reason why?

This works.

function messageNoResults() {
    echo "<script>document.getElementById('messages').innerHTML = '<p>There are no results for that combo.</p>'<script>";
}

$counta = 0;
$countb = 0;

if ($counta == 0 && $countb == 0) { messageNoResults(); }

So the issue must be somewhere in the code we haven’t seen.

I was afraid of that.

The script has two open scripts tags, try replacing the second occurrence with a closing script tag.

Thank you! Thank you! Thank you! :eek:

Just one thank you was enough :slight_smile:

Glad I was able to help.