need help!!

Reply

Join Date: Feb 2008
Posts: 15
Reputation: niladri.user is an unknown quantity at this point 
Solved Threads: 0
niladri.user niladri.user is offline Offline
Newbie Poster

need help!!

 
0
  #1
Apr 11th, 2008
what is the problem with this code?

<body bgcolor="#FFFF00">
<div align="center">
<table width="284" border="4" cellspacing="2" cellpadding="2">
<tr>
<td width="92">cat_id</td>
<td width="79">cat_name</td>
<td width="79">choose product </td>
</tr>
<?php
$id=$_GET['id'];
$con=mysql_connect("localhost","root","");
mysql_select_db("niladri",$con);
$sql="SELECT * FROM `subcategory`whare `cat_id`=`$id`";
$res=mysql_query("$sql",$con);
while($row=mysql_fetch_array($res))
{
?>
<tr>
<td><?php echo $row[subcat_id];?></td>
<td><?php echo $row[subcat_name];?></td>
<td><a href="fetch3.php"?id=<?php echo $row[subcat_id]?>>click</a></td>
</tr>
<?php
}
?>
</table>
</div>
</body>

it is showing an warning--->

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\htdocs\Niladri's PHP Programs\PROJECT\fetch2.php on line 16

the previous page fetch1.php code is.....

<?php
ob_start();
session_start();
$sidf=session_id();
session_register('sidf');
?>
<body bgcolor="#FFFF00">
<div align="center">
<table width="284" border="4" cellspacing="2" cellpadding="2">
<tr>
<td width="92">cat_id</td>
<td width="79">cat_name</td>
<td width="79">choose subcategory </td>
</tr>
<?php

$con=mysql_connect("localhost","root","");
mysql_select_db("niladri",$con);
$sql="SELECT * FROM `category`";
$res=mysql_query("$sql",$con);
while($row=mysql_fetch_array($res))
{
?>
<tr>
<td><?php echo $row['cat_id'];?></td>
<td><?php echo $row['cat_name'];?></td>
<td><a href="fetch2.php"?id=<?php print $row['cat_id'];?>">click</a></td>
</tr>
<?php
}
?>
</table>
</div>
</body>

please send me a quick reply
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 145
Reputation: queenc is an unknown quantity at this point 
Solved Threads: 4
queenc's Avatar
queenc queenc is offline Offline
Junior Poster

Re: need help!!

 
0
  #2
Apr 11th, 2008
  1. $sql="SELECT * FROM `subcategory`where `cat_id`=`$id`";
  2. $res=mysql_query($sql);
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 145
Reputation: queenc is an unknown quantity at this point 
Solved Threads: 4
queenc's Avatar
queenc queenc is offline Offline
Junior Poster

Re: need help!!

 
0
  #3
Apr 11th, 2008
  1. mysql_select_db($dbid) or die("unable to connect");
  2. $sql="SELECT * FROM subcategory where cat_id='$id'";
  3. $res=mysql_query($sql);
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC