Jump to content

[SOLVED] Fatal error: Cannot redeclare "My function" Help please.


Recommended Posts

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!  :)

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")

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

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);

}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.