I posted this once but no one is stopping by so maybe the title didn't sound much interesting.

I got the code for a google search bar and pasted it on the corresponding <div id and made a separate file for the search results and worked perfectly.

But when I tried to put the search bar code in a php file and include it in my pages <?php include("php/google_search_bar.php"); ?> it does not show the search bar. It shows only the word "Loading" which is found here:

<div id="cse-search-form" style="width: 100%;">Loading</div>
<script src="../../Documents/jsapi" type="text/javascript"></script>... etc.

but the input box and search button are not loaded in the webpage.

**Note that the code itself it's correct because if I copy and paste it back directly into the <div id="searchbar.php"> the whole search bar re-appears and fully functional.

google_search_bar.php only contains the source code provided by google when the search bar was created. Do I need to add any more code so it shows up at <?php include("php/google_search_bar.php"); ?> ?

Thank you for your help!

means the program has not found the javascript to replace the innertext of the div
likely causes

wrong filename the script is unlikely to be called jsapi, more often jsapi.js

the path is wrong ../../Documents is not the path to the script from the file that is including, try absolute references <script src='http://yoursite/documents/jsapi.js'> or <script src='<?php echo $_SERVER['DOCUMENT_ROOT'].'/documents/jsapi.js'; ?>' type='text/javascript'>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.