Belelros Posted September 16, 2010 Share Posted September 16, 2010 Hi there, I have this hook: <?php function setupweb($vars) { $password= $vars["params"][password]; $email= $vars["params"][email]; $domain= $vars["params"][domain]; $subdomain=str_replace(".$main_domain", "", $vars["params"][domain]); exec("mysql -uroot -p$root_pass $subdomain < /home/master/master.sql"); $date = date("Y-m-d H:i:s"); $connection = mysql_connect("localhost","root","S4ha5do0w"); mysql_select_db("dbmydnsconfig", $connection); $sql="INSERT INTO `dns_rr` VALUES('', 1, 0, 'riud', 'riud', '', 1, 5, '$subdomain', 'A', '$server_ip', 0, 86400, 'Y', '2010-04-30 17:21:16', 2010043002)"; $sqlb="INSERT INTO `hosting` VALUES('', '$subdomain', '$password','$date' ,'0','$_SERVER[HTTP_REFERER]','$_SERVER[REMOTE_ADDR]','$data')"; mysql_query($sql,$connection); mysql_query($sqlb,$connection); mysql_close($connection); } add_hook("AfterModuleCreate",1,"setupweb"); ?> And it makes it right. It creates a Database and also a folder and insert some data in a DB table. But then, I needed to insert more code which is: mysql_select_db($subdomain, $connection); $mailsql="UPDATE 'config' set config_value='$email' where config_name like 'admin_email'"; mysql_query($mailsql,$connection); The DB "selected" is the one created in this step: exec("mysql -uroot -p$root_pass $subdomain < /home/master/master.sql"); I've tried to put in another function and execute it using add_hook("AfterModuleCreate",2,"setupanotherfunction"); And also inside the function at the top but it doesn't do anything... anyone have any clues? 0 Quote Link to comment Share on other sites More sharing options...
ShaneMcC Posted September 16, 2010 Share Posted September 16, 2010 You haven't included all the code there so I'm making assumptions here, but my best guess is that you aren't creating the variable in the second function. The $subdomain variable only exists inside that first function, it won't exist in another unless you declare it, or make it global. 0 Quote Link to comment Share on other sites More sharing options...
Belelros Posted September 17, 2010 Author Share Posted September 17, 2010 You haven't included all the code there so I'm making assumptions here, but my best guess is that you aren't creating the variable in the second function. The $subdomain variable only exists inside that first function, it won't exist in another unless you declare it, or make it global. As I said, I tried to put that code in the first function (so it could use the subdomain variable) and when it is in a second function I copy all the variables again in that function. The majority of the code is there BTW, thanks for your help ^^ 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted September 17, 2010 Share Posted September 17, 2010 What he is saying is, the variables will not carry over from function1 to function2 without defining them as globals. You'd have to redefine them in the second function 0 Quote Link to comment Share on other sites More sharing options...
Belelros Posted September 17, 2010 Author Share Posted September 17, 2010 What he is saying is, the variables will not carry over from function1 to function2 without defining them as globals. You'd have to redefine them in the second function I don't know if you didn't understand but I certainly redefine them if they are in another function so that's not the problem. I just avoid copying that because it was the same text as above. 0 Quote Link to comment Share on other sites More sharing options...
Trekkan Posted September 27, 2010 Share Posted September 27, 2010 BTW, that looks like a valid root password in your first post, might wanna edit that. 0 Quote Link to comment Share on other sites More sharing options...
Belelros Posted September 27, 2010 Author Share Posted September 27, 2010 It seems I can't 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted September 27, 2010 Share Posted September 27, 2010 Report the post and have a moderator remove it. Either way, you should change it. 0 Quote Link to comment Share on other sites More sharing options...
Belelros Posted September 27, 2010 Author Share Posted September 27, 2010 I did it but nobody answered yet... 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.