TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,911
  • Total Topics: 21,307
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 361
  • Total: 362
  • tino

Database connection with External article

Started by azaslavsky, May 27, 2010, 10:42:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

azaslavsky

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

IchBin

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.

azaslavsky

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

JPDeni

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.

Crip

may have to do with that new :

', sprintf($txt['mod_reports_waiting'], $context['open_mod_reports']), '
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



azaslavsky

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.

IchBin

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.

JPDeni

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.

azaslavsky

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 ;)

IchBin

Any errors output in your error_log for apache on your server? Tags are needed, so I wouldn't worry about them.

This website is proudly hosted on Crocweb Cloud Website Hosting.