473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Discussion Forums error

Hi I am new to the forums and I have one question I read through this tutorial:

Tutorial

and I get this error when I view the index.php3 file

Expand|Select|Wrap|Line Numbers
  1. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/user/public_html/forum/index.php3 on line 36
  2.  
  3. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/user/public_html/forum/index.php3 on line 51
  4.  
Jan 12 '08 #1
9 1470
Your query have some problems..
Your query is not executed ...
Jan 12 '08 #2
Would you by happen to know the general issue behind query's not being executed?
In my previous post the code written says that there is an issue on line 36. This is what the piece of code is on line 36.
Expand|Select|Wrap|Line Numbers
  1.     while ($topic = mysql_fetch_array($topic_query)) {
This line is from this piece of code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $topic_query = mysql_query("SELECT * FROM topics ORDER BY ID");
  3.     while ($topic = mysql_fetch_array($topic_query)) {
  4. ?>
Thanks for the reply.
Jan 12 '08 #3
Bump, please can someone help me. Thanks
Jan 16 '08 #4
Markus
6,050 Expert 4TB
Please post the rest of that code.

Thanks.
Jan 16 '08 #5
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require( './functions.php3');
  3.  
  4. showheader("Here are your Topics");
  5. ?>
  6.  
  7. <TABLE BORDER=0 WIDTH=100% CELLSPACING=3 CELLPADDING=5>
  8.     <TR>
  9.         <TD>
  10.         <FONT COLOR="#000000" FACE="Arial,Verdana,Helvetica" size=-1>
  11.         <b>Topics: </b>
  12.         <BR>
  13.         <P>
  14.         <a href="add-topic.php3"><FONT COLOR="#000000">Make a Topic</a>
  15.         </TD>
  16.     </TR>
  17. </TABLE>
  18. <P>
  19. <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
  20.     <TR VALIGN=TOP ALIGN=LEFT>
  21.         <TD WIDTH=100%>
  22.             <TABLE BORDER=0 BGCOLOR="#000000" CELLSPACING=1 CELLPADDING=1 WIDTH=100%>
  23.                 <TR>
  24.                     <TD BGCOLOR="#C0C0C0" WIDTH=100%>
  25.                         <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>
  26.                             <TR>
  27.                                 <TD>
  28.                                 <P><B><FONT COLOR="#000000" FACE="Trebuchet MS,Arial,Helvetica">Topics</FONT></B>
  29.                                 </TD>
  30.                             </TR>
  31.                         </TABLE>
  32.                     </TD>
  33.                 </TR>
  34. <?php
  35. $topic_query = mysql_query("SELECT * FROM topics ORDER BY ID");
  36.     while ($topic = mysql_fetch_array($topic_query)) {
  37. ?>
  38.     <TR>
  39.     <TD WIDTH=82% BGCOLOR="#FFFFFF" HEIGHT=28 VALIGN=TOP>
  40.         <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>
  41.             <TR>
  42.                 <TD>
  43.                 <P><FONT SIZE="+1" FACE="Trebuchet MS,Arial,Helvetica"><a href="view.php3?topicID=<?php echo $topic['ID'] ?>"><?php echo $topic['TopicName'] ?></a></FONT> 
  44.                 </TD>
  45.             </TR>
  46.         </TABLE>
  47.     </TD>
  48. </TR>
  49. <?php
  50. if (mysql_num_rows($topic_query) < 1) {
  51. ?>
  52. <TR height=300>
  53.     <TD WIDTH=100% BGCOLOR="#FFFFFF" HEIGHT=28 VALIGN=TOP>
  54.     <CENTER><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">
  55.     <BR><B>There Are No Topics</B><BR><BR></CENTER>
  56.     </TD>
  57. </TR>
  58. <?php } ?>
  59. </TABLE>
  60. </TD></TR>
  61. </TABLE>
  62. <?php
  63. showfooter();
  64. ?>
Jan 16 '08 #6
stepterr
157 100+
Text Case is very important in PHP and SQL. So I would make sure that you have the table and fieldname the exact same way they appear in your database.
Jan 16 '08 #7
ahh I think i seem to have found the issue. It seems the tables for the database are not being created.

When I put this into the mySQL query to create the tables:
Expand|Select|Wrap|Line Numbers
  1.  CREATE TABLE posts (
  2.    ID int(5) DEFAULT '0' NOT NULL auto_increment,
  3.    TopicID int(5) DEFAULT '0' NOT NULL,
  4.    Name varchar(50) NOT NULL,
  5.    Email varchar(50) NOT NULL,
  6.    Password varchar(50) NOT NULL,
  7.    TimeStamp varchar(10) NOT NULL,
  8.    Post text NOT NULL,
  9.    PRIMARY KEY (ID)
  10. );
  11.  
  12. CREATE TABLE topics (
  13.    ID int(5) DEFAULT '0' NOT NULL auto_increment,
  14.    TopicName varchar(50) NOT NULL,
  15.    PRIMARY KEY (ID)
  16. );
  17.  
  18.  
I get this error returned from phpMyAdmin:
Expand|Select|Wrap|Line Numbers
  1. Error
  2.  
  3. SQL query:
  4.  
  5. CREATE TABLE posts(
  6. ID int( 5 ) DEFAULT '0' NOT NULL AUTO_INCREMENT ,
  7. TopicID int( 5 ) DEFAULT '0' NOT NULL ,
  8. Name varchar( 50 ) NOT NULL ,
  9. Email varchar( 50 ) NOT NULL ,
  10. PASSWORD varchar( 50 ) NOT NULL ,
  11. TimeStamp varchar( 10 ) NOT NULL ,
  12. Post text NOT NULL ,
  13. PRIMARY KEY ( ID )
  14. );
  15.  
  16. MySQL said: Documentation
  17. #1067 - Invalid default value for 'ID' 
What does this mean?
Jan 17 '08 #8
never mind I got around this issue by manually creating the tables, but now a new problem has arised, I cant seem to post anything. After i submit an article it will just seem like the page reloaded and all the fields are empty again. Whats going on here?
Jan 17 '08 #9
stepterr
157 100+
What does your form tag look like? If you are posting back to the same page and not assigning your fields the posted values that is probably why it would be blanking out.
Jan 17 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: stenknz | last post by:
Does any one know where there is a good introduction to Discussion Forum scripting using PHP and MySQL. (Apache WS) I just need the nuts and bolts to get an overview of whats required. Regards,...
1
by: Andy Fish | last post by:
Hi, I'm developing a community/discussion/collaboration/groupware/bulletin board type application which will be ASP.Net based, using RDBMS for persistence. I'm looking for any standard...
1
by: html brooklyn boy | last post by:
I am creating a site which will eventually need a discussion forum of some sort. How would I approach this? Is this done with java, html, or somehing else? Thanks
1
by: vasss_n | last post by:
I am planning to create a DIscussion Forunm cum Chat application ASP.NET, would any plese guide me in data design for ideal application. Is there any sample code available on net fro free to have...
3
by: Smithers | last post by:
Our tech support group is looking to implement better online assistance - and we like the idea of having a news group similar to this one (microsoft.public.dotnet.framework.aspnet) but without...
2
by: Eddie H | last post by:
Do you other sites, forums or discussion groups where you can change knowledge, opinions etc. considering C# programming and .NET? -- like to get answers sometimes too --
4
by: maflatoun | last post by:
Hi, I'm looking at adding a discussion forum to our site (C# or VB.NET). Any recommendations for a good discussion forum software? (both free and $$$$). I looked at InstantForum and it seems...
2
by: Pyrotecnix | last post by:
I created a table in mysql database named forums with the following code CREATE*TABLE*posts*( ***ID*int(5)*DEFAULT*'0'*NOT*NULL*auto_increment, ***TopicID*int(5)*DEFAULT*'0'*NOT*NULL,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.