Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    undefined constant

    Does anybody know of this error?
    What is the solution to this?

    Notice: Use of undefined constant


    Notice: Use of undefined constant membercode - assumed 'membercode' in c:\inetpub\wwwroot\cyyamhub\library\sqlInsert.php on line 7

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Is membercode meant to be a variable? If so make sure there is a $ before it.

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is my code

    PHP Code:
    $con dbConnection();

    mysql_select_db("cyyamhub"$con);

        
    $membercode $_POST[membercode];
        
    $name $_POST[name];
        
    $userid $_POST[userid];
        
    $pwd $_POST[pwd];
        
    $repwd $_POST[repwd];
        
    $zone $_POST[zone];
        
    $position $_POST[position];
        

            if(
    $membercode == "")
                
    $errorMsg $errorMsg "MemberCode must be filled in<br>";

            if(
    $name == "")
                    
    $errorMsg $errorMsg "Name must be filled in<br>";
            
            if(
    $userid == "")
                
    $errorMsg $errorMsg "UserID must be filled in<br>";
            
            if(
    $pwd == "")
                
    $errorMsg $errorMsg "Email must be filled in.<br>";
                
            if(
    $repwd == "")
                
    $errorMsg $errorMsg "Email must be filled in.<br>";
                
            if(
    $pwd != $repwd)
                
    $errorMsg $errorMsg "Password not the same with your re-entered password<br>";

            if(
    $zone == "")
                
    $errorMsg $errorMsg "Zone must be Selected.<br>";
                
            if(
    $position == "")
                
    $errorMsg $errorMsg "Positon must be Selected.<br>";
                
            if(
    errorMsg != "")
            {
                
    $sql="INSERT INTO info (Name, userid,password)";
                
    $sql=$sql " VALUES ";
                
    $sql=$sql "('" $name "',";
                
    $sql=$sql "'" $userid "',";
                
    $sql=$sql "'" $pwd "')";
                
                if (!
    mysql_query($sql,$con))
                  {
                    die(
    'Error: ' mysql_error());
                  }
                
                
    $sql="INSERT INTO zonedetail (Name, zoneName, levelID)";
                
    $sql=$sql " VALUES ";
                
    $sql=$sql "('" $name "',";
                
    $sql=$sql "'" $zone "',";
                
    $sql=$sql "'" $position "')";
                
                if (!
    mysql_query($sql,$con))
                  {
                  die(
    'Error: ' mysql_error());
                  }
                echo 
    "1 record added";
            }
    mysql_close($con); 

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    array keys should be strings, not constants:
    i.e.
    PHP Code:
    $array['key']=$something
    not
    PHP Code:
    $array[key]=$something 

  • #5
    New Coder
    Join Date
    Apr 2005
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could anybody tell me what is wrong with this?
    I get the same problem with this code.

    PHP Code:
    <?php 
            
    if($_SESSION['err'] != "")
            {
                  echo 
    "<tr><td class='errortext'>" $_SESSION['err'] . "</td></tr>";
            }
        
    ?>

  • #6
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    take a look at either 'empty' or 'isset'
    http://php.net/empty
    http://php.net/isset


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •