Jump to content

Integrate Third Party Script - Make PHP Modular


jj-dr

Recommended Posts

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 comes 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. I just don't know if this the right way to do it.

 

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 script's 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 CONTENT page template.

 

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

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 '<b>'.$row['author']. '</b><br>';
        echo ucwords($row['body_text']);

//Add Bible Script
if (ucwords($row['title'])=='Biblia') //use row title -- UPPERCASED word
   {
     include ('bible/__WINDOWS/search.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 third party scripts to an existing PHP website. I hope someone can help me.

 

Thanks in advance for your assistance.

Link to comment
Share on other sites

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 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 engineis 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.

 

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

Link to comment
Share on other sites

One last thing, 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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.