Help - Search - Members - Calendar
Full Version: Inserting Php database code
Invision Power Services > Community Forums > Community Web Design and Coding
dalts
I have a very nice site called UKC-EVE which I have completely customised from a combination of Virtua News and links to IPB - it's great. I have worked out almost all the features and have become a fairly good programmer inserting new Javascrips, HTML and PHp pages into the IPB forum elements and added pages.

However, for some reason I can't work out how to add a simple piece of PhP code to the 'GLOBAL ELEMENTS' -->Navigation End' element (or any other element to be honest).

My code is simple - it looks like this ..

QUOTE
<?php

/* set's the variables for MySQL connection */

$server = "localhost";
$username = "********"; // removed for obvious reasons
$password = "*****"; // removed for obvious reasons

/* Connects to the MySQL server */

$link = @mysql_connect ($server, $username, $password)
or die (mysql_error());

/* Defines the Active Database for the Connection */

if (!@mysql_select_db("kdalton_sales", $link)) {
echo "<p>There has been an error. This is the error message:</p>";
echo "<p><strong>" . mysql_error() . "</strong></p>";
echo "Please Contact Your Systems Administrator with the details";
}

/* Passes a Query to the Active Database */

$result = mysql_query("SELECT * FROM minerals", $link);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}

/* Closes Connection to the MySQL server */

mysql_close ($link);
?>


This piece of code works fine as a PhP page on its own and is being used in other parts of the site - so I know it works. However, it will not work when embedded into an IPB element. I have even tried to use an 'include' command where this code sits in a seperate PhP file - but that doesn't work either.

1 million ISK to anyone who can solve this biggrin.gif
Michael P
I think you would have to add this as a module.

If you add it via the skin it wont work, and via the files well...it will always run unless its hidden behind a switch.
dalts
Ok - I figured out that you can't add PhP code to the 'elements' - so how do I make / add/ edit a module please?

I just realised I don't know as much as I thought I did w00t.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.