Hey,
i'm working on a plugin which needs an extra database connection. The database host is the same as the one i use for elgg but the database itself and the user are different.
So when i try to establish the connection with a simple script (mysql_connect()) it works just fine but if i try that within a plugin then i'm getting a strange error. It says:
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 '= -2
AND .owner_guid IN (
SELECT guid_one FROM elgg_entity_relationships
' at line 1
This error comes from the mysql_connect() line. There is no error if i comment this line out. So can you tell me where this error is coming from?
greets
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Brett@brett.profitt

Brett - 0 likes
- rob2109@rob2109

rob2109 - 0 likes
- Brett@brett.profitt

Brett - 0 likes
- rob2109@rob2109

rob2109 - 0 likes
You must log in to post replies.When you use mysql_connect() to make your own connection, be sure you set the 4th parameter ($newlink) to true. This will tell PHP not to use the existing connection, but to create a new one. When you use mysql_connect() without that, you're changing the database Elgg is using to connect to its tables. If you're still getting query errors, be sure to post the entire error to help us debug it.
Thanks for your help but i tried that and it did not work. My command was like this:
$this->conn = mysql_connect($host, $user, $pass, true);
No difference.
The thrown errors which are always different. The only thing they have in common is that it is a mysql error. I copied the whole error into pastebin.
http://pastebin.com/tWGHQRs6
I'm looking desperately for a solution. I hope anyone can help.
greets
Try to disable the access_plus plugin. It looks like the error is originating there.
Is that not this plugin? I couldn't find the code the error stack trace references in the latest version of that plugin.
Thanks for your help. The problem really seemed to be in relation with that PlugIn. The error was not thrown when i deactivated the PlugIn, but a different appeared. But i solved it by cutting the code out of the init function of my plugin. Now i'm opening the connection within a different file and all works fine until now. I'll tell you here if i got any other errors.
But anyway i should update the plugin to avoid more problems.
greets