Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

forum_User table not updating

Quote Reply
forum_User table not updating
Hi there,

I am trying to update data in the forum_User table.
Here is the script I am using (it is called via AJAX, the script is located in /home/mw/mywebsite.com/cgi-bin/forum):

Code:
#!/usr/bin/perl -w

use CGI;
use strict;
my $query = new CGI;
my $func = $query->param('func');

if($func eq "llUpd"){

my $user = $query->param('id');
my $lat = $query->param('lat');
my $lng = $query->param('lng');
my $result;
use lib '/home/mw/mywebsite.com/cgi-bin/forum/admin';
use GForum qw/$DB/;

GForum::init('/home/mw/mywebsite.com/cgi-bin/forum/admin');

my $user_table = $DB->table('User');
$result = $user_table->update({ user_latitude => $lat, user_longitude => $lng }, { user_username => $user });

if($result)
{

print $query->header;
print "$result lat:$lat lng:$lng";
}
else
{

print $query->header;
print "Update failed.";

}
}

The if statement evaluates true and the result of the print in the true branch is

Code:

GT::SQL::Driver::MYSQL::sth=HASH(0xa0b1d60) lat:-29.535229562948455 lng:27.421875

It seems to work, but the columns in the table isn't being updated. Thanks for the help Wink


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] forum_User table not updating In reply to
Hi,

Try writing some details into a log file, so you can see what details are being passed in, i.e:

Code:
open(WRITEIT,">/path/to/file/debug.txt");
print WRITEIT qq|{ user_latitude => $lat, user_longitude => $lng }, { user_username => $user } \n|;
close(WRITEIT);

Then, call the script - and look in /path/to/file/debug.txt - to see what details are printed.

It could be one of your variables are missing.

BTW, on this line:

Code:
print "$result lat:$lat lng:$lng";

.. not sure if this will 100% work, but try:

Code:
print $result->query . qq| lat:$lat lng:$lng|;

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [EZFrag] forum_User table not updating In reply to
Oh, also - what happens if you try to manually edit a user in the admin panel, with those long and lat values? Does that work? If not, it could be your field setup (i.e it may not like the field type you've setup)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] forum_User table not updating In reply to
Andy, once again you have both proven your genius and my stupidity. Smile

Here is the parameters I need in the script:

Code:

my $func = $query->param('func');
my $user = $query->param('user');
my $lat = $query->param('lat');
my $lng = $query->param('lng');

And this is what I sent it:

Code:

func=llUpd
id=<%user_username%>
lat=+getLat()
lng=+getLng()

That costed me +-4 hoursUnsure

Anyway, thanks alot AndyWink


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] forum_User table not updating In reply to
Hi,

haha - np =)

Don't feel silly, I do stuff like that all the time (and normally at the expense of hours or trying to work it out / rewriting - only to find it was something silly :P)

Glad that helps though.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!