jeff5656 Posted January 20, 2010 Share Posted January 20, 2010 I am joining two tables so I can replace the value in table2 with the value in table 1, (fieldname is pod), but I get this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\mc\testbundle.php on line 15 $consultsq1 = "SELECT icu.mrn, icu.id_incr, bundle.pt_id, icu.pod as pod1, bundle.pod as pod2, bundle.vent_id FROM icu INNER JOIN bundle ON icu.id_incr = bundle.pt_id "; $result = mysql_query ($consultsq1) or die ("Invalid query: " . mysql_error ()); while ($row = mysql_fetch_assoc ($results)) { $pod= $row['pod1']; $mrn=$row['mrn']; $vent_id=$row['vent_id']; echo "pod mrn vent it is".$pod.",".$mrn.",".$vent_id."<br>"; $sql = "UPDATE bundle SET mrn = '$mrn', pod='$pod' WHERE vent_id = '$vent_id'"; if (isset($sql) && !empty($sql)) { $result = mysql_query($sql) or die ("Invalid querrry: " . mysql_error()); } } WHat I really want to do is search for all reords in bundle where the value of pod is blank, and then replace that blank value with the value of pod from the ICU table. Sorry if this is confusing. But I can;t even get the above simple code to even work... Quote Link to comment https://forums.phpfreaks.com/topic/189196-supplied-argument-is-not-a-valid-mysql-resul/ Share on other sites More sharing options...
wildteen88 Posted January 20, 2010 Share Posted January 20, 2010 Remove the s on this line while ($row = mysql_fetch_assoc ($results)) { You miss typed your variable. Should be $result not $results Quote Link to comment https://forums.phpfreaks.com/topic/189196-supplied-argument-is-not-a-valid-mysql-resul/#findComment-998847 Share on other sites More sharing options...
jeff5656 Posted January 20, 2010 Author Share Posted January 20, 2010 Thanks I removed the s. Now the first record is echoed and then the error comes up: pod mrn vent it is1,555,323 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\mc\testbundle.php on line 15 Quote Link to comment https://forums.phpfreaks.com/topic/189196-supplied-argument-is-not-a-valid-mysql-resul/#findComment-998850 Share on other sites More sharing options...
wildteen88 Posted January 20, 2010 Share Posted January 20, 2010 Remove $result = in this code block if (isset($sql) && !empty($sql)) { $result = mysql_query($sql) or die ("Invalid querrry: " . mysql_error()); }$result = mysql_query($sql) or die ("Invalid querrry: " . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/189196-supplied-argument-is-not-a-valid-mysql-resul/#findComment-998852 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.