...

View Full Version : undefined constant



ooiyh
08-29-2006, 06:12 PM
Does anybody know of this error?
What is the solution to this?


Notice: Use of undefined constant:confused:


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

Mwnciau
08-29-2006, 06:17 PM
Is membercode meant to be a variable? If so make sure there is a $ before it.

ooiyh
08-29-2006, 08:43 PM
This is my 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);

GJay
08-29-2006, 09:17 PM
array keys should be strings, not constants:
i.e.


$array['key']=$something;

not


$array[key]=$something

ooiyh
08-30-2006, 04:54 PM
Could anybody tell me what is wrong with this?
I get the same problem with this code.


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

GJay
08-30-2006, 07:35 PM
take a look at either 'empty' or 'isset'
http://php.net/empty
http://php.net/isset



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum