Jump to content

What path to give to display announcements on my html template ?


Recommended Posts

Hi,

I have installed my whmcs in a sub directory like directory.whmcs.com

 

Now i m using the following code to display 3 announcements on my html website template ..

 

"<?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>");

}

?>"

 

According to whmcs I should only change the support with my directory Path I need to know what It will be ? will it be like /home/user/public_html/directory/ or will it be /public_html/directory/ or http://www.directory.whmcs.com ?

 

I have tried them all and nothing is working I am lil confused here ..

Link to comment
Share on other sites

Change

 

include("[color=red][b]support[/b][/color]/dbconnect.php");
include("[color=red][b]support[/b][/color]/includes/functions.php");

 

 

to the location of your directory, try the dir of your whmcs.

 

include("[color=red][b]Where Your WHMCS Is Located[/b][/color]/dbconnect.php");
include("[color=red][b]Where Your WHMCS Is Located[/b][/color]/includes/functions.php");

Link to comment
Share on other sites

I have tried it but its not working somehow its not getting connected to the database file .. I am currently giving the absloute path to where my whmcs is located like

 

"/home/user/public_html/whmcs/dbconnect.php"

 

but its not working

 

or should I give there html path ? like http://www....

 

help needed in this regard ?

Link to comment
Share on other sites

  • 1 year later...

<?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>");

}

?>

Link to comment
Share on other sites

This does not seem to work. My site is http://recongaming.net and I have tried every configuration I can think of. Attached is the end result in everything I try. Suggestions?

 

Also, Is this code for the latest version of whmcs? Im sure it is due to you being a senior member and all, butt I gotta ask.

ann_error.jpg

Edited by tjmartin
Link to comment
Share on other sites

I use lastrss to display a small ticker on my site site wide I was looking at doing banners but this was easier :-)

 

here is a link to my site http://gr8greenhosting.com the ticker is just under the chat banner on the right, If you need something like that I'd be glad to help it takes a wee bit of coding and css changing here is the site I got the script from http://www.dynamicdrive.com/dynamicindex17/rsstickerajax/index.htm

Link to comment
Share on other sites

  • 2 months later...

This mistake I had made when I built my site is that I didnt use .php tags. I had html and the code wouldnt work. a n00b like me was unaware of this and couldnt even find it online. Once you save it as a php file and insert the code, it should work fine as long as your paths are correct. Im guessing you are the one that visited my site today to see it working. Here is the code that I used and still works with the current version of whmcs.

 

<?

$x=1;

// truncate the text to only 65 chars, add ... to the end

function truncate($text) {

$text = substr($text,0,40);

$text = substr($text,0,strrpos($text,' '));

$text = $text." ... ";

return $text;

}

// format the date to mm/dd/yyyy

function formatdate($date) {

$year = substr ($date, 0, 4);

$month = substr ($date, 5, 2);

$day = substr ($date, 8, 2);

return $month.'/'.$day.'/'.$year;

}

// limit the number of announcements to return

$limit = 3;

 

require '/home/YOURHOSTNAME/public_html/billing/configuration.php';

$link = mysql_connect($db_host,$db_username,$db_password);

mysql_select_db($db_name);

 

$result = mysql_query("SELECT * FROM tblannouncements WHERE published='on' ORDER BY id DESC LIMIT ".$limit);

while($data = mysql_fetch_array ($result))

{

$id = $data['id'];

$title = $data['title'];

$date = $data['date'];

$announcement = truncate($data['announcement']);

$date = formatdate($date);

echo'<b>'.$date.' - '.$title.'</b><br>'.$announcement.' <a href="billing/announcements.php?id='.$id.'"><img src="../images/more.gif" border="0" alt="More »" /></a>';

echo'<hr />';

$x=false;

}

if(!$x) echo '<p>Older News: <a href="/billing/announcements.php">More »</a></p>';

if($x) echo '<p>There are no new announcements.</p>';

?>

 

Just change the YOURHOSTNAME to yours and make sure you use the correct directory of your whmcs, mine is listed as billing.

 

Goodluck

Link to comment
Share on other sites

You have your page set as "index.php" and the code isnt working? You changed you path names to reflect your hosting correctly? If you want.. you can jump on my site and use our live chat and I can try to help you through there. Its easier than having lengthly posts. What is your domain where you are adding latest announcements?

Link to comment
Share on other sites

  • 1 month later...

Im using this for my homepage, but im running my web in 2 languages. And i have 2 home pages. In English is working in second language is not working. (Im using just 2 languages).

 

 

$result = mysql_query("SELECT * FROM tblannouncements WHERE published=' ' ORDER BY id DESC LIMIT ".$limit);

 

The text is apparing good but the date and the link is not working? Any idea?

Link to comment
Share on other sites

Im using this for my homepage, but im running my web in 2 languages. And i have 2 home pages. In English is working in second language is not working. (Im using just 2 languages).

 

 

$result = mysql_query("SELECT * FROM tblannouncements WHERE published=' ' ORDER BY id DESC LIMIT ".$limit);

 

The text is apparing good but the date and the link is not working? Any idea?

 

 

Anyone know how to fix that?

Link to comment
Share on other sites

  • 9 months later...
  • 4 weeks later...
  • 9 months later...

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