|
-
Feb 11th, 2009, 01:14 PM
#1
Thread Starter
New Member
My SQL Error
HI All
The problem I have got is that I got a table displaying results and I need to insert a form that allows you to update the code, but its displaying the following error code:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in W:\www\Book\book_change_form.php on line 14. Its saying the error is with line 14 which I have highlighted, but read the forums and it doesnt necessarily refer to the room. Hope someone can help, many thanks
<html><head><title></title></head>
<body>
<?php
include("dbinfo.inc.php");
$comm=@mysql_connect(localhost,$username,$password);
$rs=@mysql_select_db($database) or die( "Unable to select database");
$id=$_POST['id'];
$sql="SELECT * FROM book WHERE Book_id='$id'";
//mysql_connect(localhost,$_POST['username'],$_POST['pass']);
$result=mysql_query($sql);
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {
$Title=mysql_result($result,$i,"Title");
$Cost=mysql_result($result,$i,"Cost");
$Stock=mysql_result($result,$i,"Stock");
?>
<table width="300" cellpadding="10" cellspacing="0" border="2">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="#ffcc99">
<h3>Edit and Submit</h3>
<form action="book_change_record.php" method="post">
<input type="hidden" name="username" value="<?php print $_POST['username']?>">
<input type="hidden" name="pass" value="
<?php print $_POST['pass']?>">
<input type="hidden" Book_id="ud Book_id" value="<? echo "$Book_id" ?>">
Title: <input type="text" Title="ud_Title" value="<? print "$Title"?>"><br>
Cost: <input type="text" Cost="ud_Cost" value="<? echo "$Cost"?>"><br>
Stock: <input type="text" Stock="ud_Stock" value="<? echo "$Stock"?>"><br>
<input type="Submit" value="Update">
</form>
</td></tr></table>
<?
++$i;
}
?>
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|