Ugat Posted March 23, 2010 Share Posted March 23, 2010 Hi Guys, Can I ask question regarding mysql fetch function doenst not working I received this kind of error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Auction\Virtuosity(Online Auction)\admin\changetree.php5 on line 14 Here is my code: <?php session_start(); include 'config.php5'; $i=$_POST['i']; $mid = $_SESSION["id"]; $str=""; $str.='<ul id="browser" class="filetree">'; $qry="select c.CategoryId,c.CategoryName,count(i.Name) from categories c left join items i using(CategoryID) group by c.CategoryId,c.CategoryName"; $rs=mysql_query($qry); while($row=mysql_fetch_row($rs)) { if($i==2) { $qry="select i.ItemID,i.Name from items i where i.CategoryId=" . $row[0] . " and i.CustomerId=" . $mid; } else $qry="select i.ItemID,i.Name from items i where i.CategoryId=" . $row[0]; $str.='<li class="closed"><span class="folder">'. $row[1] . '</span><ul>'; $rss=mysql_query($qry); $n=mysql_num_rows($rss); for($count=0;$count<$n;$count++) { $rows=mysql_fetch_row($rss); $str.='<li><span class="file"><a class="flink" href="javascript:showprod(' . $rows[0] .')">' . $rows[1] . '</a><input type="hidden" id="c' . $rows[0] .'" value="' . $row[0] . '"></input></span></li>'; } if(isset($_SESSION['id'])) $str.='<li><span class="file"><a href="javascript:insertprod(' . $row[0] . ')" class="flink">Add Product</a></span></li> '; $str.=' </ul></li>'; } $str.="</ul>"; echo $str; ?> Is there something wrong. Thanks and Regards Link to comment https://forums.phpfreaks.com/topic/196198-mysql-fetch-problem/ Share on other sites More sharing options...
o3d Posted March 23, 2010 Share Posted March 23, 2010 You will first have to connect to the database server and database. Then you can run queries on that db. Link to comment https://forums.phpfreaks.com/topic/196198-mysql-fetch-problem/#findComment-1030326 Share on other sites More sharing options...
Rustywolf Posted March 23, 2010 Share Posted March 23, 2010 try using mysql_fetch_assoc (1 output, i think) or mysql_fetch_array (Multiple outputs) Link to comment https://forums.phpfreaks.com/topic/196198-mysql-fetch-problem/#findComment-1030332 Share on other sites More sharing options...
The Little Guy Posted March 23, 2010 Share Posted March 23, 2010 I don't think using is correct, maybe it is, I just have never used it then... categories c left join items i using(CategoryID) to: categories c left join items i on(c.CategoryID = i.Category) Link to comment https://forums.phpfreaks.com/topic/196198-mysql-fetch-problem/#findComment-1030334 Share on other sites More sharing options...
Ugat Posted March 23, 2010 Author Share Posted March 23, 2010 Still I cannot solved this problem. I used mysql_fetch_assoc and mysql_fetch_array. Link to comment https://forums.phpfreaks.com/topic/196198-mysql-fetch-problem/#findComment-1030341 Share on other sites More sharing options...
The Little Guy Posted March 23, 2010 Share Posted March 23, 2010 Try this: $rs=mysql_query($qry)or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/196198-mysql-fetch-problem/#findComment-1030342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.