Jump to content

Displaying Announcements on your site


Strother

Recommended Posts

WHMCS has the following code in their docs at http://docs.whmcs.com/Linking_to_WHMCS.


 

<?php

include("support/dbconnect.php");

include("support/includes/functions.php");

$query = "SELECT * FROM tblannouncements WHERE published='on' ORDER BY date DESC LIMIT 0,3";

$result = mysql_query($query);

while ($data = mysql_fetch_array($result)) {

$id = $data["id"];

$date = $data["date"];

$title = $data["title"];

$announcement = $data["announcement"];

$date = fromMySQLDate($date);

echo '<p><font color="#cccccc">'.$date.'</font> - <b>'.$title.'</b><br />'.$announcement.'</p>';

}

?>

 


 

Unfortunately it seems to have something missing or coded wrong. Running it returns the following:

 

'.$date.' - '.$title.'

'.$announcement.'

 

'; } ?>

 

Any ideas how to patch this snippet?

Link to comment
Share on other sites

Is "support/dbconnect.php" the right path for your environment and the page it's being called from? That path needs to match where your WHMCS installation is, and if it's echoing out only the var names and not the data, that may be why.

 

Strange it's including "'; } ?>" also, though. That shouldn't be there in that case. Is it possible the file was corrupted on upload, or the editor you'd used added in odd line breaks?

Link to comment
Share on other sites

I also had suspected the editor was tinkering with the code, but I have since tried it with three different editors with the same output.

What program and upload method are you using on the file (BINARY vs ASCII)? Whichever one, try the other. Some FTP programs default to one or the other and can introduce issues that way. It's echoing so PHP is parsing it, that leaves corruption as my main suspicion.

Link to comment
Share on other sites

I am using filezille, which was set to auto. When I changed it to ascii the file uploaded and can now be executed.

 

However, now we have new output, which is even more peculiar. When that code is executed, here is what gets returned:

 

[ATTACH=CONFIG]4150[/ATTACH]

 

So, it still seems there is something amiss in the code provided by Whmcs.

Link to comment
Share on other sites

Not sure what happened to the image, I've attached it here again.

 

At current, the code is only on one page of my site, and its not a WHMCS page. When I open that page, I get the "down for maintenance" response. If I remove the code, the page loads fine.

 

Further, while the code is on that page, other pages, including whmcs pages, load just fine.

 

I'm running 5.1.2.

 

Is anyone running this code on their own site with success?

 

dfm.jpg

Link to comment
Share on other sites

Is anyone running this code on their own site with success?

Well, I am, but I'm not using the latest version of WHMCS, it's one back. Mine doesn't call the DB since that gets called in another file on that same page, but other than a few minor changes it works on mine.

 

The function call uses the full path, not a relative path:

@include("/home/cpaneluser/www/whmcs-dir/includes/functions.php");

Have you tried that for both calls in yours?

Link to comment
Share on other sites

Ah, those were the days!

I've made it a rule that I never update to new releases until I see almost no complaints or bug reports. This one had some problems early on, so I held off. ;)

Just tried that, same result "Down for maintenance". Baffling.

I agree. Since mine works using the same code and yours does not, that implies it's an issue with your environment more than an issue with the script/code, I'd suggest. Have you looked into using error reporting to see if maybe it's not connecting to the DB? Not sure if this would reveal anything useful, but: http://docs.whmcs.com/Blank_Pages (I know it's not a blank page, but it shows the error reporting step).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated