News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Username variable

Started by Aeris130, July 04, 2006, 03:44:20 AM

Previous topic - Next topic

Aeris130

Yes, the problem is simply that it doesn't work. The posts get added as usual, no problems there. Its just that column "yen" (default value 0) isn't updated at all.

I've tried your query, but for some reason the entire page just goes blank when I try to add a reply. So I deleted it, and everything worked agin. I don't know if it might be related to the problem, but my forum is integrated with mambo (4.5.4).

Do I need to insert any other code in order for the query to work?

Rudolf

You know what? Use the following way to do the queries.

$result = db_query("UPDATE shop_yen SET yen=yen+1 WHERE y_user_name='{$user_info['name']}' LIMIT 1", __FILE__, __LINE__);


this is an SMF function that will give you meaningful error messages if anything goes wrong with your query. Also check your forum's error messages for anything related.
The query is working, I tested it (on a test database), so there must be something you're not writing good. The error messages should give you a hint.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Elmacik

#22
I agree with rudiksz and want to add something;
You already defined $my_username variable in Load.php
So you dont have to define again in Subs-Post.php
I mean you dont need this line in Subs-Post.php :
$my_username = $context['user']['name'];

Plus, this may be the reason of your problem. Because in some source files, $context is not a global.
So typing $my_username $context['user']['name']; may bring an EMPTY result. An empty query wont update the database as in this case, its normal.
Typing global $my_username; is enough in Subs-Post.php
So it will call the value from Load.php
Hopefully it will work now.
Home of Elmacik

Rudolf

On a second thought you should use the ID of a member for identifying the rwo in the table. In this case your query would look:

$result = db_query("UPDATE shop_yen SET yen=yen+1 WHERE ID_MEMBER = $ID_MEMBER LIMIT 1", __FILE__, __LINE__);

You create an integer column called ID_MEMBER in shop_yen table. Any further operation on the database will be easier and slightly faster too (JOINs).
You can use the $ID_MEMBER basically anywhere in any function, if it's not declared in the function you're modifying just add it between the globals. Remember, variable names are case sensitive, so $ID_MEMBER is not $id_member
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Aeris130

^ Sounds like a good thing to do. I'm currently having way to many usernames passed around the sites functions.

Quote from: rudiksz on July 08, 2006, 06:49:23 AM
You know what? Use the following way to do the queries.

$result = db_query("UPDATE shop_yen SET yen=yen+1 WHERE y_user_name='{$user_info['name']}' LIMIT 1", __FILE__, __LINE__);


this is an SMF function that will give you meaningful error messages if anything goes wrong with your query. Also check your forum's error messages for anything related.
The query is working, I tested it (on a test database), so there must be something you're not writing good. The error messages should give you a hint.

That finally did it, everything works the way it should. Huge thanks to everyone that replied so far, and to the coder that took his/her time to comment every 10:th line in SMF.  :)

Advertisement: