General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 27th, 2002, 02:08 PM
WebGuy WebGuy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 54 WebGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Cannot redeclare function

Hi all,

I have a script that checks to see if the usernames and passwords users enter are correct, but the problem is in a file called common.php, a file that contains basic variable and function definitions. Here's the error I receive:
Quote:
Fatal error: Cannot redeclare errormsg() (previously declared in /usr/local/www/virtual2/66/175/22/189/html/cms/common.php:26) in /usr/local/www/virtual2/66/175/22/189/html/cms/common.php on line 26
And the code that causes the error: (Line 26 is the one that says: function errorMsg(...) Also, in the files in which this file is include()d, there aren't any function definitions in them.
PHP Code:
<?php // common.php

// Default Width of Message Tables
$deftablewidth "70%";

// Header Background Color
$headcolor "#000099";

// Header Text Color
$headtextcolor "#FFFFFF";

// Row 1 Background Color
$row1back "#CCCCFF";

// Row 2 Background Color
$row2back "#9999FF";

// Default Font
$defaultfont "Verdana,Arial,Helvetica";

// Default Font Size
$defaultfontsize "2";

/*************************************************/

function errorMsg($title$msg) {
    
?>
    <html>
    <head>
    <title>JFWCMS - <?php echo($title); ?></title>
    <?php
    
include('includes/header.html');
    
?>
    <br>
    <table width="95%" cellspacing="0" cellpadding="1" border="0" align="center">
    <tr>
        <td bgcolor="<?php echo($headcolor); ?>"><font size="2" color="<?php echo($headtextcolor); ?>"><b>&nbsp;<?php echo($title); ?></b></font></td>
    </tr>
    <tr>
        <td bgcolor="<?php echo($row1back); ?>"><font size="2"><?php echo($msg); ?></font></td>
    </tr>
    </table>
    <?php
    
include('includes/footer.html');
    exit;
}

function 
Msg($title$msg) {
    
?>
    <html>
    <head>
    <title>JFWCMS - <?php echo($title); ?></title>
    <?php
    
include('includes/header.html');
    
?>
    <br>
    <table width="95%" cellspacing="0" cellpadding="1" border="0" align="center">
    <tr>
        <td bgcolor="<?php echo($headcolor); ?>"><font size="2" color="<?php echo($headtextcolor); ?>"><b>&nbsp;<?php echo($title); ?></b></font></td>
    </tr>
    <tr>
        <td bgcolor="<?php echo($row1back); ?>"><font size="2"><?php echo($msg); ?></font></td>
    </tr>
    </table>
    <?php
    
include('includes/footer.html');
    exit;
}

function 
showLoginForm() {
    
?>
    <html>
    <head>
    <title>JFWCMS - Login Required</title>
    <?php
    
include('includes/header.html');
    
?>
    <br><br>
    <table width="95%" cellspacing="0" cellpadding="2" border="0" align="center">
    <tr>
        <td bgcolor="<?php echo($headcolor); ?>"><font size="2" color="<?php echo($headtextcolor); ?>"><b>&nbsp;System Message</b></font></td>
    </tr>
    <tr>
        <td bgcolor="<?php echo($row1back); ?>"><font size="2">You are not logged in or you do not have permission to access this page. This could be for one of the following reasons:</font></p>
         <ol>
         <font size="2"><li>You are not logged in. Use the form at the bottom of this page to login with your username and password.</li></font>
         <font size="2"><li>You do not have permission to access this page. Perhaps you are trying to access the content management system of this website? If you believe you should have access to this page, please contact <a href="mailto:members@justforwebmasters.com">member services</a>.</li></font>
         </ol></td>
    </tr>
    <form action="<?php echo($PHP_SELF); ?>" method="post">
    <tr>
        <td bgcolor="<?php echo($row2back); ?>">
         <table width="100%" cellspacing="0" cellpadding="0" border="0">
         <tr>
             <td width="33%" align="center"><font size="2"><b>Your Username:&nbsp;</b></font></td>
             <td width="33%" align="center"><input type="text" name="uid" size="16"></td>
             <td width="33%" align="center" nowrap><font size="1">&nbsp;<a href="/users/register.php"><b>How to Register</b></a></font></td>
         </tr>
         </table></td>
    </tr>
    <tr>
        <td bgcolor="<?php echo($row1back); ?>">
         <table width="100%" cellspacing="0" cellpadding="0" border="0">
         <tr>
             <td width="33%" align="center"><font size="2"><b>Your Password:&nbsp;</b></font></td>
             <td width="33%" align="center"><input type="password" name="pwd" size="16"></td>
             <td width="33%" align="center" nowrap><font size="1">&nbsp;<a href="/users/password.php"><b>Password Retrieval</b></a></font></td>
         </tr>
         </table></td>
    </tr>
    <tr>
        <td bgcolor="<?php echo($row2back); ?>">
         <table width="100%" cellspacing="0" cellpadding="0" border="0">
         <tr>
             <td align="center" colspan="3" align="right"><input type="submit" name="submitok" value="  Log In  "></td>
         </tr>
         </table></td>
    </tr>
    </form>
    </table>
    <?php
    
include('includes/footer.html');
    
?>
    </html>
    <?php
}
?>
Any ideas as to what could be causing this?

Thanks,
-Corbb
__________________
Sincerely,
Corbb O'Connor, Author at DevArticles

Reply With Quote
  #2  
Old July 27th, 2002, 09:22 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
easy

change this line

function errorMsg($title, $msg) {

to this

function anothername($title, $msg) {

i think the name of your function is causing you problems

Reply With Quote
  #3  
Old July 27th, 2002, 11:04 PM
WebGuy WebGuy is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 54 WebGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Hi Ben,

I found the error.

You see, when a page is called, a file called accesscontrol.php is included to check if the username and password of the user are correct. This file includes common.php. However, I also included common.php in the file after including accesscontrol.php.

So, to anybody who has this problem, change require(...); or include(...); to require_once(...); or include_once(...);.

Thanks for the help though, Ben!

-Corbb

Reply With Quote
  #4  
Old July 28th, 2002, 12:43 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
ahh ok, thats cool

i thought it might of been something like that, cos it was coming up with that error

Reply With Quote
  #5  
Old December 2nd, 2011, 12:39 PM
h8usernames h8usernames is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Posts: 1 h8usernames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 19 sec
Reputation Power: 0
9-years on and still helping

I doubt you guys are still around but thanks for the tip.

I have the same problem now... the thing is I can't find the other instance where the file with the function in it was included so the include_once function saved my backside.

I will find it eventually but thanks again!

Reply With Quote
  #6  
Old November 19th, 2012, 01:22 AM
lugocottewd lugocottewd is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 6 lugocottewd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 31 sec
Reputation Power: 0
I know exactly how you can update multiple columns in a row.





Reply With Quote
  #7  
Old November 19th, 2012, 06:44 PM
Rhon3da Rhon3da is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 3 Rhon3da User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 8 sec
Reputation Power: 0
I will find it eventually but thanks again!URLURLURLURL
URL

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Cannot redeclare function


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap