943,914 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1276
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 6th, 2009
0

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

Expand Post »
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>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
san_cash is offline Offline
10 posts
since May 2009
May 6th, 2009
0

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

just echo this line and execute that query on your database area
PHP Syntax (Toggle Plain Text)
  1. $query = "SELECT * FROM contacts WHERE id = '$id'";

or post your table structure..
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
May 6th, 2009
0

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

hi,
problem is here you have forget to write (_)
PHP Syntax (Toggle Plain Text)
  1. $num = mysql_numrows($result);

change it to
PHP Syntax (Toggle Plain Text)
  1. $num = mysql_num_rows($result);

hope will help u..
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
May 6th, 2009
0

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

ya exactly,, i even don't see this before..
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
May 6th, 2009
0

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

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.
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
May 6th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by Aamit ...
hi,
problem is here you have forget to write (_)
PHP Syntax (Toggle Plain Text)
  1. $num = mysql_numrows($result);

change it to
PHP Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
san_cash is offline Offline
10 posts
since May 2009
May 6th, 2009
0

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

If you are not setting password then left blank or write your password
PHP Syntax (Toggle Plain Text)
  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..
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
May 7th, 2009
0

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

hi amith, i tried that too but still its telling the error.

Click to Expand / Collapse  Quote originally posted by Aamit ...
hi,
problem is here you have forget to write (_)
PHP Syntax (Toggle Plain Text)
  1. $num = mysql_numrows($result);

change it to
PHP Syntax (Toggle Plain Text)
  1. $num = mysql_num_rows($result);

hope will help u..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
san_cash is offline Offline
10 posts
since May 2009
May 7th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by Aamit ...
If you are not setting password then left blank or write your password
PHP Syntax (Toggle Plain Text)
  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...
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
May 7th, 2009
0

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

You most likely have a problem with your query.
Replace:
PHP Syntax (Toggle Plain Text)
  1. $result = mysql_query($query);
with
PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP to parse at | and at ^
Next Thread in PHP Forum Timeline: session logged out time





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC