1
lunaticalm
Need help in kernel/member.php
  • 2009/4/21 20:40

  • lunaticalm

  • Just popping in

  • Posts: 14

  • Since: 2005/1/4 1


Hi I want to add to function activateUser() a notification from one of the modules to be default checked for the registered users.
so I have added this to the activateUser() function, but i can't make this to insert value into xoopsnotifications table,

Please help me thanks.

function activateUser(&$user)
    {
        if (
$user->getVar('level') != 0) {
            return 
true;
        }

        
$user->setVar('level'1);

 
//notification mod start       
//module id =9 

  
$query "INSERT INTO ".$xoopsDB->prefix("xoopsnotifications")." (not_modid, not_itemid, not_category, not_event, not_uid, not_mode) VALUES (9,".$user->getVar('uid').",'scrap','new_scrap',".$user->getVar('uid').",0)";
$res=$xoopsDB->query($query);
if(!
$res) {
echo 
"error: $query";
}
//notification mod end


        
return $this->_uHandler->insert($usertrue);
    }

2
ghia
Re: Need help in kernel/member.php
  • 2009/4/21 21:02

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Do you see the error?
Must you not use $this->_uHandler->db->prefix(" in stead of $xoopsDB->prefix(" ?

3
lunaticalm
Re: Need help in kernel/member.php
  • 2009/4/21 21:45

  • lunaticalm

  • Just popping in

  • Posts: 14

  • Since: 2005/1/4 1


Becouse the page is refrshing after activation, Yes i see the error if i ad exit() after echo "error: $query";

$xoopsDB->prefix is ok becouse that is pointing at my db prefix in databse, i can see that on the error , but can't understand what is causing the error.

4
ghia
Re: Need help in kernel/member.php
  • 2009/4/21 21:51

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


With the exit, copy the query and put it in the SQL window of phpMyAdmin and press go. It would give a clear error message if the query itself is not acceptable.

5
lunaticalm
Re: Need help in kernel/member.php
  • 2009/4/21 22:07

  • lunaticalm

  • Just popping in

  • Posts: 14

  • Since: 2005/1/4 1


I added and global $xoopsDB; at the code and
at error msg i have
errorINSERT INTO myprefix_xoopsnotifications (not_modidnot_itemidnot_categorynot_eventnot_uidnot_modeVALUES (9,867,'scrap','new_scrap',867,0)


When i run that query with phpmyadmin the query is executed with no errors , and new record is inserted into the table

6
ghia
Re: Need help in kernel/member.php
  • 2009/4/22 0:31

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Try once:
echo "error: $xoopsDB->error()";

7
phppp
Re: Need help in kernel/member.php
  • 2009/4/22 1:26

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


update queries are forbidden under a GET request.

Try
$res $xoopsDB->queryF($query);

8
lunaticalm
Re: Need help in kernel/member.php
  • 2009/4/22 5:03

  • lunaticalm

  • Just popping in

  • Posts: 14

  • Since: 2005/1/4 1


Thank you very much ghia, phppp.

Quote:
$res = $xoopsDB->queryF($query);

This solved the code to work.
Many time i wondered what is the diference between query and queryF, now i know :).

Login

Username:
Password:

Lost Password? Register now!

Who's Online

59 user(s) are online (41 user(s) are browsing Support Forums)


Members: 0


Guests: 59


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jan 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits