Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Needing some help. (31st Mar 11 at 7:51pm UTC) | | Ok, I have an affiliate bar set up, that Dwight coded for me, but when things changed the affiliate bar stopped working. Dwight is unable to help right now, so I'm stuck with it not working. This is the error I get inside the affiliate bar: Fatal error: Cannot redeclare class Database in /home/idirect/public_html/includes/Database.class.php on line 35
Now when I take out /home/idirect/public_html in the line above, it shows the affiliates, but with a set of whole new errors:
[31-Mar-2011 10:37:55] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening '/includes/Database.class.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/idirect/public_html/includes/global.php on line 30
[31-Mar-2011 10:37:56] PHP Warning: include(/includes/Database.class.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/idirect/public_html/includes/global.php on line 30
I'm not quite sure what to do.
http://idirectory.us
If you need the files I can send them in PM.
Thanks | |
|
ashkir Full Member
Posts: 1,159 Status: Offline Gender: Male Location: Cali! Age: 35 Joined:
pmskypemsnyahoo | Re: Needing some help. (31st Mar 11 at 10:34pm UTC) | | For other softwares like drupal/wordpress. This means the functions file went missing. | |
|
Marc vChat Developer
I <3 Rossy
Posts: 3,388 Status: Offline Gender: Male Location: Ontario, Canada Age: 32 Joined:
Additional Groups: Coding Team
pmwww | Re: Needing some help. (1st Apr 11 at 2:38pm UTC) | | Ok, I have an affiliate bar set up, that Dwight coded for me, but when things changed the affiliate bar stopped working. Dwight is unable to help right now, so I'm stuck with it not working. This is the error I get inside the affiliate bar: Fatal error: Cannot redeclare class Database in /home/idirect/public_html/includes/Database.class.php on line 35Now when I take out /home/idirect/public_html in the line above, it shows the affiliates, but with a set of whole new errors: [31-Mar-2011 10:37:55] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening '/includes/Database.class.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/ php') in /home/idirect/public_html/incl udes/global.php on line 30 [31-Mar-2011 10:37:56] PHP Warning: include(/includes/Database.cla ss.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/idirect/public_html/incl udes/global.php on line 30 I'm not quite sure what to do. http://idirectory.usIf you need the files I can send them in PM. Thanks
The line I bolded in the quote above explains what the error is. Line 35 in Database.class.php is trying to declare a class that's already been declared somewhere else before. If Database.class.php is a file that came with a pre-built CMS (like Joomla or Wordpress), then their support is probably the best place to go as it's a problem with their system.
However, if Database.class.php is a file you (or Dwight) created, then you simply need to find where the class is first declared, make sure that deleting the class on line 35 won't break things, and then go ahead and delete the duplicate. | |
rroll.to— Shorten a link, rickroll your friends. |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Needing some help. (1st Apr 11 at 7:22pm UTC) | | Line 35 is just class Database {
and below it is
var $server = ""; //database server var $user = ""; //database login name var $pass = ""; //database login password var $database = ""; //database name var $pre = ""; //table prefix
and I nor did Dwight create it. I have no clue what to do. Everything pretty much depends on the Database. I don't know what joomla is, but I don't have either joomla or Wordpress..
| |
|
Marc vChat Developer
I <3 Rossy
Posts: 3,388 Status: Offline Gender: Male Location: Ontario, Canada Age: 32 Joined:
Additional Groups: Coding Team
pmwww | Re: Needing some help. (1st Apr 11 at 11:21pm UTC) | | Line 35 is just class Database { and below it is var $server = ""; //database server var $user = ""; //database login name var $pass = ""; //database login password var $database = ""; //database name var $pre = ""; //table prefix and I nor did Dwight create it. I have no clue what to do. Everything pretty much depends on the Database. I don't know what joomla is, but I don't have either joomla or Wordpress..
As I said, "class Database" is defined somewhere else already, which is why the site is throwing errors (you can't have multiple classes with one name, or one class defined numerous times). Joomla and Wordpess are examples of Content Management Systems (CMS); if you use a Content Management System for your website, then their support can likely help better than we can.
Whereabouts did you get the backend for your website? | |
rroll.to— Shorten a link, rickroll your friends. |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Needing some help. (2nd Apr 11 at 5:30am UTC) | | I see. And Dwight. Our coding is 80% the same I do believe On his and mine, basically copy/paste for him, but he's not in the mood to look into it, and im not gonna push it. I'll have a look in my files later and post back here. As I am not quite sure where to go or what to do. | |
|
Marc vChat Developer
I <3 Rossy
Posts: 3,388 Status: Offline Gender: Male Location: Ontario, Canada Age: 32 Joined:
Additional Groups: Coding Team
pmwww | Re: Needing some help. (2nd Apr 11 at 2:52pm UTC) | | I see. And Dwight. Our coding is 80% the same I do believe On his and mine, basically copy/paste for him, but he's not in the mood to look into it, and im not gonna push it. I'll have a look in my files later and post back here. As I am not quite sure where to go or what to do.
I feel like the most likely thing that happened is that you include()'d or require()'d the file twice on the same page; the best thing to do is to find all the instances of the database class and replace the include() or the require() (whichever function you're using) with include_once() or require_once(), respectively. These functions check to see if the file has already been included, and only includes it if it hasn't. | |
rroll.to— Shorten a link, rickroll your friends. |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Needing some help. (2nd Apr 11 at 5:45pm UTC) | | In my global.php which is included onto most pages it has this, the only ones that dont have this are the categorires. but they do have
<?php $name = 'Role Play'; include ("./includes/category_core.php"); ?>
and this is in the global.php include("/home/idirect/public_html/includes/Database.class.php"); ?>
with out that, it wont work.
But in the 700wideF.php it has this.
<?php include_once('/home/idirect/public_html/includes/Database.class.php'); include_once('/home/idirect/public_html/includes/global.php');
$db = new Database($DBhost, $DBuser, $DBpass, $DBname, $DBpre); $db->connect();
$rand_item = mysql_query("SELECT * FROM ads") or die(mysql_error());
echo "<marquee onmouseover=\"this.stop()\" onmouseout=\"this.start()\">";
while($row = mysql_fetch_assoc($rand_item)) { echo "<a href=\"$row[url]\" target=\"_blank\" /><img src=\"$row[image]\" border=\"0\" ></a> "; }
echo "</marquee>";
$db->close(); ?> | |
|
Marc vChat Developer
I <3 Rossy
Posts: 3,388 Status: Offline Gender: Male Location: Ontario, Canada Age: 32 Joined:
Additional Groups: Coding Team
pmwww | Re: Needing some help. (3rd Apr 11 at 4:06am UTC) | | Try changing the include() in global.php to include_once() and see if that works. | |
rroll.to— Shorten a link, rickroll your friends. |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Needing some help. (3rd Apr 11 at 2:57pm UTC) | | That worked! Thanks! | |
|
Marc vChat Developer
I <3 Rossy
Posts: 3,388 Status: Offline Gender: Male Location: Ontario, Canada Age: 32 Joined:
Additional Groups: Coding Team
pmwww | Re: Needing some help. (3rd Apr 11 at 11:56pm UTC) | | That worked! Thanks!
No worries. | |
rroll.to— Shorten a link, rickroll your friends. |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Needing some help. (4th Apr 11 at 4:49am UTC) | | PHP or any coding can be so difficult. x.x Thanks again. | |
|