Jump to content

[SOLVED] Help


sstangle73

Recommended Posts

on my site i have it do a query at the top of everypage with several other functions:

<?php
session_start(); 
include("database.php");
include("login.php");
include("func.php");
mait();
query($_SESSION['ID']);
PageTop($level, $ID, $username, $color);
?>

 

now later down the index i call for this

<?php 
if($logged_in){ 
    echo "Welcome " .  $name . "<br>"; 
    echo "Logged in as " . $username . "     ID Number: " . $ID . " <a href=\"logout.php\">logout</a><br>"; 
    echo "Your registered email is " .  $email . "<br>";
    echo "Your birthday is " . $bdate . "<br>";
    echo "You are " . $age . " years old <br>";
    echo "You are " . $sex . "<br>";
    echo "You live in " . $location . "<br>";
?>

 

for the age and location it comes up blank.

also on a different page $profile comes up blank

 

heres the query:

<?php
function query($ID){
$query="SELECT * FROM users WHERE ID = '$ID' LIMIT 1"; 
$result=mysql_query($query); 
while($array=mysql_fetch_assoc($result)){
$level=$array['level'];
$ID=$array['ID'];
$user=$array['username'];
$name=$array['name'];
$dname=$array['dname'];
$email=$array['email'];
$bdate=$array['bdate'];

$sex=$array['sex'];
$city=$array['city'];
$state=$array['state'];

$schedule=$array['schedule'];
$color=$array['color'];
$quote=$array['quote'];
}
$age=birthday($bdate);
$location="" . $city . ", " . $state . "";
$query2="SELECT * FROM profile WHERE ID = '$ID' LIMIT 1"; 
$result2 = mysql_query($query2);
while($array2=mysql_fetch_assoc($result2)){
$about=$array2['about'];
}
}
?>

 

thanks!

Link to comment
Share on other sites

You either need to make all those variables within your function global (the bad way). Or return an array with all the data you want, then use that later in your page.

 

Variables contained within a function are not accessable outside the functions scope by default.

Link to comment
Share on other sites

can $_SESSION['about'] be called by $about?

only if register_globals is enabled. register_globals is now depreciated and is disabled by default as it can cause security exploits within your code. However some hosts do still keep this setting enabled for compatibility reasons for older (outdated) scripts.

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.