Unexpected Error - Undefined variable???

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Unexpected Error - Undefined variable???

Propeng
Is this script correct?

index.php:
CODE
<?php
    if (isset($_COOKIE["disp_name"]))
          $_GET['name'] = $_COOKIE['disp_name'];
    else
        setcookie("disp_name", Anonymous, date()+99);
?>
<html>
    <head>
        <title>Display Name - DZN</title>
        <!-- METAS -->
        <meta name="verify-v1" content="oyEmG+TJ87xHGXl8NQS6GHJ8rcRDkFG4oXnYWtqddGk=" />
    </head>
    <body>
        <div align="center">
            <form action="proccess.php" method="get">
                <?php if ($_GET["name"]=="") {$_GET['name']="Anonymous";} ?>
                Dislpay Name: <input type="text" value=<?php echo $_GET['name']; ?> name="name" />
                <input type="submit" value="Enter Website!" />
            </form>
        </div>
        <?php $wn = "Download Zone Network"; $swn = "DZN"; ?>
    </body>
</html>


proccess.php:
CODE
<head>
    <title>Proccessing Request...</title>
    <meta http-equiv="Refresh" content="1; URL=main.php" />
    <b>Please wait...</b>
</head>
<?php
    setcookie("disp_name", $_GET['name'], date()+99);
?>


main.php:
CODE
<?php
    function customError($errno, $errstr)
    {
        echo "<div align='center'><b>Error:</b> [$errno] $errstr<br /></div>";
        echo "<div align='center'>Ending Script</div>";
        die();
    }
?>
<?php //Page Config.
    //REQUIRE
      $_GET['name'] = $_COOKIE['disp_name'];
      /* do: echo (remember) */
      //          echo $_GET['name']          //
      if ($_COOKIE['disp_name']=="")
      {
        $_GET['name'] = "Guest";
    }
    function currentlyOnline()
    {
        echo "";
    }
    set_error_handler("customError");
    function showCO ($showCO)
    {
        echo "ddd";
    }
    while ($showCO=="true")
    {
        showCO();
    }
?>
<?php
    echo "<title>Welcome back, " . $_GET['name'] . "! - DZN</title>";
    showCO ($showCO);
    $showCO = "true";
?>
(Not all the file; just the piece that encounters the problem)

Everything goes fine, but when i enter main.php, it displays:
QUOTE
Error: [8]Undefined variable: showCO
Ending Script


Is this script wrong? If it has, please reply. I know that the problem is in the main.php only, but i copied all of them if you want to test it.

 

 

 


Reply

TavoxPeru
QUOTE(Propeng @ Sep 29 2007, 04:15 AM) *
main.php:
CODE
<?php
    function customError($errno, $errstr)
    {
        echo "<div align='center'><b>Error:</b> [$errno] $errstr<br /></div>";
        echo "<div align='center'>Ending Script</div>";
        die();
    }
?>
(Not all the file; just the piece that encounters the problem)

Everything goes fine, but when i enter main.php, it displays:
Is this script wrong? If it has, please reply. I know that the problem is in the main.php only, but i copied all of them if you want to test it.

I think that the problem is related with the brackets that you use in your customError() function. Try this:
CODE
<?php
    function customError($errno, $errstr)
    {
        echo "<div align='center'><b>Error:</b> [" . $errno . "] $errstr<br /></div>";
        echo "<div align='center'>Ending Script</div>";
        die();
    }
?>

Best regards,

 

 

 


Reply

robert2411
put this error_reporting(E_ALL); abover you main script directly after <?php

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. unexpected error - 20.34 hr back. (1)
Similar Topics

