| | |
update record error-mysql_numrows(): supplied argument is not a valid MySQL
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
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>
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>
just echo this line and execute that query on your database area
or post your table structure..
PHP Syntax (Toggle Plain Text)
$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..
•
•
Join Date: Apr 2008
Posts: 293
Reputation:
Solved Threads: 11
hi,
problem is here you have forget to write (_)
change it to
hope will help u..
problem is here you have forget to write (_)
PHP Syntax (Toggle Plain Text)
$num = mysql_numrows($result);
change it to
PHP Syntax (Toggle Plain Text)
$num = mysql_num_rows($result);
hope will help u..
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
hi,
problem is here you have forget to write (_)
PHP Syntax (Toggle Plain Text)
$num = mysql_numrows($result);
change it to
PHP Syntax (Toggle Plain Text)
$num = mysql_num_rows($result);
hope will help u..
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
•
•
Join Date: Apr 2008
Posts: 293
Reputation:
Solved Threads: 11
If you are not setting password then left blank or write your password
check what result you get..
PHP Syntax (Toggle Plain Text)
$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } else { // echo('Connected with Mysql'); } @mysql_select_db("service", $con); $id=$_GET['id']; echo $query = "SELECT * FROM contacts WHERE id = '$id'"; $result = mysql_query($query); echo "num of rows".$num = mysql_num_rows($result);
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
hi amith, i tried that too but still its telling the error.
•
•
•
•
hi,
problem is here you have forget to write (_)
PHP Syntax (Toggle Plain Text)
$num = mysql_numrows($result);
change it to
PHP Syntax (Toggle Plain Text)
$num = mysql_num_rows($result);
hope will help u..
•
•
Join Date: Apr 2008
Posts: 293
Reputation:
Solved Threads: 11
•
•
•
•
If you are not setting password then left blank or write your password
check what result you get..PHP Syntax (Toggle Plain Text)
$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } else { // echo('Connected with Mysql'); } @mysql_select_db("service", $con); $id=$_GET['id']; echo $query = "SELECT * FROM contacts WHERE id = '$id'"; $result = mysql_query($query); echo "num of rows".$num = mysql_num_rows($result);
You most likely have a problem with your query.
Replace:
with
This will show the error.
Replace:
PHP Syntax (Toggle Plain Text)
$result = mysql_query($query);
PHP Syntax (Toggle Plain Text)
$result = mysql_query($query) or die(mysql_error());
Last edited by kkeith29; May 7th, 2009 at 9:26 am.
![]() |
Other Threads in the PHP Forum
- Previous Thread: PHP to parse at | and at ^
- Next Thread: session logged out time
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube






