Jump to content

Is there a hook error log?


Fearghal

Recommended Posts

I am writing some hooks to expand my new website, however the script is not working.

 

I cannot see any errors, just no results. Is there an error log I can look at to see the problem?

 

It's currently installed as an addon module and is supposed to run after module create.

 

Any help would be appreciated!

Link to comment
Share on other sites

Thanks! I've now managed to work out that for some reason the variables are not being defined.

 

I have...

 

<?php

function hook_updatetokens($vars) {

   $serviceid = $vars['serviceid'];
   $product = $vars['pid'];
   $username = $vars['username'];

if($product==5){	 
 $result = mysql_query("SELECT userid FROM tbl WHERE id=$serviceid");

 $data = mysql_fetch_array($result);
 $userid= $data[0];
 $smartyvalues["userid"] = $userid;

 //current credits
 $result = mysql_query("SELECT smscredits FROM tblclients WHERE id=$userid");
 $data = mysql_fetch_array($result);
 $smscredits = $data[0];
 $smartyvalues["smscredits"] = $smscredits;

//New credit amount
$newamount = $smscredits + 1;  

 mysql_query("UPDATE `tblclients` SET `smscredits`='$newamount' WHERE `id`=$userid");
 mysql_query("UPDATE `tblclients` SET `userid`='9' WHERE `id`=$userid");
	 };

}


add_hook("AfterModuleCreate",1,"hook_updatetokens");

?>

 

Have I done something silly?

Link to comment
Share on other sites

<?php
function hook_updatetokens($vars) {
$serviceid = $vars['serviceid'];
$product = $vars['pid'];
$products = array(5,6,7,8,9); // products list 

if(in_array($product, $products) === true){
	mysql_query("UPDATE `tblclients` SET `smscredits`= smscredits+1 WHERE `id` = (SELECT userid FROM tblhosting WHERE id = '{$serviceid}')"); // better
}

}

add_hook("AfterModuleCreate",1,"hook_updatetokens");

?>

 

i didnt test it but its should work :)

Edited by k1ng440
Link to comment
Share on other sites

Heres the full code that will probably work.

 

<?php

function hook_updatetokens($vars) {

 $serviceid = $vars['serviceid'];
 $product = $vars['pid'];
 $username = $vars['username'];
 if ($product == 5) {
   $query = "SELECT c.user, c.smscredits FROM tblclients c, tblhosting h WHERE h.id = $serviceid AND h.userid = c.id";
   $result = full_query($query);
   $data = mysql_fetch_array($result);
   $userid = $data[0];
   $smscredits = $data[1];
   $smartyvalues["userid"] = $userid;
   $smartyvalues["smscredits"] = $smscredits;

   //New credit amount
   $newamount = $smscredits + 1;

   update_query("tblclients", array("smscredits"=>$newamount), array("id" => $userid));
 }
}

add_hook("AfterModuleCreate",1,"hook_updatetokens");

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated