update record error-mysql_numrows(): supplied argument is not a valid MySQL

Reply

Join Date: May 2009
Posts: 4
Reputation: san_cash is an unknown quantity at this point 
Solved Threads: 0
san_cash san_cash is offline Offline
Newbie Poster

update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #1
May 6th, 2009
Hi!, I am trying to update record but an error is coming. Can any one help.
error is - mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\xampp\Test\Report\Despatch\update.php on line 10
here is the script

<?
$id=$_GET['id'];
$username="root";
$password="mysql";
$database="service";
mysql_connect(localhost,$username,$password);

$query = "SELECT * FROM contacts 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");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");

++$i;
}
?>


<form action="updated.php" method="post">
<input type="hidden" name="ud_id" value="<? echo $id; ?>">
First Name: <input type="text" name="ud_first" value="<? echo $first; ?>"><br>
Last Name: <input type="text" name="ud_last" value="<? echo $last; ?>"><br>
Phone Number: <input type="text" name="ud_phone" value="<? echo $phone; ?>"><br>
Mobile Number: <input type="text" name="ud_mobile" value="<? echo $mobile; ?>"><br>
Fax Number: <input type="text" name="ud_fax" value="<? echo $fax; ?>"><br>

<input type="Submit" value="Update">
</form>
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #2
May 6th, 2009
just echo this line and execute that query on your database area
  1. $query = "SELECT * FROM contacts WHERE id = '$id'";

or post your table structure..
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #3
May 6th, 2009
hi,
problem is here you have forget to write (_)
  1. $num = mysql_numrows($result);

change it to
  1. $num = mysql_num_rows($result);

hope will help u..
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #4
May 6th, 2009
ya exactly,, i even don't see this before..
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #5
May 6th, 2009
Originally Posted by Shanti Chepuru View Post
ya exactly,, i even don't see this before..
thanks..mark thread as solved
Last edited by Aamit; May 6th, 2009 at 3:53 am.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 4
Reputation: san_cash is an unknown quantity at this point 
Solved Threads: 0
san_cash san_cash is offline Offline
Newbie Poster

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #6
May 6th, 2009
Originally Posted by Aamit View Post
hi,
problem is here you have forget to write (_)
  1. $num = mysql_numrows($result);

change it to
  1. $num = mysql_num_rows($result);

hope will help u..
I tried but still the following errar is coming

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\xampp\Test\Report\Despatch\update.php on line 10
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #7
May 6th, 2009
If you are not setting password then left blank or write your password
  1. $con = mysql_connect("localhost","root","");
  2. if (!$con)
  3. {
  4. die('Could not connect: ' . mysql_error());
  5. }
  6. else
  7. {
  8. // echo('Connected with Mysql');
  9. }
  10. @mysql_select_db("service", $con);
  11.  
  12. $id=$_GET['id'];
  13. echo $query = "SELECT * FROM contacts WHERE id = '$id'";
  14. $result = mysql_query($query);
  15. echo "num of rows".$num = mysql_num_rows($result);
check what result you get..
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 4
Reputation: san_cash is an unknown quantity at this point 
Solved Threads: 0
san_cash san_cash is offline Offline
Newbie Poster

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #8
May 7th, 2009
hi amith, i tried that too but still its telling the error.

Originally Posted by Aamit View Post
hi,
problem is here you have forget to write (_)
  1. $num = mysql_numrows($result);

change it to
  1. $num = mysql_num_rows($result);

hope will help u..
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 293
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #9
May 7th, 2009
Originally Posted by Aamit View Post
If you are not setting password then left blank or write your password
  1. $con = mysql_connect("localhost","root","");
  2. if (!$con)
  3. {
  4. die('Could not connect: ' . mysql_error());
  5. }
  6. else
  7. {
  8. // echo('Connected with Mysql');
  9. }
  10. @mysql_select_db("service", $con);
  11.  
  12. $id=$_GET['id'];
  13. echo $query = "SELECT * FROM contacts WHERE id = '$id'";
  14. $result = mysql_query($query);
  15. echo "num of rows".$num = mysql_num_rows($result);
check what result you get..
please check the post and tell me the result...
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: update record error-mysql_numrows(): supplied argument is not a valid MySQL

 
0
  #10
May 7th, 2009
You most likely have a problem with your query.
Replace:
  1. $result = mysql_query($query);
with
  1. $result = mysql_query($query) or die(mysql_error());
This will show the error.
Last edited by kkeith29; May 7th, 2009 at 9:26 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC