我实在不知道为什么$row就是没有东西,下面是我一个page的所有php代码,我个人怀疑问题是出在把session的值给了其他的变量,然后又用那么个变量去除当sql语句的被查找目标,但我觉得这似乎也没什么不妥啊。<?php
session_start();
?> <?php
$cNumber = $_SESSION['username'];//就是这里,我把session的值给了$cNumber
echo $_SESSION['username'];
?> <?php
include('connect.php');
$sql = "SELECT * FROM customers WHERE cNumber = '$cNumber'";
$result = mysql_query ( $sql );
if ( !$result ) {
echo "<script language=javascript>alert('sql error!');history.back();</script>";
$row = mysql_fetch_array ( $result );
}
?>
<div id="sample1" class="boxed">
<form action="updateend.php" method="post" enctype="multipart/form-data" >
<h2>Customer Number:
<label>
<?
echo $row['cNumber'];
echo "<input name=cNumber type=hidden id=cNumber style=width:100px value=$row[cNumber]>";
?>
</label>
</h2>
<h2>Name:
<label>
<?
echo " <input name=name type=text id=name style=width:100px value=$row[name]>";
echo $row['name'];
?>
</label>
</h2>
<h2>Gender:
<label>
<?
echo " <input name=gender type=text id=gender style=width:100px value=$row[gender]>";
?>
</label>
</h2>
<h2>Age:
<label>
<?
echo " <input name=age type=text id=age style=width:100px value=$row[age]>";
?>
</label>
</h2>
<h2>TelNo:
<label>
<?
echo " <input name=tel type=number id=tel style=width:100px value=$row[tel]>";
?>
</label>
</h2>
</form>以上说有要输出$row的部分全部都输出不出来。其他各方面因素全部查过基本没有问题,数据库也不存在问题。
我尝试这输出$cNumber的值,跟我预想的一样,为什么就是没东西呢
session_start();
?> <?php
$cNumber = $_SESSION['username'];//就是这里,我把session的值给了$cNumber
echo $_SESSION['username'];
?> <?php
include('connect.php');
$sql = "SELECT * FROM customers WHERE cNumber = '$cNumber'";
$result = mysql_query ( $sql );
if ( !$result ) {
echo "<script language=javascript>alert('sql error!');history.back();</script>";
$row = mysql_fetch_array ( $result );
}
?>
<div id="sample1" class="boxed">
<form action="updateend.php" method="post" enctype="multipart/form-data" >
<h2>Customer Number:
<label>
<?
echo $row['cNumber'];
echo "<input name=cNumber type=hidden id=cNumber style=width:100px value=$row[cNumber]>";
?>
</label>
</h2>
<h2>Name:
<label>
<?
echo " <input name=name type=text id=name style=width:100px value=$row[name]>";
echo $row['name'];
?>
</label>
</h2>
<h2>Gender:
<label>
<?
echo " <input name=gender type=text id=gender style=width:100px value=$row[gender]>";
?>
</label>
</h2>
<h2>Age:
<label>
<?
echo " <input name=age type=text id=age style=width:100px value=$row[age]>";
?>
</label>
</h2>
<h2>TelNo:
<label>
<?
echo " <input name=tel type=number id=tel style=width:100px value=$row[tel]>";
?>
</label>
</h2>
</form>以上说有要输出$row的部分全部都输出不出来。其他各方面因素全部查过基本没有问题,数据库也不存在问题。
我尝试这输出$cNumber的值,跟我预想的一样,为什么就是没东西呢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货