Jump to content


Photo

error message HELP


  • Please log in to reply
2 replies to this topic

#1 Meza44

Meza44
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 06 October 2006 - 08:51 AM

I get this error message from my code and I don't know why.  I am new to php.

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/content/i/b/e/ibezamn/html/change.php on line 15



<html>
<head><title>Ibezamn - Update</title>
</head>

<?

$id=$_GET['id'];

include("capsroster.inc.php");

mysql_connect(localhost,$username,$password);

$query="SELECT * FROM roster WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while($i<$num) {
$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$number=mysql_result($result,$i,"number");
$position=mysql_result($result,$i,"position");
$height=mysql_result($result,$i,"height");
$weight=mysql_result($result,$i,"weight");
$shoots=mysql_result($result,$i,"shoots");
$dob=mysql_result($result,$i,"dob");
?>


<form action="update.php" method="get">
<input type="hidden" name="ud_id" value="<? echo $id; ?>"><br>
First:<input type="text" name="ud_first" value="<? echo $first; ?>"><br>
Last:<input type="hidden" name="ud_last" value="<? echo $last; ?>"><br>
Number:<input type="hidden" name="ud_number" value="<? echo $number; ?>"><br>
Height:<input type="hidden" name="ud_height" value="<? echo $height; ?>"><br>
Weight:<input type="hidden" name="ud_weight" value="<? echo $weight; ?>"><br>
Shoots:<input type="hidden" name="ud_shoots" value="<? echo $shoots; ?>"><br>
DOB:<input type="hidden" name="ud_dob" value="<? echo $dob; ?>"><br>
<input type="submit" value='Update">
</form>
<?

++$i;
}

?>

</body>
</html>

#2 thedarkwinter

thedarkwinter
  • Members
  • PipPipPip
  • Advanced Member
  • 191 posts
  • LocationLondon

Posted 06 October 2006 - 09:06 AM

Hi, ylou probably justy need to select the database

mysql_connect(localhost,$username,$password);
mysql_select_db("mydbname");
$query="SELECT * FROM roster WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

cheers,
tdw
Remember - if you don't figure it out yourself, you'll probably forget it tomorrow :)

#3 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 06 October 2006 - 09:07 AM

also add this after you query and see if there are any errors

$result=mysql_query($query) or die(mysql_error());




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users