Hey all,
I am having a problem with an application I am trying to move into SMF with tinyportal. Basically, it is a database search algorithm. My current strategy is to move the current applications php files into TP using the "+External" feature. This works great, except for one problem: all of my DB queries from within the file that's being called externally are failing. That means I can't connect to the DB, can't search, can't insert, etc. This is obviously a huge problem, and I can't find a way around it.
I am using MySQLi instead of MySql for security reasons, and therefore have my own set of functions for DB connections independent of those included with TP and SMF. Should I use SMF's DB connection functions, or will mine work? Does MySQLi fail for one reason or another with TP? Does SMF or TP open a mysql connection which "boxes out" other attempts to connect to the server? I am very confused. Any help would be greatly appreciated.
-Alex
I bet what is happening, is that when you include it with the external method, paths are not working.
If you have something like this in your script:
include('../path/to/file.php');
SMF/TP execute that as if you are going from the root of SMF. I don't know of any way to possibly tell you how to fix this as you'll run into something like this no matter what you do. The only way to get it to work is by troubleshooting through it. It's a little easier to do that if you can view your server log, as it will tell you when you are trying to hit a file that is either missing or in a different location.
Nah, I checked - my Mysql file is definitely loading. This was a problem, but I fixed, and the issue is still presenting itself. It just seems like its not connecting to the mysql server (though the script definitely IS running). Is it possible that TP's own Mysql connection is somehow interfering? Thanks!
-Alex
It's very likely that the SMF MySQL connection is interfering. As I understand it, there can only be one connection open at a time. I'm not sure that what you want to do is possible.
may have to do with that new :
', sprintf($txt['mod_reports_waiting'], $context['open_mod_reports']), '
Hmmm - so then should I use the SMF Mysql protocol to retrieve my data? I really don't like that it doesn't use MySQLi (and at this point, it really, really should), but I guess I will give it a shot.
Have you tried just doing an include() ? I think running the external article through SMF/TP's eval() is what is causing the problem like Deni said. Simply doing an include() in a php article with your file "I think" should work around that.
You might want to just use an iframe, with your external pages dealing with the external database. I think that would work.
Quoteso then should I use the SMF Mysql protocol to retrieve my data?
Only if you move your tables into the same database where SMF and TP reside.
Ok, so I have the following in the PHP article window (this is ALL the text I have):
<?php
include(/users/tsc/apache2/http-www/htdocs/test/tools/query/main.php);
?>
...and nothing is showing up. I have also tried it with "require()", and still nothing. Are the "<?php?>" tags necessary. Even still, it does not work without them.
And yes, I am using the root path with include ;)
Any errors output in your error_log for apache on your server? Tags are needed, so I wouldn't worry about them.
Unfortunately, I am on a shared server, so I don't have access to that.
Also, completely unrelated, but is it possible to make articles have titles, and not just numbers, in the URL? Eg, instead of "http://www.test.com/index.php?page=8", something like "http://www.test.com/index.php?page=somename"?
On a shared server, they should still be giving you access to a access_log and an error_log. If you have CPanel, there is a section in there where you can actually view or download the log for your sites.
Quote from: azaslavsky on June 01, 2010, 09:57:48 PM
Also, completely unrelated, but is it possible to make articles have titles, and not just numbers, in the URL? Eg, instead of "http://www.test.com/index.php?page=8", something like "http://www.test.com/index.php?page=somename"?
Sure, you can do that. On the edit page for the particular article look for "Query title:" under "[Preview]Title:" The query title that you choose can be used in place of the page number.
For instance, on my test site, both of these are the same ...
http://talesofthehavenexpanse.com/smf2test/index.php?page=Board1
http://talesofthehavenexpanse.com/smf2test/index.php?page=13
ZarPrime
Quote from: IchBinâ„¢ on June 01, 2010, 10:01:55 PM
On a shared server, they should still be giving you access to a access_log and an error_log. If you have CPanel, there is a section in there where you can actually view or download the log for your sites.
Okay, found it. This is the closest I have to a file not found error:
"File does not exist: /users/tsc/apache2/http-www/htdocs/test/Themes/default/css/firefox.css, referer: http://www.mysite.edu/test/index.php?page=7;tpreview"
However, the absence of a CSS file hardly seems like a reason to show nothing at all.
Hmm... well sorry but there's really not enough information in that log then to give much more help. There should be at least something showing that eval() has a problem.
Quote from: IchBinâ„¢ on June 01, 2010, 10:44:01 PM
Hmm... well sorry but there's really not enough information in that log then to give much more help. There should be at least something showing that eval() has a problem.
Well, all of the eval errors are from the article edits, not the article itself, but...
[Tue Jun 01 13:37:57 2010] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected '/' in /users/tsc/apache2/http-www/htdocs/test/Sources/TPSubs.php(1730) : eval()'d code on line 4, referer: http://mysite.edu/test/index.php?action=tpadmin;sa=editarticle7
and
[Tue Jun 01 13:38:59 2010] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected '<' in /users/tsc/apache2/http-www/htdocs/test/Sources/TPSubs.php(1730) : eval()'d code on line 1, referer: http://www.mysite.edu/test/index.php?action=tpadmin;sa=editarticle7
Okay, I got it to load using the include method, but once again, everything works except for the DB connection. The iframe method works fairly well, but that of course raises the issue of posting data to the page in the iframe and ensuring secure access. Oh well, I guess I'll go with that for now, though I am disappointed the External article method failed.
Quote from: JPDeni on June 01, 2010, 08:55:20 PM
You might want to just use an iframe, with your external pages dealing with the external database. I think that would work.
Quoteso then should I use the SMF Mysql protocol to retrieve my data?
Only if you move your tables into the same database where SMF and TP reside.
While I have tried implementing this, my problem is that one of the main reason's I moved to SMF/TP is that I want control over which users can access which articles, something which SMF/TP has excellent tools for. An iframe, while technically allowing me that control, is also a great hinderance, since users could just bypass the iframe and go to the page directly. The only ways to pass variables from the page to its iframe are client-side, meaning that users can manipulate them and then access the tool in the iframe without having the proper permissions, something that is a pretty big deal since users pay for various parts of the application.
Oh well, I guess what I was looking for was a way to easily move my application into the SMF/TP ecosystem; I guess I will just have to bite the bullet and switch to the SMF database query method.