473,795 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot redeclare foo() error

5 New Member
Hello, I got message:
Fatal error: Cannot redeclare sqlconnect() (previously declared in E:\Program Files\Apache Group\Apache2\h tdocs\openemr-2.9.0\library\s ql.inc:33) in E:\program files\apache group\Apache2\h tdocs\openemr-2.9.0\library\s ql.inc on line 36


File sql.inc:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. ...
  3. function sqlConnect($login,$pass,$dbase,$host,$port = '3306')
  4. {
  5.   return $GLOBALS['dbh'] = $database->_connectionID;
  6. }
  7. ...
  8. ?>
All programs use statement
include_once("$ srcdir/sql.inc");
to call function.

Help will be very much appreciated.
Oct 17 '08 #1
6 2891
Markus
6,050 Recognized Expert Expert
You're declaring the function twice; you can't do that.
Oct 17 '08 #2
willlen
5 New Member
Thank you Marcus for reply.
But I declared function only once.
I did search for "function sqlConnect" and got only one file: sql.inc.
No other declaration for this function.
Willlen
Oct 17 '08 #3
Markus
6,050 Recognized Expert Expert
I'm no psychic, so post the rest of the code from sql.inc

You shouldn't use the .inc extension in case your server doesn't understand it and prints it as text.
Oct 17 '08 #4
willlen
5 New Member
Programs are big. I post part of the code:
sql.inc
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include_once(dirname(__FILE__) . "/sqlconf.php");
  3. require_once(dirname(__FILE__) . "/adodb/adodb.inc.php");
  4.  
  5. if (!defined('ADODB_FETCH_ASSOC')) define('ADODB_FETCH_ASSOC', 2);
  6. $database = NewADOConnection("mysql");
  7. $database->PConnect($host, $login, $pass, $dbase);
  8. $GLOBALS['adodb']['db'] = $database;
  9. $GLOBALS['dbh'] = $database->_connectionID;
  10.  
  11. //fmg: This makes the login screen informative when no connection can be made
  12. if (!$GLOBALS['dbh']) {
  13.   //try to be more helpful
  14.   if ($host == "localhost") {
  15.     echo "Check that mysqld is running.<p>";
  16.   } else {
  17.     echo "Check that you can ping the server '$host'.<p>";
  18.   }//if local
  19.   HelpfulDie("Could not connect to server!", mysql_error($GLOBALS['dbh']));
  20.   exit;
  21. }//if no connection
  22.  
  23. function sqlConnect($login,$pass,$dbase,$host,$port = '3306')
  24. {
  25.   return $GLOBALS['dbh'] = $database->_connectionID;
  26. }
  27.  
  28. function sqlStatement($statement)
  29. {
  30.   //----------run a mysql query, return the handle
  31.   $query = mysql_query($statement, $GLOBALS['dbh']) or 
  32.     HelpfulDie("query failed: $statement", mysql_error($GLOBALS['dbh']));
  33.   return $query;
  34. }
  35.  
  36. function idSqlStatement($statement)
  37. {
  38.   return sqlInsert($statement);
  39. }
  40.  
  41. function sqlClose()
  42. {
  43.   //----------Close our mysql connection
  44.   $closed = mysql_close($GLOBALS['dbh']) or
  45.     HelpfulDie("could not disconnect from mysql server link", mysql_error($GLOBALS['dbh']));
  46.   return $closed;
  47. }
  48.  
  49. function sqlInsert($statement)
  50. {
  51.   //----------run a mysql insert, return the last id generated
  52.   mysql_query($statement, $GLOBALS['dbh']) or 
  53.     HelpfulDie("insert failed: $statement", mysql_error($GLOBALS['dbh']));
  54.   return mysql_insert_id($GLOBALS['dbh']);
  55. }
  56.  
  57. function sqlInsertClean($statement)
  58. {
  59.   return sqlInsert($statement);
  60. }
  61.  
  62. Further are many other functions like above...
  63.  
  64. ?>
  65.  
  66. Incuding program is login.php:
  67. <?php
  68.  
  69. $ignoreAuth=true;
  70. include_once("../globals.php");
  71. include_once("$srcdir/md5.js");
  72. include_once("$srcdir/sql.inc");
  73. ?>
  74.  
  75. <html>
  76. <head>
  77. <?php html_header_show(); ?>
  78. <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
  79.  
  80. <script language='JavaScript'>
  81.  
  82. function imsubmitted() {
  83. <?php if (!empty($GLOBALS['restore_sessions'])) { ?>
  84.  // Delete the session cookie by setting its expiration date in the past.
  85.  // This forces the server to create a new session ID.
  86.  var olddate = new Date();
  87.  olddate.setFullYear(olddate.getFullYear() - 1);
  88.  document.cookie = '<?php echo session_name() . '=' . session_id() ?>; path=/; expires=' + olddate.toGMTString();
  89. <?php  }  ?>
  90.  return true;
  91. }
  92.  
  93. </script>
  94.  
  95. </head>
  96. <body <?php echo $login_body_line;?> onload="javascript:document.login_form.authUser.focus();" >
  97.  
  98. <span class="text"></span>
  99.  
  100. <center>
  101.  
  102. <form method="POST" action="../main/main_screen.php?auth=login" target="_top"
  103.  name="login_form" onsubmit="return imsubmitted();">
  104.  
  105. <?php
  106. $res = sqlStatement("select distinct name from groups");
  107. for ($iter = 0;$row = sqlFetchArray($res);$iter++)
  108.     $result[$iter] = $row;
  109. if (count($result) == 1) {
  110.     $resvalue = $result[0]{"name"};
  111.     echo "<input type='hidden' name='authProvider' value='$resvalue' />\n";
  112. }
  113. ?>
