MyBB Community Forums

Full Version: What do I CHMOD 777 to make Ajax Cool Reg work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm trying to get Ajax Cool Registration to work, but I'm getting errors that it can't access the server. I remember reading a while back that this was caused by not CHMODing a particular folder, but I can't remember which one. I've searched these forums and don't see it here. Any help is greatly appreciated.

I'm currently getting this error:

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /misc/38/000/164/778/0/user/web/baytownbb.com/inc/plugins/ajax_cr.php on line 34


Thanks,
Dstaten
dastaten Wrote:I'm trying to get Ajax Cool Registration to work, but I'm getting errors that it can't access the server. I remember reading a while back that this was caused by not CHMODing a particular folder, but I can't remember which one. I've searched these forums and don't see it here. Any help is greatly appreciated.

I'm currently getting this error:

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /misc/38/000/164/778/0/user/web/baytownbb.com/inc/plugins/ajax_cr.php on line 34


Thanks,
Dstaten

try reactivating it, it has to do with you mysql.
i've deactivated and reactivated a few times. it has never worked from the beginning.

Isn't the "cannot connect" because I need to chmod something?

Here are my mysql settings:

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 5.0.27
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_INCLUDE -I/usr/include/mysql
MYSQL_LIBS -L/usr/lib -lmysqlclient

Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 30 30
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port 3306 3306
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off
Can you post that line? It might not be using the $db class and may need to be rewritten.

ADD:

Yeah...took a look and you need to change the function.

function ajax_cr_action()
{
    global $mybb;
    if ($mybb->input['action'] == 'CheckUsername') {
	$query = mysql_query("SELECT username FROM `".TABLE_PREFIX."users` WHERE `username` = '" . $_GET['user'] . "'");
	$count = mysql_num_rows($query); 
	if ($count > 0) { 
		$return_value = $_GET['user'] . ",Invalid"; 
	} else {
		$return_value = $_GET['user'] . ",Working";
	}
	echo $return_value;
}
}

To this:

function ajax_cr_action()
{
    global $mybb, $db;
    if ($mybb->input['action'] == 'CheckUsername') {
	$query = $db->query("SELECT username FROM `".TABLE_PREFIX."users` WHERE `username` = '" . $db->escape_string($_GET['user']) . "'");
	$count = $db->num_rows($query); 
	if ($count > 0) { 
		$return_value = $_GET['user'] . ",Invalid"; 
	} else {
		$return_value = $_GET['user'] . ",Working";
	}
	echo $return_value;
}
}

Let me know if that doesn't work cuz it's not tested but that should fix it.

Holy crap....the original code has a HUGE mysql injection problem by not sanitizing the query. I recommend anyone reading this fix that.
looks a little better. but now i'm getting this...

Fatal error: Call to a member function query() on a non-object in /misc/38/000/164/778/0/user/web/baytownbb.com/inc/plugins/ajax_cr.php on line 34
Oh ...forgot to global the $db.
function ajax_cr_action()
{
    global $mybb, $db;
    if ($mybb->input['action'] == 'CheckUsername') {
    $query = $db->query("SELECT username FROM `".TABLE_PREFIX."users` WHERE `username` = '" . $db->escape_string($_GET['user']) . "'");
    $count = $db->num_rows($query); 
    if ($count > 0) { 
        $return_value = $_GET['user'] . ",Invalid"; 
    } else {
        $return_value = $_GET['user'] . ",Working";
    }
    echo $return_value;
}
}
IT WORKS!!! I've been trying off and on to get this working for a long time. Thanks for all your help! Smile
No problem...glad I could help.
one last question, if you don't mind. i'm using captcha and i'm not sure where to paste this code. i'm on step 3 on this page: http://www.captchacreator.com/v-howtoinstall.html I've uploaded the captcha images and fonts and everything and i've got it showing on the page. but i'm not sure where to paste that last code. i tried on member.php and i'm getting an error.
Mybb comes with Captcha. It's on by default.
Pages: 1 2