$sql = "SELECT temail FROM teacherusers WHERE tfullname='$teachername' limit 1";
$result = mysql_query($sql);
$value = mysql_fetch_object($result);
$teacheremail2 = $value->temail;
echo $teacheremail2;
echo $teacheremail2
不返回任何内容。
$teachername
有效,并且我已多次检查。
答案 0 :(得分:0)
它应该是一个二维数组,您需要
$value[0]->temail
答案 1 :(得分:0)
mysql_fetch_object($result)
的结果是一个对象(stdClass)。
对此link
可以找到关于object(stdClass)
的解释
$sql = "SELECT temail FROM teacherusers WHERE tfullname='$teachername' limit 1";
$result = mysql_query($sql);
while ($value = mysql_fetch_object($result))
{
$teacheremail2 = $value->temail;
echo $teacheremail2;
}
答案 2 :(得分:-1)
首先,您将要直接对数据库运行查询,以确保查询返回某种结果。 其次,如果可行,您将希望直接回显$ value以检查是否在网页上获得了结果。
然后您可以检查temail是否为$ value字段
答案 3 :(得分:-2)
$sql = "SELECT temail FROM teacherusers WHERE tfullname='$teachername' limit 1";
$result = mysql_query($sql);
while ($value = mysql_fetch_object($result))
{
$teacheremail2 = $value->temail;
echo $teacheremail2;
}
希望获得帮助