Creating EXTERNAL PHP MODULES

Happy New Year, folks!

I am having an issue that’s been dragging my life for quite some time. I am creating a website for my church maranatha.tv.

The site’s Menu and Content are pulled from a MySQL database I created. As far as this goes, everything is fine; content is pulled from my database with no issues.

My problem is as follow:
I am including an online bible, which is a third party script I downloaded. This scripts come with its own database, which I have installed for use in my web server. I used Include() to include the index.php file of the online bible script, from its folder.

Of course, this script has its own folder and a set of files which makes up the entire bible script. I use an if condition so that when the user clicks on the menu button BIBLE, the bible index.php file is included instead of text from my database. This way of adding the third party script is rendering some unwanted results such as layout distortion (which I don’t care at this point), broken links (main issue), and links (although broken) are sent to new pages, instead of staying within my site’s template.

I need to find a way to make my script modular so everything renders as intended. Here’s my content function:

[php]

function content(){

// DETERMINE which page ID to USE in our query below ***************************************************
if (!isset($_GET['jesusid'])) {
	$pageid = '1';
	
} else {
	
$pageid = preg_replace('#[^0-9]#i', '', $_GET['jesusid']);} // filter everything but numbers for security)
//preg_replace($pattern, $replacement, $string);//preg_replace() Function structure

// Query the body section for the proper page
$query = mysql_query ("SELECT body_text,title,linklabel, author FROM content WHERE id = '$pageid' LIMIT 1 ") or die (mysql_error());  

while ($row = mysql_fetch_array($query)) {
echo ucwords($row[‘title’]).’ por ';
echo ‘’.$row[‘author’]. ‘
’;

    echo ucwords($row['body_text']);

//Add Bible Script
if (ucwords($row[‘title’])==‘Biblia’) //use row title – UPPERCASED word
{
include (‘bible/__WINDOWS/search.php’);
}

}
}

?>

[/php]

Just click on the BIBLE button, and then on any link within that page and you will see what I mean. I am still learning PHP and I don’t have any background integrating external scripts to an existing database. I hope someone can help me. Thanks in advance for your assistance.

OK, guys, I think I need to rephrase my question to clarify. I believe the issue I am facing is how to use PHP include();

This is what exactly happening:
I am working in my local machine using WAMP Server.

1) My main index.php file is located in: http://localhost/MARANATHA.tv/index.php
2) This is my folder hierarchy:
a) http://localhost/MARANATHA.tv/]index.php
b) http://localhost/MARANATHA.tv/_functions/functions.php
c) http://localhost/MARANATHA.tv/bible/search.php

functions.php is added as an include() in index.php, and it contains the code to include the search.php file include (‘bible/search.php’);

When I click on the BIBLE button, the right the content of search.php in rendered on the page. We are good up to here. However, when I click on any of the links in search.php, they are broken. For instance if I click on genesis, I am directed to http://localhost/MARANATHA.tv/readbible.php?version=kjv&book=Genesis, which is broken.

What’s happening, in this case, is that PHP engine is looking at readbible.php as if this file is included in the main root folder (http://localhost/MARANATHA.tv/readbible.php), and not in the bible folder (http://localhost/MARANATHA.tv/bible/readbible.php) as is supposed to happen.

You can also see it online at maranatha.tv. I use jQUERY to render the contents pages. If you click BIBLE, you will only see maranatha.tv on the address bar and not martaha.tv/bible/search.php but thats fine. However if click on any of the links on BIBLE page, it will show the broken link as so: http://maranatha.tv/readbible.php?version=kjv&book=Genesis

In summary, I need understand how to use includes more properly. I hope this is a bit more clear. Thanks.

Can you not just prepend the links with “/bible/” ?

Thanks Smokey for your help. I am not sure if Append would work. From my little research, Append would basically open and file and write content to the end of the file.

Since all intent to do for the most part, is to open php file containing the script that query the database and keeping is current folder structure so no broken links are generated. Think of it as to calling this file from an iframe. The reason I don’t use iframe for this execution is because the script is pretty much a search form that renders different size content depending on the link clicked, and iframes are big pain to auto-adjust to content.

No sorry, what I meant was, the link that says href=“readbible.php” change that to say href="/bible/readbible.php"

That’s exactly the issue smokey… I can’t change it.

Everything points to the same directory. \bible\ but when I include() the search.php, it sort of bring it to the default root directory, thus breaking all other links.

Sponsor our Newsletter | Privacy Policy | Terms of Service