A2xA Posted September 1, 2008 Share Posted September 1, 2008 I'm trying to pass a function from one page to another.. I've go this error: Fatal error: Cannot redeclare handle_this() (previously declared in /x/x/x/x/x/SiteRegister.php:3) in /x/x/x/x/x/Register.php on line 308 My code on the first file (that's passing it) register.php $memberID = registerMember($regOptions); require_once('/x/x/x/x/x/SiteRegister.php'); function handle_this($regOptions, $memberID) { } { } My Code on the 2nd page (that it's passing two) SiteRegister.php <?php function handle_this($regOptions, $memberID) { $con = mysql_connect("x","x","x"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("x_smf", $con); mysql_query("INSERT INTO users (userName, userUser, userPass, UserID, userEmail) VALUES (" . $regOptions['username'] . ", " . $regOptions['username'] . ", " . $regOptions['password'] . ", " . $memberID . " " . $regOptions['email'] . ");"); mysql_close($con); } ?> If someone could take a look and see what I'm doing wrong I'd greatly appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/122161-solved-fatal-error-cannot-redeclare-my-function-help-please/ Share on other sites More sharing options...
spfoonnewb Posted September 1, 2008 Share Posted September 1, 2008 I'm confused, the function is already passed by running require_once. You can't have this as well: function handle_this($regOptions, $memberID) { } { } If you want to use the function just run handle_this("options", "member_id") Quote Link to comment https://forums.phpfreaks.com/topic/122161-solved-fatal-error-cannot-redeclare-my-function-help-please/#findComment-630679 Share on other sites More sharing options...
A2xA Posted September 1, 2008 Author Share Posted September 1, 2008 I've tried a bunch of things. And all wern't working so I just ended up with that.. Now i've got: for the register.php first file $memberID = registerMember($regOptions); require_once('/x/x/x/x/x/SiteRegister.php'); handle_this("options", "member_id"); and..for the second file: <?php handle_this("options", "member_id"); mysql_select_db("x"); mysql_query("INSERT INTO users (userName, userUser, userPass, UserID, userEmail) VALUES (" . $regOptions['username'] . ", " . $regOptions['username'] . ", " . $regOptions['password'] . ", " . $memberID . " " . $regOptions['email'] . ");"); ?> It gives me this error: Fatal error: Call to undefined function handle_this() in /x/x/x/x/x/SiteRegister.php on line 3 Quote Link to comment https://forums.phpfreaks.com/topic/122161-solved-fatal-error-cannot-redeclare-my-function-help-please/#findComment-630684 Share on other sites More sharing options...
spfoonnewb Posted September 1, 2008 Share Posted September 1, 2008 Second file should be like this: <?php function handle_this($regOptions, $memberID) { $con = mysql_connect("x","x","x"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("x_smf", $con); mysql_query("INSERT INTO users (userName, userUser, userPass, UserID, userEmail) VALUES (" . $regOptions['username'] . ", " . $regOptions['username'] . ", " . $regOptions['password'] . ", " . $memberID . " " . $regOptions['email'] . ");"); mysql_close($con); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/122161-solved-fatal-error-cannot-redeclare-my-function-help-please/#findComment-630685 Share on other sites More sharing options...
A2xA Posted September 1, 2008 Author Share Posted September 1, 2008 thanks that worked. I've got a system error now :-X I'll go patch it up. Quote Link to comment https://forums.phpfreaks.com/topic/122161-solved-fatal-error-cannot-redeclare-my-function-help-please/#findComment-630691 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.