Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-28-2011, 07:13 PM   #1
Mamassita
Confirmed User
 
Join Date: Nov 2009
Posts: 252
PHP Help Needed :)

Building a paid module for a custom tube script, but i'm getting this error


Notice: Undefined variable: paid in /home/nakedmov/public_html/xxx/video.php on line 179

Notice: Undefined variable: paid in /home/nakedmov/public_html/xxx/video.php on line 213


Line 179 to 187
PHP Code:
if($paid == false){
    if(isset(
$users_credits)){
        if(
$credits $users_credits){
            
$errors[] = 'Not enough credits for this action. Visit credits page from your profile to charge up your account!';
        }        
    } else {
        
$errors[] = 'You need to login before you can watch this video';
    }    

Line 213
PHP Code:
$smarty->assign('paid',$paid); 
Anyone know what i've done wrong ?

Thanks
Mamassita is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 07:21 PM   #2
FlexxAeon
Confirmed User
 
FlexxAeon's Avatar
 
Industry Role:
Join Date: May 2003
Posts: 3,765
dont think you use == for a boolean

try:

if($paid = false)
__________________
flexx [dot] aeon [at] gmail
FlexxAeon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 07:23 PM   #3
Mamassita
Confirmed User
 
Join Date: Nov 2009
Posts: 252
Quote:
Originally Posted by FlexxAeon View Post
dont think you use == for a boolean

try:

if($paid = false)
Work like a charm

Thanks a lot
Mamassita is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 07:32 PM   #4
Aric
Confirmed User
 
Aric's Avatar
 
Industry Role:
Join Date: Sep 2002
Posts: 1,209
Quote:
Originally Posted by FlexxAeon View Post
dont think you use == for a boolean

try:

if($paid = false)
I'm no expert, but that is wrong? You just assigned a value to $paid, which of course got rid of his PHP notices.

The PHP notices are displayed because $paid has no value set before the conditional.
__________________
Awesome cloud hosting by DigitalOcean
Aric is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 07:35 PM   #5
VladS
Available for Coding Work
 
VladS's Avatar
 
Industry Role:
Join Date: Jun 2008
Posts: 1,435
PHP Code:
if(!$paid
__________________
<developer> MechBunny / KVS / PHP / MySQL / HTML5 / CSS3 / jQuery
Email: vlad [at] dangerouscoding.com
Telegram: @dangerouscoding
VladS is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 07:38 PM   #6
marlboroack
So Fucking Banned
 
Industry Role:
Join Date: Jul 2010
Location: ☣
Posts: 9,327
PHP Code:
my cock is huge 
marlboroack is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 07:39 PM   #7
FlexxAeon
Confirmed User
 
FlexxAeon's Avatar
 
Industry Role:
Join Date: May 2003
Posts: 3,765
Quote:
Originally Posted by Aric View Post
I'm no expert, but that is wrong? You just assigned a value to $paid, which of course got rid of his PHP notices.

The PHP notices are displayed because $paid has no value set before the conditional.
if it's under an if condition it's not setting a value
__________________
flexx [dot] aeon [at] gmail
FlexxAeon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 07:40 PM   #8
Mamassita
Confirmed User
 
Join Date: Nov 2009
Posts: 252
Quote:
Originally Posted by Aric View Post
I'm no expert, but that is wrong? You just assigned a value to $paid, which of course got rid of his PHP notices.

The PHP notices are displayed because $paid has no value set before the conditional.
yeah seem there's no notices anymore
Mamassita is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:03 PM   #9
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,516
Quote:
Originally Posted by Mamassita View Post
Work like a charm

Thanks a lot
No it didn't.

Run these two scripts :

<?php

$paid = false;
if($paid = false) {
echo "This really works!";

}
else {
echo "No No No No!";
}

?>


-------------

<?php

$paid = false;
if($paid == false) {
echo "This really works!";

}
else {
echo "No No No No!";
}

?>
__________________
Make Money with Porn
blackmonsters is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:04 PM   #10
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,516
Quote:
Originally Posted by flexxaeon View Post
if it's under an if condition it's not setting a value
stfu!

....
__________________
Make Money with Porn
blackmonsters is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:09 PM   #11
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
Quote:
Originally Posted by Aric View Post
I'm no expert, but that is wrong? You just assigned a value to $paid, which of course got rid of his PHP notices.

The PHP notices are displayed because $paid has no value set before the conditional.
Yep, $paid = false sets $paid to false.
The warning goes away because it's perfectly legal code, but it's also perfectly useless - it will always be true. To confirm, try this:

$paid = 1;
if ($paid = false) {
echo "oops, wrong answer";
}
__________________
For historical display only. This information is not current:
support&#64;bettercgi.com ICQ 7208627
Strongbox - The next generation in site security
Throttlebox - The next generation in bandwidth control
Clonebox - Backup and disaster recovery on steroids
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:19 PM   #12
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,516
Quote:
Originally Posted by raymor View Post
Yep, $paid = false sets $paid to false.
The warning goes away because it's perfectly legal code, but it's also perfectly useless - it will always be true. To confirm, try this:

$paid = 1;
if ($paid = false) {
echo "oops, wrong answer";
}
Exactly :

<?php

//$paid is not defined yet

if($paid = false) {
echo "paid is false";
}
//$paid was set to false above

if($paid == false) {
echo "That's really FUCKED UP!!!!!!!!!!!!!!!!!!!!!!!!!!!";
}

?>
__________________
Make Money with Porn
blackmonsters is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:24 PM   #13
VladS
Available for Coding Work
 
VladS's Avatar
 
Industry Role:
Join Date: Jun 2008
Posts: 1,435
Quote:
Originally Posted by Gsx-R View Post
PHP Code:
if(!$paid
You can also do this.

PHP Code:
if(!isset($paid)) 
__________________
<developer> MechBunny / KVS / PHP / MySQL / HTML5 / CSS3 / jQuery
Email: vlad [at] dangerouscoding.com
Telegram: @dangerouscoding
VladS is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:28 PM   #14
FlexxAeon
Confirmed User
 
FlexxAeon's Avatar
 
Industry Role:
Join Date: May 2003
Posts: 3,765
haha holy shit. i apologize, i was wrong. rookie mistake. doing 3 other things. but...

Quote:
Originally Posted by blackmonsters View Post
stfu!

....
from the dude that still uses tables??? gtfoh
__________________
flexx [dot] aeon [at] gmail
FlexxAeon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:31 PM   #15
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,516
Quote:
Originally Posted by FlexxAeon View Post
haha holy shit. i apologize, i was wrong. rookie mistake. doing 3 other things. but...



from the dude that still uses tables??? gtfoh


I use tables because I know what the fuck I'm doing.

__________________
Make Money with Porn
blackmonsters is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:35 PM   #16
Zoxxa
Confirmed User
 
Zoxxa's Avatar
 
Industry Role:
Join Date: Feb 2011
Location: Ontario, Canada
Posts: 1,026
Your original code should work fine. The problem seems to be getting the boolean value assigned to the variable in the first place. Your error message states "Undefined variable", meaning it probably has no value. Have you echo'd out the value of $paid before the if statement to see if it has any value or is NULL?
__________________
[email protected]
ICQ: 269486444
ZoxEmbedTube - Build unlimited "fake" tubes with this easy 100% unencoded CMS!

Last edited by Zoxxa; 10-28-2011 at 08:39 PM..
Zoxxa is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 08:47 PM   #17
FlexxAeon
Confirmed User
 
FlexxAeon's Avatar
 
Industry Role:
Join Date: May 2003
Posts: 3,765
Quote:
Originally Posted by blackmonsters View Post


I use tables because I know what the fuck I'm doing.

__________________
flexx [dot] aeon [at] gmail
FlexxAeon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 09:11 PM   #18
Kiopa_Matt
Confirmed User
 
Industry Role:
Join Date: Oct 2007
Posts: 1,448
Quote:
Originally Posted by FlexxAeon View Post
if it's under an if condition it's not setting a value
Yes, it does. Test it and see. PHP executes what's inside the brackets first, and since it successfully assigned $paid as false, the conditional passes.
__________________
xMarkPro -- Ultimate Blog Network Management
Streamline your marketing operations. Centralize management of domains, pages, Wordpress blogs, sponsors, link codes, media items, sales and traffic statistics, plus more!
Kiopa_Matt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 10:15 PM   #19
Carmen80
Confirmed User
 
Carmen80's Avatar
 
Industry Role:
Join Date: Sep 2010
Location: Europe
Posts: 207
Quote:
Originally Posted by Gsx-R View Post
You can also do this.

PHP Code:
if(!isset($paid)) 
That is plain wrong. You're checking if the variable exists, not if the value is true or false.

--

The real solution:

PHP Code:
if(!isset($paid) || !$paid){
    if(isset(
$users_credits)){
        if(
$credits $users_credits){
            
$errors[] = 'Not enough credits for this action. Visit credits page from your profile to charge up your account!';
        }        
    } else {
        
$errors[] = 'You need to login before you can watch this video';
    }    

You should really considering lowering your error reporting level. This should be done at the top of the script, and the script can look like this. Less messy and actually faster.
PHP Code:
error_reporting(E_ALL E_NOTICE); // put this on top of the script, preferably inside your top configuration include file

if(!$paid){
    if(isset(
$users_credits)){
        if(
$credits $users_credits){
            
$errors[] = 'Not enough credits for this action. Visit credits page from your profile to charge up your account!';
        }        
    } else {
        
$errors[] = 'You need to login before you can watch this video';
    }    

__________________
It's all just a strange dream..

Last edited by Carmen80; 10-28-2011 at 10:19 PM..
Carmen80 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 11:26 PM   #20
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Oh good lord.... lol.. The "proper" way.

Code:
if( !isset($page) || $page !== true ){
That assumes that $page will contain a proper php boolean type.. And yes, the extra = is not a typo because it doesn't just check the value but also the "type". However, if it's a 0/1 then it should just be

Code:
if( !isset($page) || $page != 1 ){
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-28-2011, 11:49 PM   #21
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Oh shit this is hilarious. Don't take code advice from GFY anymore!
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-29-2011, 12:06 AM   #22
loopardo
Registered User
 
Industry Role:
Join Date: Aug 2008
Location: around...
Posts: 81
that was intense...
__________________
___
loopardo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-29-2011, 03:35 AM   #23
mikke
Confirmed User
 
mikke's Avatar
 
Industry Role:
Join Date: Jan 2010
Location: Europe
Posts: 1,327
Code:
if(empty($paid)){
    if(isset($users_credits)){
        if($credits > $users_credits){
            $errors[] = 'Not enough credits for this action. Visit credits page from your profile to charge up your account!';
        }        
    } else {
        $errors[] = 'You need to login before you can watch this video';
    }    
}
also..

Code:
$smarty->assign('paid', !empty($paid)?$paid:false);
__________________
icq: 395 294 346
http://www.adultsubmitter.eu - submit any adult site to 20 directories from 1 form!
now 20 domains!
http://www.porndeals.eu http://www.ebonybangbros.com
mikke is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-29-2011, 04:23 AM   #24
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
thats a lot of wrong adivce, next time ask you quetsion at www.stackoverflow.com
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-29-2011, 04:31 AM   #25
Emil
Confirmed User
 
Emil's Avatar
 
Join Date: Feb 2007
Location: Sweden
Posts: 5,650
Quote:
Originally Posted by marlboroack View Post
PHP Code:
my cock is huge 
Doesn't seem to work.
__________________
Free 🅑🅘🅣🅒🅞🅘🅝🅢 Every Hour (Yes, really. Free ₿itCoins.)
(Signup with ONLY your Email and Password. You can also refer people and get even more.)
Emil is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-29-2011, 01:12 PM   #26
mafia_man
Confirmed User
 
mafia_man's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: icq#: 639544261
Posts: 1,965
Quote:
Originally Posted by Gsx-R View Post
You can also do this.

PHP Code:
if(!isset($paid)) 
The only guy on the thread who knows what he is talking about.
__________________
I'm out.
mafia_man is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-29-2011, 05:01 PM   #27
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
Quote:
Originally Posted by Brujah View Post
Oh shit this is hilarious. Don't take code advice from GFY anymore!

Hey it's about like us circa 1997.
__________________
For historical display only. This information is not current:
support&#64;bettercgi.com ICQ 7208627
Strongbox - The next generation in site security
Throttlebox - The next generation in bandwidth control
Clonebox - Backup and disaster recovery on steroids
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-30-2011, 11:34 PM   #28
Mamassita
Confirmed User
 
Join Date: Nov 2009
Posts: 252
Damn guys i wont buy any shit you made...

Where's konrad
Mamassita is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2011, 08:54 PM   #29
Solace
So Fucking Banned
 
Industry Role:
Join Date: Nov 2011
Posts: 995
First time I have seen code tags used here
Solace is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2011, 10:07 PM   #30
biskoppen
Confirmed User
 
Join Date: Mar 2003
Location: Very small penis
Posts: 5,809
I'm just here for the cocks
__________________
Submit my videos to make bank, tons of 5 minute videos offered right here
biskoppen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-29-2011, 10:26 PM   #31
FlexxAeon
Confirmed User
 
FlexxAeon's Avatar
 
Industry Role:
Join Date: May 2003
Posts: 3,765
noooooo my bane is back from the dead!

haha......wow. don't drink and code
__________________
flexx [dot] aeon [at] gmail

Last edited by FlexxAeon; 11-29-2011 at 10:31 PM..
FlexxAeon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.