0

Hello,

I am making an online gallery for a friend and have this (partially listed) folder structure.

root/index.php
root/inc/gallery.inc.php
root/inc/setup.inc.php
root/inc/includes.inc.php

Gallery.inc.php has various functions in it (Get image, album, etc), setup.inc.php has config variables (for my friend's ease of access, contains SQL stuff and date formats), here is what includes.inc.php looks like:

<?php
require "setup.inc.php";
require "gallery.inc.php";
?>

index.php has this code at the top:

<?php
include "inc/includes.inc.php";
?>

What I would like to do is use variables and functions FROM settings.inc.php IN gallery.inc.php.

I can access functions from settings.inc.php in gallery.inc.php but not variables...

No there is no "class ______" calls anywhere and therefore I see no problem with my code.

Any and all help is appreciated,

-- Turt2Live

3
Contributors
10
Replies
11
Views
5 Years
Discussion Span
Last Post by turt2live
Featured Replies
  • 1

    1) either you need to make all config variable global inside function. i.e. [CODE] function fname() { global $LOCATION; // now you can use $LOCATION } [/CODE] 2) or you can define in Setup.inc.php: [CODE]define('LOCATION', 'http://www.rest/of/address'); // now you can use LOCATION (without $ sign) in function file. [/CODE] Read More

0

Where is settings.inc.php in included?
In index.php OR includes.inc.php?
And what is the order of include coding?

0

Sorry, I didn't realize that,

settings.inc.php and setup.inc.php are the same file.

0

In my original post I said in the includes.inc.php file there was this line:

require "setup.inc.php";

But I went on to explain a "settings.inc.php".

Both of these files are the same file.

0

Can you post how your variable is defined in setup.inc.php and how did you used it in gallery.inc.php?

0

Setup.inc.php:

<?php
/* START USER CONFIG */
$SQL_HOST =			"localhost";
$SQL_USER = 		"*****";
$SQL_PASS = 		"*****";
$SQL_DATABASE =		"*****";

$DATE_FORMAT =		"d/M/Y H:i:s A";
$TIMEZONE = 		"America/Edmonton";

$LOCATION = 		"http://turt2live.com/newgallery";

/* END USER CONFIG */
?>

gallery.inc.php:
(This is partial code, the file is a wee bit long, but it is where I am getting issues.)

$q = mysql_query("SELECT * FROM `images` ORDER BY RAND() LIMIT ".$show);
if(mysql_num_rows($q) > 0){
	$ret = $ret . "<div>";
	while($a = mysql_fetch_array($q)){
		$img_src = 				$a['image_location'];
		$img_name = 			$a['image_title'];
		$img_thumb_src = 		create_thumbnail($img_src, "cache/image_temp_".$img_name.".png", true);
		$album_link = 			$LOCATION . "/album.php?name=".$a['album_name']."&username=".$a['username'];
		$album_name = 			$a['album_name'];
		$username = 			$a['username'];
		$ret = $ret . "<div class='imagecontainer'>";
		$ret = $ret . "<a href='".$img_src."' rel='lightbox-ALBUMNAME' title='".$img_name." (".$album_name.", by ".$username.")'><img src='".$img_thumb_src."'></a><br>";
		$ret = $ret . "<b>".$img_name."</b><br>";
		$ret = $ret . "(<a href='".$album_link."'>".$album_name."</a>)<br>";
		$ret = $ret . "By: <a href='".$LOCATION."/user/".$username."'>".$username."</a>";
		$ret = $ret . "</div>";
	}
	$ret = $ret . "</div>
}";

I am trying to use the $LOCATION variable.

Edited by turt2live: n/a

0

Is the code you have posted here for gallery.inc.php is in any function? Or it is outside? If its inside you need to make it global.
Generally i am always defining configuration variables.
e.g. define('SQL_HOST','localhost'); so that i can use it any where inside function.

Edited by vibhaJ: n/a

1

1) either you need to make all config variable global inside function.
i.e.

function fname()
{
    global $LOCATION;
// now you can use $LOCATION
}

2) or you can define in Setup.inc.php:

define('LOCATION', 'http://www.rest/of/address');
// now you can use LOCATION (without  $ sign) in function file.

Edited by vibhaJ: n/a

Votes + Comments
Amazing help
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.