Jump to content

MySQL accessing from a InvoiceCreationPreEmail hook


webio

Recommended Posts

Hello,

can someone point me direction why this code:

 

<?php
function free_account_upgrade($vars) {
   $invoiceid = $vars['invoiceid'];
   $sql_order_num = "SELECT id FROM tblorders WHERE invoiceid = '$invoiceid'";
   $rs_order_num = mysql_query($sql_order_num);
   while($row = mysql_fetch_array($rs_order_num, MYSQL_ASSOC)){
       $order_num = $row["id"];
   }
   $sql_hosting_num = "SELECT id FROM tblhosting WHERE orderid = '$order_num'";
   $rs_hosting_num = mysql_query($sql_hosting_num);
   while($row = mysql_fetch_array($rs_hosting_num, MYSQL_ASSOC)){
       $hosting_num = $row["id"];
   }
   echo($invoiceid." ".$order_num." ".$hosting_num);
   update_query("tblhosting",array("notes"=>"Upgrade"),array("id"=>$hosting_num));
   delete_query("tblcancelrequests","relid='".$hosting_num["id"]."'");
}
add_hook("InvoiceCreationPreEmail",1,"free_account_upgrade");
?>

 

is not fetching any data from MySQL? I was trying many many other variations with select_query too. Everytime MySQL is not returning anything.

 

Thank you

Link to comment
Share on other sites

Are you sure that the hook is returning an array for the invoice ID? being that its only 1 var that gets passed to it, its possible that its not an array at all.

 

Either way, I'd add some debugging code to print out the invoice ID so you can verify that its being passed properly.

 

Other than that, the code looks like. As stated in your post, you should use select_query() where applicable.

 

Also, try turning on display_errors in your configuration.php to make sure its not something silly like a newline after the closing ?>

 

Hope this helps!

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