» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-15-2006, 01:17 PM
gathy gathy is offline
Junior Member
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
gathy is on a distinguished road
Exclamation unable to create class

Hi guys,

I'v got a bit of a problem, from what I can see everything is ok. But when I try and create an instance of a class it doesn't do anything.

The below code is ment to check all details and then process it i.e. store the user in the db. but it fails at $reg = new register($username, $password);

The code:

PHP Code:
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$confirmPassword = $_POST['confirmPassword'];

// CHECK IF ALL DETAILS HAVE BEEN PROVIDED
if (!$username) {
errorMessage('Missing username', 'Please enter a username.');
include('templates/registration_form.php');
}
else if (!$password) {
errorMessage('Missing password', 'Please enter a password.');
include('templates/registration_form.php');
}
e -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-15-2006, 01:23 PM
zenith zenith is offline
OSP Starters
 
Join Date: Apr 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
zenith is on a distinguished road
Default

One reason I can see is that your class name and function name is same i.e register.. try to change the function name and then work over it,

and btw if you are using register function as constructor then you are doing wrong, in php you define constructor as __contruct()

OR first create the object and then call the register function like


PHP Code:
$reg->register($username,$password);

Hope that helps -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  #3  
Old 08-15-2006, 01:26 PM
nicolas nicolas is offline
OSP Starters
 
Join Date: Apr 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
nicolas is on a distinguished road
Default

Quote:
Originally Posted by zenith
One reason I can see is that your class name and function name is same i.e register.. try to change the function name and then work over it,

and btw if you are using register function as constructor then you are doing wrong, in php you define constructor as __contruct()

OR first create the object and then call the register function like


PHP Code:
$reg->register($username,$password);


Using the class name is still backwards compatible in PHP5 and is the only way to make it work in PHP4 too. Nothing wrong with tha -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use CREATE PROCEDURE? silvair MySQL Forums 1 09-06-2006 07:44 AM
unable to add or update rows; Chariti MySQL Forums 1 08-14-2006 05:32 AM
create the Custom Datatype in MySQL dominic MySQL Forums 1 08-08-2006 01:10 PM
decreasing class based on value ghosty PHP Programming and Tips 1 07-30-2006 11:33 AM
getting private class variables from outside the class maxima PHP Programming and Tips 3 07-29-2006 01:29 PM


All times are GMT. The time now is 05:28 AM.