Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-09-2012, 03:28 PM
!Alive !Alive is offline
Member
 
Join Date: Feb 2012
Posts: 39
Gender: Male
Credits: 1,438
!Alive is on a distinguished road
Default Having a problem running a query

So what I'm trying to accomplish is every time the page changes/reloaded check to see if the user has won a random, mystery prize. Right now I have got the random prize page working and I already have the piece of code that randomly decides if the user wins something.
My problem is that it doesn't run my query to update the info in the table. I think my problem may be where I have put the code, which I currently have located in the functions.php.

Any help would be greatly appreciated.
Thank you much in advance.
Reply With Quote
  #2  
Old 03-10-2012, 12:39 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 97,321
SilverDragonTears is on a distinguished road
Default

We probably need to see the code snippet...
__________________

Check out SilvaTales
Reply With Quote
  #3  
Old 03-10-2012, 12:16 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 490,826
Hall of Famer is on a distinguished road
Default

umm the mysql update query wont work? Well I've had problems like this at times but theres really an easy way to debug. The mysql query string may have a typo in it, or the variables used to locate or update the database contain wrong information. To debug, lets consider the example below:

PHP Code:
runquery("UPDATE {$prefix}adoptables_conditions SET promocode='{$code}' WHERE type='{$type}'"); 
The query string is enclosed in the function runquery. The variable $code is used to update database info, while the other variable $type is used to locate the specific row in a table. You can debug by outputting values inside the variables $code and $type to the screen and see if they contain the correct information. If so, you've apparently made a typo with the query string. Otherwise, chances are you've incorrectly assigned values to $code or $type.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #4  
Old 03-10-2012, 01:30 PM
!Alive !Alive is offline
Member
 
Join Date: Feb 2012
Posts: 39
Gender: Male
Credits: 1,438
!Alive is on a distinguished road
Default

PHP Code:
$number=rand(1,2);
    if (
$number == 2){
    
runquery("UPDATE ".$GLOBALS['prefix']."users SET explore='1' WHERE username".$GLOBALS['loggedinname']);
    
    
$query "SELECT * FROM ".$GLOBALS['prefix']."users WHERE username".$GLOBALS['loggedinname'];
    
$result mysql_query($query);
    
$explore=@mysql_result($result,0,"explore");
    echo 
"$explore";

    return 
$explore;
    if (
$explore == 1){
    
header'Location: browseprize.php' ) ;
        }
        } 
That's my code I'm running. I don't think I have any sytax errors, but I'm still new to this so I could be wrong.
Reply With Quote
  #5  
Old 03-10-2012, 10:49 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 490,826
Hall of Famer is on a distinguished road
Default

umm your query is wrong, try this:

PHP Code:
runquery("UPDATE {$GLOBALS['prefix']}users SET explore='1' WHERE username = '{$loggedinname}'"); 
$query "SELECT * FROM {$GLOBALS['prefix']}users WHERE username = '{$loggedinname}'"
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #6  
Old 03-11-2012, 03:54 AM
!Alive !Alive is offline
Member
 
Join Date: Feb 2012
Posts: 39
Gender: Male
Credits: 1,438
!Alive is on a distinguished road
Default

That works perfectly. Thanks a bunch HoF. <3
Reply With Quote
  #7  
Old 03-11-2012, 10:16 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 490,826
Hall of Famer is on a distinguished road
Default

You are very welcome, glad it works out for you. Another quick note is that at times it does not work because you are using mysql's reserved word. I ran into this problem once, in which the field name 'usage' is a reserved word and thus cannot be used. Because of this I could not manage to create the table prefix.items_functions. I changed it to 'intent' instead and the problem is all gone.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #8  
Old 03-11-2012, 10:31 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 37,838
fadillzzz is an unknown quantity at this point
Default

Quote:
Originally Posted by Hall of Famer View Post
You are very welcome, glad it works out for you. Another quick note is that at times it does not work because you are using mysql's reserved word. I ran into this problem once, in which the field name 'usage' is a reserved word and thus cannot be used. Because of this I could not manage to create the table prefix.items_functions. I changed it to 'intent' instead and the problem is all gone.
This might be slightly out of topic, but it's also worth noting that you can still use a reserved keyword if you enclose it with backticks.
Reply With Quote
  #9  
Old 03-11-2012, 03:39 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 490,826
Hall of Famer is on a distinguished road
Default

@ Fadillzzz: Yeah you are right, I actually tried that before but it still gave me an error. Turned out that I was using single quote instead of backticks, oh my...
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply


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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Query: COUNT(*) Kyttias Questions and Supports 5 01-19-2015 04:57 AM
CSS Query .-. ChibiMaestro Templates and Themes 2 12-08-2012 06:51 AM
Errors Running Mysidia Inf3rnal Questions and Supports 10 03-04-2011 08:31 AM
Join query for optimization? Arianna Questions and Supports 2 04-09-2010 01:32 PM
Problems getting the script running.... milay Questions and Supports 7 03-08-2009 08:21 AM


All times are GMT -5. The time now is 02:53 PM.

Currently Active Users: 703 (0 members and 703 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636