JimWorld Forums: Alternative to INCLUDE?



Posted By: david68 ()
Posted On: 07/30/2007 11:17 am

I have a "users online" PHP script which I place on each page on my site, works great showing how many people hit each page recently. I added it to my PHPBB forums with no problem, but I have since switch to SMF (due to spamming problems) and it works but also gives an error, saying a table doesn't exist which isn't even in my script. I changed all $string values to something unique so that couldn't be it. My INCLUDE is at the bottom of the main forum script, so it can't be doing anything after it it called.

Error:
Database Error: Table 'dbname.smf_sessions' doesn't exist
File: ..path/forums/Sources/Load.php
Line: 2005

dbname is the name of my database for the users online sql base. Unfortunately I don't know what line 2005 is as I just use wordpad to write my scripts and run them on the server.

I did ask this in the SMF forums but nobody there helps sad

I tried EXEC but it didn't work. Any idea what I could do to just run it by itself after the main script is done? It doesn't share any info so INCLUDE isn't needed if there is another method. Thanks.



Posted By: SportsGuy (Moderator)
Posted On: 07/30/2007 11:24 am

Crap - I had a great response about going to SMF support forums to ask, then reread your post. sad

Make sure you try a couple of different sections there (I tend to only post in the main support area, not the sub-sections) as that main area sees more traffic.

I've also had to bump posts daily for a few days before getting a response, but this I attribute to summer/vacation/folks spending more time outdoors, etc.

Sorry I've got nothing direct to contribute to answer your question... sad


Posted By: david68 ()
Posted On: 07/30/2007 01:06 pm

Well, I only posted it here wondering if it's a SQL problem (tho worked fine in PHPBB) and if there is a way to call a PHP from another PHP script without sharing anything, without INCLUDing. I don't know everything about PHP and know nothing about SQL smile



Posted By: SportsGuy (Moderator)
Posted On: 07/30/2007 04:14 pm

The only real advice I can offer comes from my own self-teachings:

Be VERY careful in the code in SMF - especially the new versions. If you misplace even so much as a semi-colon it'll die on you. wink

Other than that, I've still got my learner's permit for coding...


Posted By: Prowler (Moderator)
Posted On: 07/30/2007 10:10 pm

I am not sure about your question. As I understand, your main script which has an include (calls an external file for further processing) fails due to a database error.

The easy way to isolate and test a module (in your case the offending include file Load.php) is to write another test script which includes the Load.php along with any other supporting files. You can test this directly from the browser like so: http://localhost/test.php

Alternatively go to your shell prompt and type
php test.php




Posted By: david68 ()
Posted On: 07/31/2007 06:18 am

Thanks for the input. I don't have sql and everything locally so I have to test it on the server. Basically everything works fine until I include my little users online script at the end of the main forum file - it works but shows the above error after it's done, must be some SQL clash tho I don't understand how. If I could just RUN my PHP script and not INCLUDE it, it probably would work fine. I'm going to try VIRTUAL later, probably won't work.



Posted By: Prowler (Moderator)
Posted On: 08/01/2007 06:09 am

Including a file is the same as running it in the server. The file included is run in the server; You can still test the results from your server.

Instead of http://localhost/test.php you will have to address the script as [link]



Posted By: david68 ()
Posted On: 08/01/2007 07:27 am

I know that smile What I meant is can I execute a PHP from within a PHP script but have it ignore the other PHP script? For some reason, and since I don't know SQL or PHP well enough to figure it out, my users online script and the forum script are clashing in the SQL area, but the $string names and SQL names are different. I have no clue. It worked fine in PHPBB, too bad it's a junk forum and the spammers love it. I kind of gave up on resolving it. I googled everything I can think of.


Posted By: Dinkar (Moderator)
Posted On: 08/01/2007 01:00 pm


Error:
Database Error: Table 'dbname.smf_sessions' doesn't exist
File: ..path/forums/Sources/Load.php
Line: 2005


You are adding the script at the end of the file so I guess it get executed after some code that terminate or do somthing similar with the session database.

I don't know SMF so can't tell you the exact location to add your script but it should be somewhere before footer of your main script.



Posted By: david68 ()
Posted On: 08/01/2007 02:35 pm

Yeah, but smf_sessions shouldn't even be an issue as my script doesn't call it, that's what's weird. If my db name and variables aren't the same as smf's, it shouldn't matter where it goes. I assume you can have 2 db's open at the same time right? Besides, mine opens/closes/displays info before the error... I don't know. I know it's impossible for people to understand without seeing all the code but figured I'd ask smile



Posted By: langardmicro ()
Posted On: 08/01/2007 05:07 pm

Try absolute, hardwired paths to your includes. If you're trying to connect to two different databases simultaneously, that'll cause problems. Get the free version of NoteTabPro, load your script into it, take off the wordwrap and go to line whatever using the toolbar.


Posted By: david68 ()
Posted On: 08/02/2007 05:14 am

I do use full paths.

If you can't connect to 2 db's at the same time, maybe that's the issue. But I did put the script at the very end of the main file so you'd think it would be closed. Thanks for the pointers.


Posted By: Dinkar (Moderator)
Posted On: 08/02/2007 05:54 am

I did put the script at the very end of the main file


Don't put the script at the very end of the main file. Put it before "footer" instructions that closes everything.


Posted By: david68 ()
Posted On: 08/02/2007 08:23 am

I'll look into that, thanks. If you ever looked at the source for forums you'd go crazy trying to find what you need. Complicated stuff. Like I said long ago, it worked without issue with PHPBB so SMF must not be closing it out where I thought it should have.


JimWorld Forums © 1996 - 2004 .... iWeb Technology, Jimworld.com