Further is going a code for entering and transfer login and password ...
Oct 17 '08 #5
teek5449
9 New Member
It may sound silly but when you search for another instance of your method is case sensitive turned on? Or try a less exclusive search such as "sqlconnect " (note the all lower) while you will get more results than you think that you want you may just find your problem.

Just thinking out loud since the only way you should be receiving this error is if you declare this function twice. Since PHP is a non case sensitive language another function that is capitalized differently may be causing this issue.
Oct 18 '08 #6
Atli
5,058 Recognized Expert Expert
Hi.

On line 72 of your "sql.inc" file you include a file called "sql.inc"
Is this the same file?

If so, then this would cause the error you are seeing.
Oct 18 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
5483
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
11
41094
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put debug_print_backtrace in the file to see how it is included, and here's the output: #0 require_once() called at #1 require_once(\eKirje.textGrid.class.php) called at #0 require_once() called at #1 require_once(\eKirje.kanava.class.php)...
2
15768
by: Christophe | last post by:
class A {} class B {} interface MyInterface { void method(A a); void method(B b); }
2
8101
by: Midgard | last post by:
I have this error: Fatal error: Cannot redeclare send_welcome_mail() (previously declared in /home/oxxowhol/public_html/config.php:21) in /home/oxxowhol/public_html/config.php on line 21 Why?
3
3053
by: Ciegalo | last post by:
Hi to all, I'm getting my hands into PEAR for a small newsletter-sending project. I need to boost the performance of the sending script and came accross this mail_queue class that should queue the emails. After sweating over the pear installation on myWindows Machine (IIS, PHP 4.4.6, MySQL), I cannot even run the tutorial script.. I get : Fatal error: Cannot redeclare class mail_queue_container:mail_queue_container_db in...
4
3108
by: mrityunjay11 | last post by:
my ccode goes as such this is php_dbi.php <? function dbi_connect ( $host, $login, $password, $database ) { if ( strcmp ( $GLOBALS, "mysql" ) == 0 ) { $c = mysql_pconnect ( "192.168.100.3", $login, $password ); if ( $c ) { if ( ! mysql_select_db ( $database ) )
1
1872
by: srilathaapi | last post by:
Hi All, I am getting the error cannot redeclare the class some xxx in file xxx.php. bcz i m including xxx.php in 3 diffrent functions in the same file to invoke the 3 differnet functions in the xxx.php from 3 different functions.so can u give me the solution. Thanks&regards Sri
2
14327
by: srilathaapi | last post by:
Hi All, I am getting the error cannot redeclare the class some xxx in file xxx.php. bcz i m including xxx.php in 3 diffrent functions in the same file to invoke the 3 differnet functions in the xxx.php from 3 different functions.so can u give me the solution. Thanks&regards Sri
5
3674
by: Just Another Victim of the Ambient Morality | last post by:
I have a peculiar bug in my PHP code. It looks something like this: Fatal error: Cannot redeclare func_name() (previously declared in script.php:57) in script.php on line 57 I've done a search and determined that "func_name" really is unique. Besides, how is this even possible? It was previously declared on the same line it's declared? Any help is appreciated. Thank you!
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.