Jump to content

[SOLVED] calling a function inside of another function


iarp

Recommended Posts

Hey,

 

function links() {
$query = "SELECT config_value FROM " . TBL_CONFIG . " WHERE config_name='site_location'";
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo "/" .  $row['site_location'] . "/";
}

 

Website coding:

echo '<a href="' . links() . 'test.php">Test</a>';

 

The only outcome i get from that is // Test on the page itself.

 

Oops i forgot one part.

 

function login(){
echo '<a href="./index.php">Home</a><br />';
if (isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'logout.php')) {
	echo '<a href="./logout.php">Logout</a><br />
	<a href="./admin/profile.php">Profile</a><br />
	<a href="./admin/">Admin Panel</a><br />';
	if ($_SESSION['userlevel'] >= 9) {
		echo '<a href="/todo.php">To do list</a><br />		
			  <a href="./admin/view_users.php">View Users</a><br />'; 
	}
} else { //  Not logged in.
	echo ' <a href="register.php">Register</a><br />
<a href="' . links() . 'login.php">Login</a><br />
<a href="forgot_password.php">Forgot Password</a><br />
';
}
}

thats another function that also calls links() and it doesn't work eithor.

 

Um, your query is only returning the value for the 'config_value' column and then you are trying to reference the 'site_location' value. change the query to return the value you actually want to use.

 

<?php

function links() {
$query = "SELECT site_location FROM " . TBL_CONFIG . " WHERE config_name='site_location'";
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo "/" .  $row['site_location'] . "/";
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.