News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

smcFunc: "Database Error"

Started by Kashius, October 09, 2018, 01:56:35 AM

Previous topic - Next topic

Kashius

Hey,

I'm trying to add a custom function to "Subs-Auth.php", but I'm getting the following error:

Quote
Database Error

Please try again. If you come back to this error screen, report the error to an administrator.

Here is the code I'm using to test things out:


<?php

require_once('../forums/SSI.php');
require_once(
'../forums/Sources/Subs-Auth.php');

$x usernameExists('abc');

echo 
'x = ' $x;

?>



This is the function I added inside "Subs-Auth.php":

function usernameExists($username)
{
//include_once('../SSI.php');
global $smcFunc;

$found_username = null;

$found_username = $smcFunc['db_query']('',
'SELECT `member_name` FROM `{db_prefix}smf_members` WHERE `member_name` = {text:id_member_name}',
array('id_member_name' => $username));

if($found_username == false) {
return 0;
}

return 1;
}


Thanks for reading and even more thanks for any assistance. I've been trying to figure this out on my own for a few days too long now and this is my last resort..

Arantor

What exactly are you trying to do? Depending on what you're trying to do, SMF may already have tools for you without you having to write them yourself.

Like SMF is perfectly capable of finding a user by username during login...

Kashius

What I need to do is use SMF to check information that's entered in the game. The existing validatePassword() is fine, but there is no function for simply checking for an existing account.

Arantor

Actually there is, because registration calls it via AJAX to verify whether the username entered exists or not.

I'm not on my desktop so I can't show you the URL, but go through registration with browser inspector on, watch the network tab while entering a user name.

Shambles

If you insist in going down this route, check your usage of {db_prefix}smf_members

Not knowing what your table names are I strongly suspect you won't have an additional smf_ as part of the table name, so try {db_prefix}members instead.

Like I said, just a guess...

Kashius

Quote
Actually there is, because registration calls it via AJAX to verify whether the username entered exists or not.

I'm not on my desktop so I can't show you the URL, but go through registration with browser inspector on, watch the network tab while entering a user name.

This is what I needed.

Quote
If you insist in going down this route, check your usage of {db_prefix}smf_members

Good catch, but nothing changed -- luckily I don't have to do any of that now, though.

Thanks to you both for the assists.

Advertisement: