943,742 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1390
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 10th, 2008
0

php warning fetching a record from database

Expand Post »
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`
--

sql Syntax (Toggle Plain Text)
  1. CREATE TABLE `course` (
  2. `id` INT(50) NOT NULL AUTO_INCREMENT,
  3. `course` VARCHAR(50) NOT NULL,
  4. `subcourse` VARCHAR(50) NOT NULL,
  5. `fee` INT(50) NOT NULL,
  6. `content` VARCHAR(1000) NOT NULL,
  7. `DATE` TEXT NOT NULL,
  8. PRIMARY KEY (`id`)
  9. ) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=34 ;
  10.  
  11. --
  12. -- Dumping data for table `course`
  13. --
  14.  
  15. INSERT INTO `course` (`id`, `course`, `subcourse`, `fee`, `content`, `DATE`) VALUES
  16. (24, 'java', 'dddddddddddsssssssss', 212121, '11111111111111111111111', '2008-08-29');
Attached Files
File Type: php courses.php (3.7 KB, 17 views)
Last edited by peter_budo; Sep 10th, 2008 at 3:43 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 8
Solved Threads: 1
Newbie Poster
prashanth18 is offline Offline
15 posts
since Jul 2008
Sep 10th, 2008
0

Re: php warning fetching a record from database

where is your mysql_connect ?
Sponsor
Featured Poster
Reputation Points: 550
Solved Threads: 728
Bite my shiny metal ass!
pritaeas is offline Offline
4,166 posts
since Jul 2006
Sep 10th, 2008
0

Re: php warning fetching a record from database

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'];
Last edited by NormandP; Sep 10th, 2008 at 9:52 am. Reason: ameliorate
Reputation Points: 12
Solved Threads: 3
Newbie Poster
NormandP is offline Offline
21 posts
since Jul 2008
Sep 10th, 2008
0

Re: php warning fetching a record from database

this line should be like this:
php Syntax (Toggle Plain Text)
  1. $query=("select * from course where course='".$course."'") or die(mysql_error());
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Sep 11th, 2008
0

php warning fetching a record from database

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

PHP Syntax (Toggle Plain Text)
  1. $course=$_GET['course'];
  2.  
  3. $query=("select * from course where course='".$course."' ) or die(mysql_error());
  4. while($result=mysql_fetch_array($query))
  5. {
  6.  
  7. }
  8.  


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.
Reputation Points: 10
Solved Threads: 7
Unverified User
saikishore is offline Offline
41 posts
since Jul 2008
Sep 11th, 2008
0

Re: php warning fetching a record from database

hello kishor..
echo this line and tel me wat u got:
echo $course=$_GET['course'];
and also echo this statement:
php Syntax (Toggle Plain Text)
  1. echo $r="select * from course where course='".$course."'";
Last edited by Shanti C; Sep 11th, 2008 at 7:26 am.
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Sep 11th, 2008
0

Re: php warning fetching a record from database

try this
PHP Syntax (Toggle Plain Text)
  1. echo $r="select * from course where course=$course;
  2.  
Reputation Points: 5
Solved Threads: 5
Junior Poster
vssp is offline Offline
197 posts
since Jul 2006
Sep 11th, 2008
0

Re: php warning fetching a record from database

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['course'];
doesn't print anything
Reputation Points: 10
Solved Threads: 7
Unverified User
saikishore is offline Offline
41 posts
since Jul 2008
Sep 11th, 2008
0

Re: php warning fetching a record from database

so, you didn't get any data in $_GET['course'];
tel me ,from where you are getting this variable..
or post needed code...
Last edited by Shanti C; Sep 11th, 2008 at 7:41 am.
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Sep 11th, 2008
0

Re: php warning fetching a record from database

PHP Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="description" content="Small Corporation" />
  7. <meta name="keywords" content="small, corporation" />
  8. <link rel="stylesheet" href="style.css" type="text/css" />
  9. <style type="text/css">
  10. <!--
  11. .style4 {color: #FFFFFF}
  12.  
  13. .style5 {color: #2D5181}
  14. -->
  15. </style>
  16. </head>
  17. <body>
  18.  
  19. <div id="contentcourse">
  20. <div id="header"></div>
  21. <ul id="menu">
  22. <li><a class="current" href="index.php">Home</a></li>
  23. <li><a href="aboutus.php">About Us</a></li>
  24. <li><a href="courses.php">Courses</a></li>
  25. <li><a href="demo_registration.php">Demo Class Registration</a></li>
  26. <li><a href="faq.php">FAQ's</a></li>
  27. <li><a href="order.php">How To Order</a></li>
  28. <li><a href="payment.php">Payment Options</a></li>
  29. <li><a href="enquiry.php">Enquiry</a></li>
  30. <li><a href="contact.php">Contact Us</a></li>
  31.  
  32. </ul>
  33.  
  34. <div id="course">
  35. <div id="title">
  36. <h3>Sub Courses</h3>
  37. </div>
  38. <br/>
  39.  
  40. <?php
  41. include("config.php");
  42. $course=$_GET['course'];
  43. $query=("select course,subcourse from course WHERE course=$course") or die(mysql_error());
  44. $ress1=mysql_query($query);
  45. while($rows=mysql_fetch_array($ress1))
  46. {
  47. $subcourse= $rows['subcourse'];
  48. ?>
  49. <font color="#666666"> <a href="courses.php?course=<?php echo $course ;?>&subcourse=<?php echo $subcourse ;?>" >
  50. <?php
  51. echo $subcourse;
  52. echo "<br>";
  53. ?>
  54. </a></font>
  55. <?php
  56. }?>
  57.  
  58. <?php $course=$_GET['course'];
  59. $subcourse= $_GET['subcourse'];
  60.  
  61. $ress2=mysql_query("select * from course where subcourse='$subcourse'") or die(mysql_error());
  62.  
  63. while($rows=mysql_fetch_array($ress2))
  64. {
  65. $subcourse= $rows['subcourse'];
  66. $fee= $rows['fee'];
  67. $content= $rows['content'];
  68.  
  69.  
  70. ?><br />
  71.  
  72. <table width="85%" border="1" bordercolor="#CCCCCC">
  73. <tr >
  74. <td width="14%" height="40" ><strong>Course:</strong></td>
  75. <td width="86%" ><?php echo $subcourse; ?></td>
  76. </tr>
  77. <tr>
  78. <td height="39"><strong>Fee:</strong></td>
  79. <td><?php echo $fee; ?></td>
  80. </tr>
  81. <tr>
  82. <td height="210"><strong>Discription:</strong></td>
  83. <td><textarea rows="13" cols="50"><?php echo $content; ?></textarea>
  84. </td>
  85. </tr>
  86. </table>
  87. <?php } ?>
  88. <p>&nbsp; </p>
  89. </div>
  90. <div id="title1">
  91. <h3 class="style5">Courses Offered</h3>
  92. </div>
  93. <div id="sidemenu">
  94.  
  95. <p>
  96. <?php
  97. $ress=mysql_query("select DISTINCT course from course ") or die(mysql_error());
  98.  
  99.  
  100. while ($row = mysql_fetch_array($ress))
  101. {
  102. $course= $row['course'];
  103. ?>
  104. <a href="courses.php?course='<?php echo $course ;?>'" >
  105.  
  106. <?php echo $row['course'];
  107. echo "<br>";
  108. }?> </a> </p>
  109.  
  110.  
  111. </div>
  112. <div id="footer"><br/>
  113. <div align="center"><span class="links"><a href="index.php">Home</a>
  114. <a href="aboutus.php">About Us</a>
  115. <a href="courses.php">Courses</a>
  116. <a href="demo_registration.php">Demo Class Registration</a>
  117. <a href="faq.php">FAQ's</a>
  118. <a href="order.php">How To Order</a>
  119. <a href="payment.php">Payment Options</a>
  120. <a href="enquiry.php">Enquiry</a>
  121. <a href="contact.php">Contact Us</a></span></div>
  122. </div>
  123. </div>
  124. </body>
  125. </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..
Reputation Points: 10
Solved Threads: 7
Unverified User
saikishore is offline Offline
41 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how to php error handling...
Next Thread in PHP Forum Timeline: about e-shopping





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC