TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-15-2007, 08:57 PM   #1 (permalink)
The Acquainted
 
obolus's Avatar
 
Join Date: Oct 2007
Location: florida
Posts: 110
Thanks: 36
obolus is on a distinguished road
Default Runtime Error

I was working on an OOP user tutorial and I've fixed everything so far except this:

Quote:
Runtime Notice on line 19,
Redefining already defined constructor for class mysql, in /xxx/xxx/xxx/classes/mysql.php
I'm thinking it's due to a class in my user.php class file that extends the SQL class defined in mysql.php, that also contains a __construct method.

First part of User class from user.php:

PHP Code:
class User extends mysql {
    
    var 
$mysql;

    function 
__construct( )     
    {
        
$this->mysql = new mysql();
        
        foreach(
$_POST as $key => $val
            {
                
$_POST[$key] = stripslashes(strip_tags(htmlspecialchars($valENT_QUOTES)));
                $
$key stripslashes(strip_tags(htmlspecialchars($valENT_QUOTES)));
            }
        
        
        foreach(
$_GET as $key => $val
            {
                
$_GET[$key] = stripslashes(strip_tags(htmlspecialchars($valENT_QUOTES)));
                $
$key stripslashes(strip_tags(htmlspecialchars($valENT_QUOTES)));
            }
        
        foreach(
$_SESSION as $key => $val)
            {
                
$_SESSION[$key] = stripslashes(strip_tags(htmlspecialchars($valENT_QUOTES)));
                $
$key stripslashes(strip_tags(htmlspecialchars($valENT_QUOTES)));
            }
        
        foreach(
$_COOKIE as $key => $val
            {
                
$_COOKIE[$key] = stripslashes(strip_tags(htmlspecialchars($valENT_QUOTES)));
                $
$key stripslashes(strip_tags(htmlspecialchars($valENT_QUOTES)));
            }
    } 

The first part of the code from the mysql class in mysql.php:

PHP Code:
class mysql {
    
    var 
$MYSQL_user DBUSER;
    var 
$MYSQL_pass DBPASS;
    var 
$MYSQL_host DBHOST;
    var 
$MYSQL_db DB;
    var 
$connect;
    var 
$get_db;

    function 
__construct() {
        
$this->Connect();
    }

    function 
mysql() {
        
$this->Connect();
    }

// Both of the functions above both call to a function called 'Connect', which is below.

    
function Connect( ) {

        
$this->connect mysql_connect($this->MYSQL_host$this->MYSQL_user$this->MYSQL_pass)or die(mysql_error( ));
        
$this->get_db mysql_select_db($this->MYSQL_db)or die(mysql_error().__LINE__.__FILE__);

    } 
Am I not even close with my assumption with regards to my guess on why this problem is occuring?

=o

thanks
obolus is offline  
Reply With Quote
Old 12-15-2007, 09:13 PM   #2 (permalink)
The Acquainted
 
Join Date: Nov 2007
Posts: 154
Thanks: 31
SOCK is on a distinguished road
Default

It's your mysql class constructor. Why are you using the traditional constructor type (the function named the same as the class) and the 'new' __construct() method? You have dual constructors.
SOCK is offline  
Reply With Quote
The Following User Says Thank You to SOCK For This Useful Post:
obolus (12-16-2007)
Old 12-15-2007, 09:40 PM   #3 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Redefining already defined [b]constructor[b] for class mysql
[b]constructor[b] __construct(or)

Like Sock said. :) What you should do, since you want to start TWO of them, is make two classes and engage BOTH with new classname; Then it engages both __constructors and then you're all free to go mind your business.

Hopefully that works. Or simply (if I am wrong), create a class with engages both classes it's functions.

$newclass = new classname;
classname { __constructor(); } started the two functions defined in the two other classes. Make sure BOTH other classes (2 and 3) do NOT contain the __construct magic function.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
The Following User Says Thank You to ReSpawN For This Useful Post:
obolus (12-16-2007)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:37 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design