Keywords : unexpected, error, undefined, variable,

  1. Php Configuration Error?
    (6)
  2. Permanent Variable
    (7)
    hey all... i need help with something.. . i need to save a variable during login variable is users
    Username i have login.php which leads to checklogin.php to check for username/password which finnaly
    leads to login_success.php... every of those include config.php i had in mind to save that variable
    in config.php.... i tried that by setting CODE $action='a'; for the first line in
    checklogin.php and including config.php after that to save that username with CODE
    if($action=='a') $uu=$_POST ; i could echo username on the login_success.php pag....
  3. Cant Find The Error
    (2)
    In this code I want to retrieve the energy and max energy of a players account, then add 8% to
    energy of maxenergy, hen if energy is bigger than maxenergy, energy is then made equal to maxenergy.
    Then the database is updated. I don't understand why it's not working.
    $query=mysql_query("SELECT MAX(id) as maxid FROM `accounts` LIMIT 1"); $row =
    mysql_fetch_assoc($query); $id = $row ; $query = "SELECT * FROM `accounts`";
    $result=mysql_query($query); while ($row=mysql_fetch_assoc($result)) { $energy = $row ; $maxenergy
    = $row ; } for($i=1; $i $query = "SELECT....
  4. Php Error-where To Put "?>"
    (2)
    lol....lately i have many problems in writing my scripts and i dont know if i should create post
    only for purpose so ppl can help me or should i create many post like i am doing right now...i am
    NOT making this to get many credits...i am doing it because i need help and many people here help
    me! CODE if ($_GET !='race'){ Who do you wanna race?           Derbi Senda 50
         Honda NS 50 R      Suzuki ZR 50      Yamaha DT 50 MX      Aprilia RS 50      - ?        
    } i have this code...if i put after it i get QUOTE Parse error: syntax....
  5. Warning: Mysql_num_rows()
    What is the error :S (1)
    Hey! I've made a register script.. Some time ago it worked. And I ain't sure if I changed
    something since then.. The error I am getting is this: Warning: mysql_num_rows(): supplied argument
    is not a valid MySQL result resource in /home/feelay/public_html/regcheck.php on line 31 Here is
    the code on theese lines: CODE $sqlCheckForDuplicate = "SELECT username FROM user WHERE username
    = '". $username ."'";                 if( mysql_num_rows( mysql_query(
    $sqlCheckForDuplicate ) ) == 0 )         {             $sqlRegUser =     "INSERT INTO            ....
  6. Send Php Variable To Javascript
    (5)
    Right i had a look across the internet as well as a search on here but you cannot search for
    anything less than 3 characters. But this is a really quick question. Would the following code
    allow me to send a php variable to a javascript? CODE $color = "green"; ?> BackColor= " ";
    ....
  7. Php Math Error
    (4)
    I cant get php to do simple math. Anyway
    I need to run a math problem from the mysql database (dont ask why). So lets say I have an entrie: 5
    +5. I get it from my db then eval it but nothing happens? How could I make it so that it runs the 5+
    5 rather then just displaying it? Thanks, Sparkx Also: I have no clue if it is just my browser or
    what but my post breaks to boarder for some odd reason?....
  8. Something Wrong With This Script?
    Unexpected T_SRING (9)
    Here is the code that I have: CODE $con = mysql_connect("localhost","user","password"); if
    (!$con)   {die(' Could not connect: ' . mysql_error() . ' ');}
    mysql_select_db("database", $con); $ip=$_SERVER ; echo "Adding MXP info..."; mysql_query (INSERT
    INTO mxp (date, user, victim, turns, side, gold, lost, killed, mxp, points_b, points_a, type, power,
    ip) VALUES ('$_POST ','$_POST ','$_POST ','$_POST ','$_POST
    ','$_POST ','$_POST ','$_POST ','$_POST ','$_POST
    ','$_POST ....
  9. Php Any Variable In String.
    (1)
    OK well I am making a new php program and I am trying to add bbcode to it. Anyway I was going to
    replace each thing by it self, but that could cause errors. Anyway is there a way to make a variable
    be anything? Here is an example: CODE This is the bbcode: Hey In my php: $bbcode = array(" ");
    $html = array( " "); $topic_content = str_replace($bbcode, $html, $posted_bbcode); So I want $a
    to be any variable but the same variable as used before. Do you get what I am saying? It is a little
    confusing but basicly what is the best way to make bbcode? It may not even inv....
  10. Error On Submit Page
    (10)
    I am writing a new submit page for one of my sites and am doing a few things to stretch my
    experience. I am getting an error (naturally.) Here is part pf the page where the error might be:
    CODE //Check to see if the web page called itself     if (strtoupper($action) == "CHECK") {
            //The web page called itself, so run the error checking code         //Declare a variable to
    hold the error messages     $error = '';      // variable names:    name, cat, sub_cat, url,
    date, status, email, other, area_code, city          $name = $_POST ;     $cat = $_P....
  11. Quickly Create Form Variables
    simple form, variable creation, referer check, safe guard variables (5)
    The reason I wanted to share this is I've seen so many people do this with their forms when
    using PHP. CODE $username = $_POST ; $password = sha1($_POST ); $another_var = $_POST ; ...
    and so on, just imagine if you had a large number of form inputs, do you really want to create each
    and every variable name? Why people do this, is probably due to most of the examples I've seen
    on the web, that does not show an easier and much quicker way of doing it. Though my way might be
    much easier and quicker, it does introduce security concerns which I've tried....
  12. Variable From Line Further Then Current Line?
    (13)
    Hello, Is it in some way possible to load a variable that further then the current line in the
    script? I don't know if you know what i mean so I'll try to point it out in the script
    below. CODE 1 2      echo $var1; 3      # $var1 needs to be loaded from foo.php 4     # Lets
    say i want $var1 to be echoed in $var1 5       - - - -       bla bla bla 55      - - - -
    56      switch($_GET ) { 57          case "foo": 58              include("foo.php");
    59              #- - - - from foo.php - - - - 60                   $var1 = "what ever you want";
    61           ....
  13. Got A Wee Error - Can You Help?
    (13)
    I'm taking a PHP course at college and am working on an assignment. There's no database
    involved. I've declared my variables from a submit form on another page, and on the page
    I'm working on I'm trying to bring them up in a table. But my start-table command is
    outputting an error. Here's the code relating to where the error is: CODE //Get First
    Item     if (isset($_GET )) {                 $item_1_product = $_GET ;     } else {
            $item_1_product = ""; //Default value if data missing     }          if (isset($_GET ))
    {            ....
  14. E-mail List Error
    (4)
    I just coded this e-mail list, it works well for entering data into database, but if user leaves
    the field blank or adds an already exist e-mail it gives him the error message and stops loading the
    rest of the page. CODE // Connects to your Database mysql_connect("localhost", "my_username",
    "mypassword") or die(mysql_error()); mysql_select_db("Database name") or die(mysql_error()); //This
    code runs if the form has been submitted if (isset($_POST )) { //This makes sure they did not leave
    any fields blank if (!$_POST ) {die(' No e-mail added '); } ....
  15. How To Reset The Server Variable Php_auth_user
    (9)
    Hi, i'm developing a web application which obviously requires a log in/log out script that i
    just implementing but i dont know why the log out script dont work fine. The problem is related
    with the server variable $_SERVER which remains set even when in the log out script i unset it with
    the unset() function. Does someone knows how can i reset or clear the server variable $_SERVER ???
    Best regards, ....
  16. Help: $_post Variable For Options From Select Types?
    (6)
    I want to know if there is a way to get the variables in $_POST for the options (not just the
    selected ones, but the unselected ones as well) of a type. Objective: Creating an application for
    my school. Issue: I am successful in receiving all the variables from the forms except the ones
    added to the options of a type. Just wanted to know what is the variable to access the options of
    types. Here is what I am trying to do with it: View Page If the server is down or unable to
    load file, here is the script: CODE      Malden High School va....
  17. In Php, How To Not Display Mysql Connection Error?
    Don't want mysql_connect() message (4)
    In PHP, if the mysql database server cannot be connected, for example database server is handed or
    turned off, an error message will be displayed: Warning: mysql_connect(): Unknown MySQL Server Host
    "mysql.example.com" ... My question is how to not display this warning message? or can I customise
    the error message? if so, how? Thank you.....
  18. Php Variable Concatenation
    Something New I learned Today! :P (7)
    I was coding one of my php page today, when I realized that I had to add multiple values to a
    variable (now that I think of it, a solution with arrays is possible too). But, the problem is that
    I have to add them in different parts of the code, so the new line that defines the variable will
    cover up the previous one. I played around with the code, and I finally got this solution:
    $message = "test1"; $message .= "test2"; $message .= "test3"; echo $message; By adding a dot in
    front of the = sign, I could concatenate the previous value with the new one and put them i....
  19. Php Problem Error Message
    I'm working from a book (9)
    I get this error message when I try to view a small webpage. QUOTE Parse error: parse error,
    unexpected T_STRING, expecting ',' or ';' in
    /home/nilsc/public_html/bobs/processorder.php on line 27 Line 27 is in this php part: CODE
    echo ' Order processed. '; echo $tireqty. ' tires '; echo $oilqty. ' bottles
    of oil '; echo $sparkqty. ' spark plugs '; $totalqty = 0; $totalqty = $tireqty +
    $oilqty + $spakqty; echo 'Items ordered: ' .$totalqty.' ; $totalamount = 0.00;
    define('TIREPRICE....
  20. PHP paFileDB error
    an error relating to admin login (0)
    does any body know how to over come an error in paFileDB which says Warning: Cannot modify header
    information - headers already sent by (output started at
    /home/paltalkh/public_html/pafiledb/includes/mysql.php:86) in
    /home/paltalkh/public_html/pafiledb/includes/admin/login.php on line 36 Warning: Cannot modify
    header information - headers already sent by (output started at
    /home/paltalkh/public_html/pafiledb/includes/mysql.php:86) in
    /home/paltalkh/public_html/pafiledb/includes/admin/login.php on line 38 i have downloaded the php
    from phparena.net directly. Any hel....
  21. PHP paFileDB error
    an error relating to admin login. (2)
    does any body know how to over come an error in paFileDB which says Warning: Cannot modify header
    information - headers already sent by (output started at
    /home/paltalkh/public_html/pafiledb/includes/mysql.php:86) in
    /home/paltalkh/public_html/pafiledb/includes/admin/login.php on line 36 Warning: Cannot modify
    header information - headers already sent by (output started at
    /home/paltalkh/public_html/pafiledb/includes/mysql.php:86) in
    /home/paltalkh/public_html/pafiledb/includes/admin/login.php on line 38 i have downloaded the php
    from phparena.net directly. Any he....

    1. Looking for unexpected, error, undefined, variable,






*SIMILAR VIDEOS*
Searching Video's for unexpected, error, undefined, variable,
advertisement




Unexpected Error - Undefined variable???



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE