Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Need help with $this issue
Old 10-22-2007, 10:40 PM Need help with $this issue
Novice Talker

Posts: 8
Trades: 0
I am getting the error like this:

Fatal error: Using $this when not in object context in /home/supeco/public_html/user.php on line 71

In user.php file's line#71, I see $this is used like this:
$hash = md5($this->secret.$HTTP_POST_VARS['username'])

It worked before my isp upgrade to php 5.

How should I change above $this usage so it will compatible with new php5??

Thanks.
thura is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-23-2007, 01:45 AM Re: Need help with $this issue
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Can you provide more code?

From the looks of it I think you are making a call to $this outside of the scope of an object.

Btw is this for a facebook app? Just wondering because the code looks familiar.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-23-2007, 10:17 PM Re: Need help with $this issue
Novice Talker

Posts: 8
Trades: 0
This is a part of php portal script from old days.

I did visit this thread (URL: http://www.webmaster-talk.com/php-fo...ot-object.html) too but still no idea how to fix mine

Here are a few lines.

$page_code = "user";
$page_name = LANG_USERDETAILS;
// Header file
include_once("$lib/themelib.php");
// Did the user filled the registration form?
if ((!$HTTP_POST_VARS['username']) || (!$HTTP_POST_VARS['password'])) {
// If not, go to registration form
header("Location: $root_url/register.php");
exit;
}
echo siteTheme ("header");
// If YES, start registration actions
// Hash code for confirmation mail
$hash = md5($this->secret.$HTTP_POST_VARS['username']);
// Connect database
dbconnect();
// Register user
$fullname = htmlspecialchars($FirstName)." ".htmlspecialchars($surname);
$sql = "INSERT INTO $t_users
(gender, name, surname, fullname, birthdate, country, address, state, city, zip, tel, job, email, list, hide_info, username,
password, hash, date, theme)
VALUES
('$gender', '".htmlspecialchars($FirstName)."', '".htmlspecialchars($surname)."', '$fullname', '$birthdate', '".htmlspecialchars($country)."', '".htmlspecialchars($address)."','".htmlspecialcha rs($state)."','".htmlspecialchars($city)."','".htm lspecialchars($zip)."','".htmlspecialchars($tel)." ', '".htmlspecialchars($job)."', '".htmlspecialchars($email)."', '$list','$hide_info',
'" . $HTTP_POST_VARS['username'] . "', '" . md5($HTTP_POST_VARS['password'])."', '$hash', now(), '$def_theme') ";
$result = @mysql_query($sql) or die ("Can not register user");

Thank you.

Last edited by thura; 10-24-2007 at 11:17 PM..
thura is offline
Reply With Quote
View Public Profile
 
Old 10-24-2007, 03:32 AM Re: Need help with $this issue
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I can't tell from the code if you are using $this within an object. If you are not then $this doesn't have any meaning. The object model has been overhauled since PHP4 but generally most code is backwards compatible.

Again. Like the error says, make sure that you are not using $this outside of an object. If you give me more code I can help you out. Good luck
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-24-2007, 11:12 PM Re: Need help with $this issue
Novice Talker

Posts: 8
Trades: 0
Per this forum rule, I can only send pm after the total 5 posts. I don't want to paste entire page here in the forum. I really like to know how to alter the $this usage like some people explain in this topic (URL: http://www.webmaster-talk.com/php-fo...ot-object.html). I really don't know about programming. I only see the $this once in the script like I posted above. Only that line uses it.

Thank you.

Last edited by thura; 10-24-2007 at 11:18 PM..
thura is offline
Reply With Quote
View Public Profile
 
Old 10-30-2007, 11:02 PM Re: Need help with $this issue
Novice Talker

Posts: 8
Trades: 0
Can you send me message so I may be can reply it back to you with the script. This is very inconvenient. I can't still send message to anyone. I don't know if I need to do the pay membership. No way to contact the webmaster too. Can someone read my message above and help me, please?
thura is offline
Reply With Quote
View Public Profile
 
Old 11-08-2007, 12:19 AM Re: Need help with $this issue
Novice Talker

Posts: 8
Trades: 0
I've just sent the pm. Thanks.
thura is offline
Reply With Quote
View Public Profile
 
Old 11-08-2007, 08:12 AM Re: Need help with $this issue
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
NOTE:
$HTTP_POST_VARS is old use $_POST instead.

Also try concatanating the two vars '$md5 = $this->secret.$_POST['username']'
$hash = md5($md5)

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 11-09-2007, 02:05 AM Re: Need help with $this issue
Novice Talker

Posts: 8
Trades: 0
I modified the script as you advised but still giving me the same errors.
thura is offline
Reply With Quote
View Public Profile
 
Old 11-12-2007, 11:21 AM Re: Need help with $this issue
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Does $this->secret hold any info. Try echo it out and see. Try same with $HTTP_POST_VARS['username'];

Also try adding error_reporting (E^ALL); at the top of your script.

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 11-12-2007, 10:46 PM Re: Need help with $this issue
Novice Talker

Posts: 8
Trades: 0
Thank you for your help.

I followed your advice, I echo out $this->secret and just used $HTTP_POST_VARS['username'];

The script is now almost working for registration but when user log back in to the site, the new error is displayed as:

Warning: Cannot modify header information - headers already sent by (output started at /home/supeco/public_html/library/themelib.php:565) in /home/supeco/public_html/user.php on line 13

Is it http issue? Can you help me fix it, please?

Thank you.
thura is offline
Reply With Quote
View Public Profile
 
Old 11-13-2007, 03:38 PM Re: Need help with $this issue
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Make sure you're not generating any output before you use the header function. If you echo or print anything you won't be able to forward to a new location. Most likely you've just left your echo $this->secret in your code, if you remove it that should fix your problem.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-21-2008, 10:01 PM Re: Need help with $this issue
carloncho's Avatar
Skilled Talker

Posts: 80
Name: Carlos
Trades: 0
Maybe you out from an Object. $this refer to an object. If you out of an object or you dont sure, make:
print_r($this);
And watch what is $this
__________________
-----------------------

Please login or register to view this content. Registration is FREE
carloncho is offline
Reply With Quote
View Public Profile Visit carloncho's homepage!
 
Reply     « Reply to Need help with $this issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.84725 seconds with 12 queries