注意未定义的常量假定MySql


notice undefined constant assumed MySql

这是我的代码,只是工作得很好,但在我的新迷你康柏笔记本电脑安装新的wamp服务器后?我得到错误:

$sno=mysql_result($result,$m,"sno");
$name=mysql_resul($result,$m,"name");
$location=mysql_result($result,$m,"location");
$sector=mysql_result($result,$m,"sector");
$status=mysql_result($result,$m,"status");*/?>
<table width="320" border="0"cellspacing="0">
  <tr>
    <strong>   <td width="194"><strong><span class="style16"><font face="Lucida Console, Lucida Sans Unicode">PV NO:</font></span></strong></td>
    <td width="110" nowrap><span class="style16"><strong><?PHP echo "$_POST[pvno]";?></strong></span></td></strong>  </tr>
  <tr>
    <td width="194"><span class="style16"><strong><font face="Lucida Console, Lucida Sans Unicode">SNO</font></strong></span></td>
    <td width="110" nowrap><span class="style16"><?PHP echo ''.$sno.''; ?></span></td>
  </tr>
  <tr>
    <td><span class="style16"><strong><font face="Lucida Console, Lucida Sans Unicode">PROJECT NAME </font></strong></span></td>
    <td nowrap><span class="style16"><strong><?PHP echo $name;?></strong></span></td>
  </tr>
  <tr>
    <td><span class="style16"><strong>SECTOR</strong></span></td>
    <td nowrap><span class="style16"><?PHP echo $sector;?></span></td>
  </tr>
  <tr>
    <td><span class="style16"><strong>CONTRACTOR</strong></span></td>
    <td nowrap><span class="style16"><?PHP echo $contractor;?></span></td>
  </tr>
    <tr>
    <td><span class="style16"><strong>CONTACTS</strong></span></td>
    <td nowrap><span class="style16"><?PHP echo $contact;?></span></td>
  </tr>
  <tr>
    <td><span class="style16"><strong>LOCATION</strong></span></td>
    <td nowrap><span class="style16"><?PHP echo $location;?></span></td>
  </tr>
  <tr>
    <td><span class="style16"><strong>STATUS</strong></span></td>
    <td nowrap><span class="style16"><?PHP echo $status; ?></span></td>
  </tr>
</table>
我得到的输出错误是:
PV NO:  AGRI008
SNO     
Notice: Undefined variable: sno in C:'wamp'www'cdf'new pro'pvsearch.php on line 162
PROJECT NAME    
Notice: Undefined variable: name in C:'wamp'www'cdf'new pro'pvsearch.php on line 166
SECTOR  
Notice: Undefined variable: sector in C:'wamp'www'cdf'new pro'pvsearch.php on line 170
CONTRACTOR  
Notice: Undefined variable: contractor in C:'wamp'www'cdf'new pro'pvsearch.php on line 174
CONTACTS    
Notice: Undefined variable: contact in C:'wamp'www'cdf'new pro'pvsearch.php on line 178
LOCATION    
Notice: Undefined variable: location in C:'wamp'www'cdf'new pro'pvsearch.php on line 182
STATUS  
Notice: Undefined variable: status in C:'wamp'www'cdf'new pro'pvsearch.php on line 186

如有任何帮助,请在这里输入代码

<?PHP echo "$_POST[pvno]";?>

pvno不在引号内,因此它被视为常量,但常量不存在(这正是通知试图告诉你的)

用这个代替

<?PHP echo $_POST['pvno'];?>

变量没有必要用双引号。

另外

<?PHP echo ''.$sno.''; ?>

引号对

没用
<?PHP echo $sno; ?>

在你的代码中,我看到);*/?>,这意味着在顶部的整个php块被注释掉,所以没有变量输出(因为它们从未初始化)

看起来代码被注释掉了,所以它将被忽略。使用一个语法高亮的编辑器,这将使你更容易阅读源代码,并找到被注释掉的代码片段。

见这一行:

$status=myslq_result($result,$m,"status");*/?>
                                          ^^ end of a multi-line comment

关于未定义变量的警告只是表示该变量到目前为止还没有初始化。