Topic-icon Error 1064 ?

Active Subscriptions:

None
12 years 4 months ago #40816 by reggio-metals
Error 1064 ? was created by reggio-metals
Hi

im running through some errors in the site for specific users , when i try to login and i press on facebook button a fast popup comes doing nothing then i get this error :

ERROR: 1064 - YOU HAVE AN ERROR IN YOUR SQL SYNTAX; CHECK THE MANUAL THAT CORRESPONDS TO YOUR MYSQL SERVER VERSION FOR THE RIGHT SYNTAX TO USE NEAR 'INT) SUFFIX FROM GNX32_USERS WHERE `USERNAME` ~ '^NAJD.DERGHAM[0-9]+$' ORDER BY ' AT LINE 1 SQL=SELECT CAST(REPLACE(USERNAME, 'NAJD.DERGHAM', '') AS INT) SUFFIX FROM GNX32_USERS WHERE `USERNAME` ~ '^NAJD.DERGHAM[0-9]+$' ORDER BY `SUFFIX` DESC LIMIT 1


www.syrianabroad.com in case you want to check

Thank you
The topic has been locked.
Support Specialist
12 years 4 months ago #40827 by alzander
Replied by alzander on topic Error 1064 ?
Sorry for the issue. You're running into a SQL query bug in the latest release that will be fixed in the next one. It only affects specific automatically generated usernames, so it won't happen in all cases.

To implement the one line change, please open the /libraries/sourcecoast/utilities.php file. Around line 622, you'll see:
$query = "SELECT CAST(REPLACE(username, " . $dbo->quote($prefix) . ", '') AS INT) suffix FROM #__users WHERE " . $dbo->qn('username') . " ~ '^" . $prefix . "[0-9]+$' ORDER BY " . $dbo->qn('suffix') . " DESC LIMIT 1";
Please replace that line with:
$query = 'SELECT CAST(REPLACE(username, ' . $dbo->quote($prefix) . ', "") AS UNSIGNED) suffix FROM #__users WHERE `username` REGEXP "^' . $prefix . '[[:digit:]]+$" ORDER BY `suffix` DESC LIMIT 1';

I hope that helps, but if you continue to have issues or have any other questions, just let me know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 4 months ago #40833 by reggio-metals
Replied by reggio-metals on topic Error 1064 ?
ty solved
The topic has been locked.
Support Specialist
12 years 4 months ago #40836 by alzander
Replied by alzander on topic Error 1064 ?
No problem. Glad to hear we could help. Should you run into any other issues, just let me know!

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 4 months ago #40837 by reggio-metals
Replied by reggio-metals on topic Error 1064 ?
As i see this fix kind of add "1" to a user name in case of duplicate or something ya ? can we add something else ? like an invisible space or a dot maybe ?
The topic has been locked.
Support Specialist
12 years 4 months ago #40848 by alzander
Replied by alzander on topic Error 1064 ?
That code is meant to check for an already existing auto-generated username. If one is found, it finds a number after the name (if one exists) and then adds 1 to it. That way, if your site is popular with user's named John Smith, the usernames generated would be johsmi, johsmi1, johsmi2, johsmi3

Adding a . would only work for the 2nd user with that name. Our system will work with unlimited users that have the same auto-username generated.

If you have a suggestion for a better system, just let me know. We'll gladly investigate, but the system we have implemented has been working for a few years without complaint (until this bug in the last release which causes the SQL error on some systems).

Thanks,
Alex
The topic has been locked.