-5

While updating i want to select the value of route from the another table when i try to do this it showing Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result

This is my code:

<?php
$dbHost = 'localhost'; // usually localhost
$dbUsername = 'xxxxxxx';
$dbPassword = 'xxxxxxxxxx';
$dbDatabase = 'fms';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword) or die ("Unable to connect to Database Server.");
mysql_select_db ($dbDatabase, $db) or die ("Could not select database.");

$client_id=$_POST['clientid'];
$feild=$_POST['field'];
        $data= $_POST['value'];
        $rownum=$_POST['rowid'];  
        $sql="UPDATE $client_id SET ".$feild." = '".$data."' WHERE net_id = ".$rownum."";

         print $sql;

        mysql_query($sql);  


//Select route from client Table

$sql_select="select route from $client_id WHERE net_id = ".$rownum."";
mysql_query($sql_select);
 print $sql_select;
 print mysql_error();
$i=1;
while($rows=mysql_fetch_assoc($sql_select))
{

    $route=$rows['route'];

}

?>

Please help me, thank in advance

Xavi
  • 2,552
  • 7
  • 40
  • 59
  • $result = mysql_query($sql_select); $rows = mysql_fetch_assoc($result); see url : http://us1.php.net/mysql_fetch_assoc – Dipak Yadav Nov 19 '13 at 06:23

2 Answers2

1

write like this:

$sql_select="select route from $client_id WHERE net_id = ".$rownum."";
$queryRes = mysql_query($sql_select);
 print $sql_select;
 print mysql_error();
$i=1;
while($rows=mysql_fetch_assoc($queryRes))

You need to provide #Resource returned from mysql_query() function to mysql_fetch_assoc().

Note: Mysql_* are deprecated from PHP5.3. Hence should be avoided.

Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90
1

try this

$sql_select="select route from $client_id WHERE net_id = ".$rownum."";
$result = mysql_query($sql_select);
 print $result;
 print mysql_error();
$i=1;
while($rows=mysql_fetch_assoc($result))
{

    $route=$rows['route'];

}
Muhammad Rashid
  • 563
  • 1
  • 6
  • 25