hi ,

PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Domains\eazygurus.com\wwwroot\courses.php on line 45

im getting this error please help me out from this. im attaching the php file and copying my database values........

Table structure for table `course`
--

CREATE TABLE `course` (
  `id` int(50) NOT NULL auto_increment,
  `course` varchar(50) NOT NULL,
  `subcourse` varchar(50) NOT NULL,
  `fee` int(50) NOT NULL,
  `content` varchar(1000) NOT NULL,
  `date` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=34 ;

--
-- Dumping data for table `course`
--

INSERT INTO `course` (`id`, `course`, `subcourse`, `fee`, `content`, `date`) VALUES
(24, 'java', 'dddddddddddsssssssss', 212121, '11111111111111111111111', '2008-08-29');

where is your mysql_connect ?

When you go to "courses.php" for the FIRST TIME, do you have a query after the .php ?

Something like:
.../courses.php?course=course_name&subcourse=something

// courses & subcourse values are mandatory as programmed with:
$course=$_GET['course']
$subcourse= $_GET['subcourse'];

this line should be like this:

$query=("select * from course where course='".$course."'") or die(mysql_error());

Hi Shanthi..
here the total code working properly...
the problem arises when i write where condition......
here

$course=$_GET['course'];

 $query=("select * from course where course='".$course."' ) or die(mysql_error());
while($result=mysql_fetch_array($query))
{

}

This is the part of the code where i m getting an error.
Error:mysql_fetch_array(); supplied arguement is not a valid mysql resource.

hello kishor..
echo this line and tel me wat u got:
echo $course=$_GET;
and also echo this statement:

echo $r="select * from course where course='".$course."'";

try this

echo $r="select * from course where course=$course;

hi shanthi,
when i echo$r= "select * from course where course='".$course."'";
i am getting the output as
select * from course where course="

more over in the echo $course=$_get;
doesn't print anything

so, you didn't get any data in $_GET;
tel me ,from where you are getting this variable..
or post needed code...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="description" content="Small Corporation" />
	<meta name="keywords" content="small, corporation" />
	<link rel="stylesheet" href="style.css" type="text/css" />
    <style type="text/css">
<!--
.style4 {color: #FFFFFF}

.style5 {color: #2D5181}
-->
    </style>
</head>
<body>

	<div id="contentcourse">
	  <div id="header"></div>
  <ul id="menu">
			<li><a class="current" href="index.php">Home</a></li>
			<li><a href="aboutus.php">About Us</a></li>
			<li><a href="courses.php">Courses</a></li>
			<li><a href="demo_registration.php">Demo Class Registration</a></li>
			<li><a href="faq.php">FAQ's</a></li>
			<li><a href="order.php">How To Order</a></li>
			<li><a href="payment.php">Payment Options</a></li>
			<li><a href="enquiry.php">Enquiry</a></li>
<li><a href="contact.php">Contact Us</a></li>
            
	  </ul>
		
	  <div id="course">
			<div id="title">
			  <h3>Sub Courses</h3>
			</div>
	<br/>
			  
	          <?php 
		include("config.php");
			$course=$_GET['course'];
	  $query=("select course,subcourse from course WHERE course=$course") or die(mysql_error());
	   $ress1=mysql_query($query);	
	  while($rows=mysql_fetch_array($ress1))
	   {
	   $subcourse= $rows['subcourse'];
	    ?>
			     <font color="#666666"> <a href="courses.php?course=<?php echo $course ;?>&subcourse=<?php echo $subcourse ;?>" >    
               <?php 
	   echo $subcourse;
	   echo "<br>"; 
	   ?>
	               </a></font>
			  <?php
	   }?>
		      
          <?php  $course=$_GET['course'];
	   $subcourse= $_GET['subcourse'];
	
	   $ress2=mysql_query("select * from course where  subcourse='$subcourse'") or die(mysql_error());
	    
		while($rows=mysql_fetch_array($ress2))
	   {
	   $subcourse= $rows['subcourse'];
	    $fee= $rows['fee'];
		 $content= $rows['content'];
				 	
		
	    ?><br />
	
	<table width="85%" border="1" bordercolor="#CCCCCC">
      <tr >
        <td width="14%" height="40" ><strong>Course:</strong></td>
        <td width="86%"  ><?php echo $subcourse; ?></td>
      </tr>
      <tr>
        <td height="39"><strong>Fee:</strong></td>
        <td><?php echo $fee; ?></td>
      </tr>
      <tr>
        <td height="210"><strong>Discription:</strong></td>
        <td><textarea rows="13" cols="50"><?php echo $content; ?></textarea>
        </td>
      </tr>
    </table>
     <?php } ?>
	<p>&nbsp; </p>
	  </div>
		<div id="title1">
          <h3 class="style5">Courses Offered</h3>
      </div>
		<div id="sidemenu">
		  
           <p>
             <?php
          $ress=mysql_query("select  DISTINCT course from course ") or die(mysql_error());	 
       
     
     while ($row = mysql_fetch_array($ress))
	 { 	  
	 $course=  $row['course'];
	 ?>
                   <a href="courses.php?course='<?php echo $course ;?>'" >      
                     
                     <?php echo $row['course']; 
	   echo "<br>";
	   }?>                         </a>           </p>
          
          
	  </div>
<div id="footer"><br/>
<div align="center"><span class="links"><a href="index.php">Home</a>
    <a href="aboutus.php">About Us</a>
    <a href="courses.php">Courses</a>
    <a href="demo_registration.php">Demo Class Registration</a>
    <a href="faq.php">FAQ's</a>
    <a href="order.php">How To Order</a>
    <a href="payment.php">Payment Options</a>
    <a href="enquiry.php">Enquiry</a>
    <a href="contact.php">Contact Us</a></span></div>
    </div>
	</div>
</body>
</html>

this is the original code what we did with out making anychanges u asked us to make.
Database has been posted in the first post of the thread..

see this, i have modified your code..
it is working fine now...
and i have write some more piece of code where they have needed to come out from errors..

<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="description" content="Small Corporation" />
	<meta name="keywords" content="small, corporation" />
	<link rel="stylesheet" href="style.css" type="text/css" />
    <style type="text/css">
<!--
.style4 {color: #FFFFFF}

.style5 {color: #2D5181}
-->
    </style>
</head>
<body>

	<div id="contentcourse">
	  <div id="header"></div>
  <ul id="menu">
			<li><a class="current" href="index.php">Home</a></li>
			<li><a href="aboutus.php">About Us</a></li>
			<li><a href="courses.php">Courses</a></li>
			<li><a href="demo_registration.php">Demo Class Registration</a></li>
			<li><a href="faq.php">FAQ's</a></li>
			<li><a href="order.php">How To Order</a></li>
			<li><a href="payment.php">Payment Options</a></li>
			<li><a href="enquiry.php">Enquiry</a></li>
<li><a href="contact.php">Contact Us</a></li>
            
	  </ul>
		
	  <div id="course">
			<div id="title">
			  <h3>Sub Courses</h3>
			</div>
	<br/>
			  
	          <?php 
		include("conn.php");
		if(!empty($_GET['course']))
		  {
			echo $course=$_GET['course'];
			}else
			$course='';
	  $query=("select course,subcourse from course WHERE course='".$course."'") or die(mysql_error());
	   $ress1=mysql_query($query);	
	  while($rows=mysql_fetch_array($ress1))
	   {
	   $subcourse= $rows['subcourse'];
	    ?>
			     <font color="#666666"> <a href="course.php?course=<?php echo $course ;?>&subcourse=<?php echo $subcourse ;?>" >    
               <?php 
	   echo $subcourse;
	   echo "<br>"; 
	   ?>
	               </a></font>
			  <?php
	   }?>
		      
          <?php if(!empty($_GET['course']))
		  { $course=$_GET['course'];
		  }
		  if(!empty($_GET['subcourse']))
		  {
	   $subcourse= $_GET['subcourse'];
	}
	else $subcourse='';
	
	   $ress2=mysql_query("select * from course where  subcourse='".$subcourse."'") or die(mysql_error());
	    
		while($rows=mysql_fetch_array($ress2))
	   {
	   $subcourse= $rows['subcourse'];
	    $fee= $rows['fee'];
		 $content= $rows['content'];
				 	
		
	    ?><br />
	
	<table width="85%" border="1" bordercolor="#CCCCCC">
      <tr >
        <td width="14%" height="40" ><strong>Course:</strong></td>
        <td width="86%"  ><?php echo $subcourse; ?></td>
      </tr>
      <tr>
        <td height="39"><strong>Fee:</strong></td>
        <td><?php echo $fee; ?></td>
      </tr>
      <tr>
        <td height="210"><strong>Discription:</strong></td>
        <td><textarea rows="13" cols="50"><?php echo $content; ?></textarea>
        </td>
      </tr>
    </table>
     <?php } ?>
	<p>&nbsp; </p>
	  </div>
		<div id="title1">
          <h3 class="style5">Courses Offered</h3>
      </div>
		<div id="sidemenu">
		  
           <p>
             <?php
          $ress=mysql_query("select  DISTINCT course from course ") or die(mysql_error());	 
       
     
     while ($row = mysql_fetch_array($ress))
	 { 	  
	 $course=  $row['course'];
	 ?>
                   <a href="course.php?course=<?php echo $course ;?>" >      
                     
                     <?php echo $row['course']; 
	   echo "<br>";
	   }?>                         </a>           </p>
          
          
	  </div>
<div id="footer"><br/>
<div align="center"><span class="links"><a href="index.php">Home</a>
    <a href="aboutus.php">About Us</a>
    <a href="courses.php">Courses</a>
    <a href="demo_registration.php">Demo Class Registration</a>
    <a href="faq.php">FAQ's</a>
    <a href="order.php">How To Order</a>
    <a href="payment.php">Payment Options</a>
    <a href="enquiry.php">Enquiry</a>
    <a href="contact.php">Contact Us</a></span></div>
    </div>
	</div>
</body>
</html>

Enjoy!!!!1

if your problem is solved...then make this thread as solved...then others will see for it...

Hi Shanthi..
Thank u....
now its working fine...
in that we take COURSES & SUBCOURSES r retriving same time..thats y error ...
now i take subcourses fetching in diff page..now its working fine..

Thanking U...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.