HTML Logo by World Wide Web Consortium ( Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.

Modification to Member Registration

Login / Search

 [ Join | More ]
 Add topic 
#102241 (In Topic #20039)

Fan in training

This should have been a simple modification to when a member registers...

Latest version of ocportal, new site setup through auto install scripts.  The basics are working well.
What I needed to do is "Catch" user registrations and "Sync" (create an account) on another Mysql
database at a remote site.  So I read up on things, copied the ocf_join.php to sources_custom and
dropped my own php file in the same directory with it. 

End result output is:
[ Could not connect: Access denied for user 'mrjpmyth'@'localhost' (using password: NO) ]

This occurs during the Join process after hitting save on the user join form.  And here is my script.
I figure I am doing something very simple wrong, but I am not much of a PhP coder, I do c++/c#

​(original code above ... Starting at line 332 in ocf_join.php)

    //Mythic DEBUG
    ewaction_register( $username, $password );
(original code below..)   
    // Send confirm mail
    if (!$skip_confirm)

And my little file: ewgame.php


$host_ewgame = "";
$user_ewgame = "xxxxxxx";
$pass_ewgame = "xxxxxxxxx";

// Here we receive the update from smf
function ewaction_register( $username, $password )
    global $host_ewgame, $user_ewgame, $pass_ewgame;
    if ( !(isset($username) && isset($password)) )
        die("Empty input data");
    $link = mysqli_connect($host_ewgame, $user_ewgame, $pass_ewgame, 'Xxxxxx' ) or die('Could not connect: ' . mysqli_connect_error());

End result: Full error report...

PHP WARNING [2] mysqli_connect() [<a href=''>function.mysqli-connect.php</a>]: (28000/1045): Access denied for user 'mrjpmyth'@'localhost' (using password: NO) in sources_custom/ewgame.php on line 18 (version: 9.0.11, PHP version: 5.2.17, URL: /ewproject/index.php?page=join&type=step3&

Now I have had this working on my Test Server using Smf, but I liked the looks of OcPortal and
when I moved to a commercial hoster I went with you guys and now I am unsure why it no longer
works as it should.

Originally I had been using $host ="xxx";, etc... but when I got the wrong user/host I changed the
globals as I thought it might be a Global clash, but even with the $host_ewgame change, it is still
giving me the above errors..

Any help would be greatly appreciated.

Back to the top

You need global $host_ewgame, $user_ewgame, $pass_ewgame; before the initialisation of the values for it.

While you have your initialisation code in the global scope of that particular file, you are including the file within a local scope (require_code inside a function). Hence it executes as local scope and nothing is automatically globalised. You then jump out to ewaction_register, a different local scope.

I realised this as it said it wasn't using a password, because PHP auto-casted unset variables to blank.

Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top

Fan in training

yep, I'd figured that out on the road on the way to work this morning :)  I was use to "Including" the file not activating a function.  The useage here thru me.
Back to the top
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: