Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:56:27+00:00 2026-06-11T11:56:27+00:00

i am having a problem, i am receiving an error which says undefined variable

  • 0

i am having a problem, i am receiving an error which says undefined variable although it was already defined, here is the snippet:

names.php

session_start();
$uname=$_SESSION['login'];

$host="localhost";
$username="root";
$password="";
$db_name="sampledb";
$tbl_name="tblsched";
$cd = date("F d");
$cd1 = date("Y-n-d");
$ctr = 0;

// retrieving values from cookies that were created is located before this function
function mymainfunc()
{
dateto();
datefrom();
sunday();
monday();
tuesday();
thursday();
wednesday();
friday();
satday();
$arrayto = array();
$arrayfrom = array();
$arraysu=array();
$arraysa=array();
$arraym=array();
$arraytu=array();
$arrayw=array();
$arrayth=array();
$arrayf=array();

$arrayto = dateto();
$arrayfrom = datefrom();
$arraysu=sunday();
$arraysa=satday();
$arraym=monday();
$arraytu=tuesday();
$arrayw=wednesday();
$arrayth=thursday();
$arrayf=friday();

for($x=0;$x<=count($arrayto);$x++)
{
echo "<tr>";
echo "<td align=$tdali bgcolor=$bgcolor>"+ $arrayfrom[x] + "-" + $arrayto[x] + "</td>";
echo "<td align=$tdali>" + $arraysu[x] + "</td>";
echo "<td align=$tdali>" + $arraym[x] + "</td>";
echo "<td align=$tdali>" + $arraytu[x] + "</td>";
echo "<td align=$tdali>" + $arrayw[x] + "</td>";
echo "<td align=$tdali>" + $arrayth[x] + "</td>";
echo "<td align=$tdali>" + $arrayf[x] + "</td>";
echo "<td align=$tdali>" + $arraysa[x] + "</td>"; 
echo "</tr>";
}
}

//the other functions are found before this function
function dateto()
{
$sql="SELECT SchedTimeTo FROM $tbl_name WHERE teacherID=(SELECT teacherID FROM tblteacher WHERE teacherName=$uname) AND SchedDateFrom<=$cd1 AND SchedDateTo>=$cd1";
$result=mysql_query($sql);

$count=mysql_num_rows($result);
$row = mysql_fetch_array($result);

$STF = array();
$STF[] = $row;
return $STF;
}

displayhere.php

//i inserted this snippet inside the

<?php
include "names.php";
mymainfunc();
?>

any suggestions?? the other functions didn’t return any errors though

it says undefined variable tbl_name in the sql part of the function dateto()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:56:28+00:00Added an answer on June 11, 2026 at 11:56 am

    When calling globally defined variables you will need to make them accessible to the function by means of the globalkeyword:

    <?php
    $my_global_var = 42;
    
    function doSomethingImportant() {
        global $my_global_var;
    
        // now you can safely use that variable:
        if ($my_global_var == 42) {
            //...
        }
    }
    ?>
    

    alternatively (as explained by other answerers) you can use the $_GLOBALS['my_global_var']-array to acchieve the goal:

    <?php
    $_GLOBALS['my_global_var'] = 42;
    
    function doSomethingImportant() {
    
        // now you can safely use that variable:
        if ($_GLOBALS['my_global_var'] == 42) {
            //...
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a hard time figuring out what my problem is here. I'm receiving
I am having a problem with my code here. The error that I am
We're having the same setup and receiving the same problem as: IIS 6 with
I'm having a problem in my application with an EXC_BAD_ACCESS after receiving a memory
I'm having a problem with a web app I'm managing. Users starting receiving the
I am receiving an error that says The application was unable to start correctly
I am having some problem with cache registry. Here, how I configured cache resources.cache.frontEnd
having a problem getting my simple php email contact form working. No errors are
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
Im having problem in my UIscrollView ,this is what I have done: Whenever a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.