打开index.php时就出现Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\address3\index.php on line 31#这个错误,但看了下index.php下的31也找不出什么错来, $rows=mysql_num_rows($result);
把这些代码都贴出来,可能很长全部地址簿分为index.php modify_form.php update.php delete.php
content.php add_from.php add.php
include文件夹包含了day.inc head.inc tail.inc
图片文件夹就先不管了。
#index.php
<?php
session_start();
?>
<html>
<head>
<title>清风同学录</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style>
body { font-family: "verdana"; font-size:"9pt" };
p { }
table {font-size: 9pt }
td { font-family: "verdana"; font-size: "9pt"; line-height:"14pt"; letter-spacing="1pt" }
a:link {text-decoration: none ; color: blue}
a:visist {text-decoration:none; color:yellow}
a:hover {text-decoration:underline; color:green}
</style>
</head>
<body topmargin=3 bgcolor="#ffffff">
<div>
<center>
<?php
$connect=mysql_connect("localhost","root","123456");
mysql_select_db("mysite",$connect);
$query="SET NAMES 'gb2312'";
$result=mysql_query($query); //设置查询字符集,保证能够正确显示汉字 $query="select * from address";
$result=mysql_query($query); $rows=mysql_num_rows($result); include("include/head.inc");
?>
<table border="1" width=90% cellspacing=0 cellpadding=0 bgcolor="#e4e4e4" bordercolorlight="#c2c2c2" bordercolordark="#ffffff">
<tr>
<th width="10%" >姓 名</th>
<th width="25%" >地 址</th>
<th width="20%" >邮 箱</th>
<th width="10%" >O I C Q</th>
<th width="20%" >联系方式</th>
<th width="15%" >操 作</th>
</tr>
<?php
for ($i=0; $i<$rows;$i++)
{
mysql_data_seek($result,$i);
$data=mysql_fetch_array($result);
$id=$data['Id'];
$name=$data['Name'];
$address=$data['Address'];
$email=$data['Email'];
$oicq=$data['Oicq'];
$phone=$data['Phone']; echo "<tr>";
?>
<td width="10%" align="center"> <?php echo $name; ?> </td>
<td width="25%" align="center"> <?php echo $address; ?> </td>
<td width="20%" align="center"> <?php echo $email; ?> </td>
<td width="10%" align="center"> <?php echo $oicq; ?> </td>
<td width="20%" align="center"> <?php echo $phone; ?> </td>
<td width="15%" align="center">
<a href="content.php?id=<?php echo $id; session_register("{$id}"); ?>" > <img src="picture/content.gif" border="0" alt="详细内容" width="13" height="12"></a>
<a href="modify_form.php?id=<?php echo $id; session_register("{$id}"); ?>" > <img src="picture/modify.gif" border="0" alt="修 改" width="13" height="11"></a>
<a href="delete.php?id=<?php echo $id; session_register("{$id}"); ?>" > <img src="picture/delete.gif" border="0" alt="删除" width="13" height="11"></a>
</td>
</tr>
<?php
}
mysql_close($connect);
?>
</table>
</center>
</div>
<?php
include("include/tail.inc");
?>
</body>
</html>
把这些代码都贴出来,可能很长全部地址簿分为index.php modify_form.php update.php delete.php
content.php add_from.php add.php
include文件夹包含了day.inc head.inc tail.inc
图片文件夹就先不管了。
#index.php
<?php
session_start();
?>
<html>
<head>
<title>清风同学录</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style>
body { font-family: "verdana"; font-size:"9pt" };
p { }
table {font-size: 9pt }
td { font-family: "verdana"; font-size: "9pt"; line-height:"14pt"; letter-spacing="1pt" }
a:link {text-decoration: none ; color: blue}
a:visist {text-decoration:none; color:yellow}
a:hover {text-decoration:underline; color:green}
</style>
</head>
<body topmargin=3 bgcolor="#ffffff">
<div>
<center>
<?php
$connect=mysql_connect("localhost","root","123456");
mysql_select_db("mysite",$connect);
$query="SET NAMES 'gb2312'";
$result=mysql_query($query); //设置查询字符集,保证能够正确显示汉字 $query="select * from address";
$result=mysql_query($query); $rows=mysql_num_rows($result); include("include/head.inc");
?>
<table border="1" width=90% cellspacing=0 cellpadding=0 bgcolor="#e4e4e4" bordercolorlight="#c2c2c2" bordercolordark="#ffffff">
<tr>
<th width="10%" >姓 名</th>
<th width="25%" >地 址</th>
<th width="20%" >邮 箱</th>
<th width="10%" >O I C Q</th>
<th width="20%" >联系方式</th>
<th width="15%" >操 作</th>
</tr>
<?php
for ($i=0; $i<$rows;$i++)
{
mysql_data_seek($result,$i);
$data=mysql_fetch_array($result);
$id=$data['Id'];
$name=$data['Name'];
$address=$data['Address'];
$email=$data['Email'];
$oicq=$data['Oicq'];
$phone=$data['Phone']; echo "<tr>";
?>
<td width="10%" align="center"> <?php echo $name; ?> </td>
<td width="25%" align="center"> <?php echo $address; ?> </td>
<td width="20%" align="center"> <?php echo $email; ?> </td>
<td width="10%" align="center"> <?php echo $oicq; ?> </td>
<td width="20%" align="center"> <?php echo $phone; ?> </td>
<td width="15%" align="center">
<a href="content.php?id=<?php echo $id; session_register("{$id}"); ?>" > <img src="picture/content.gif" border="0" alt="详细内容" width="13" height="12"></a>
<a href="modify_form.php?id=<?php echo $id; session_register("{$id}"); ?>" > <img src="picture/modify.gif" border="0" alt="修 改" width="13" height="11"></a>
<a href="delete.php?id=<?php echo $id; session_register("{$id}"); ?>" > <img src="picture/delete.gif" border="0" alt="删除" width="13" height="11"></a>
</td>
</tr>
<?php
}
mysql_close($connect);
?>
</table>
</center>
</div>
<?php
include("include/tail.inc");
?>
</body>
</html>
<?php
echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">";
echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\">"; $connect=mysql_connect("localhost","root","123456");
mysql_select_db("mysite",$connect);
$query="SET NAMES 'gb2312'";
$result= mysql_query($query);
$query="select * from mysite.address where Id='$id'";
$result=mysql_query($query);
mysql_data_seek($result,0);
$data=mysql_fetch_array($result); $path="d:/web/picture/".$_FILES['up_picture']['name'];
if($up_picture!="")
{ unlink($data['Picture']);
copy($up_picture,$path);
$picture=$path;
}
else
{
$picture="d:/web/picture/mypo.jpg";
} $query="update mysite.address set Name='$name' ,Favorate='$favorate',Address='$address',Email='$email',Word='$word',Oicq='$oicq',Phone='$phone',Picture='$picture'where Id='$id'";
$result=mysql_query($query);
mysql_close($connect);
?>
这句看出你的mysql_num_rows使用的不是有效资源。即该函数的参数有错误
if ($result)
{
$rows=mysql_num_rows($result);
}
我现在index.php的能正常运行,
可是没有其他部分的不好弄呀!!
我的email:[email protected]