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 - Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/user/public_html/forum/index.php3 on line 36
-
-
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/user/public_html/forum/index.php3 on line 51
-
9 1470
Your query have some problems..
Your query is not executed ...
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. -
while ($topic = mysql_fetch_array($topic_query)) {
This line is from this piece of code: - <?php
-
$topic_query = mysql_query("SELECT * FROM topics ORDER BY ID");
-
while ($topic = mysql_fetch_array($topic_query)) {
-
?>
Thanks for the reply.
Bump, please can someone help me. Thanks
Please post the rest of that code.
Thanks.
- <?php
-
require( './functions.php3');
-
-
showheader("Here are your Topics");
-
?>
-
-
<TABLE BORDER=0 WIDTH=100% CELLSPACING=3 CELLPADDING=5>
-
<TR>
-
<TD>
-
<FONT COLOR="#000000" FACE="Arial,Verdana,Helvetica" size=-1>
-
<b>Topics: </b>
-
<BR>
-
<P>
-
<a href="add-topic.php3"><FONT COLOR="#000000">Make a Topic</a>
-
</TD>
-
</TR>
-
</TABLE>
-
<P>
-
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
-
<TR VALIGN=TOP ALIGN=LEFT>
-
<TD WIDTH=100%>
-
<TABLE BORDER=0 BGCOLOR="#000000" CELLSPACING=1 CELLPADDING=1 WIDTH=100%>
-
<TR>
-
<TD BGCOLOR="#C0C0C0" WIDTH=100%>
-
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>
-
<TR>
-
<TD>
-
<P><B><FONT COLOR="#000000" FACE="Trebuchet MS,Arial,Helvetica">Topics</FONT></B>
-
</TD>
-
</TR>
-
</TABLE>
-
</TD>
-
</TR>
-
<?php
-
$topic_query = mysql_query("SELECT * FROM topics ORDER BY ID");
-
while ($topic = mysql_fetch_array($topic_query)) {
-
?>
-
<TR>
-
<TD WIDTH=82% BGCOLOR="#FFFFFF" HEIGHT=28 VALIGN=TOP>
-
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>
-
<TR>
-
<TD>
-
<P><FONT SIZE="+1" FACE="Trebuchet MS,Arial,Helvetica"><a href="view.php3?topicID=<?php echo $topic['ID'] ?>"><?php echo $topic['TopicName'] ?></a></FONT>
-
</TD>
-
</TR>
-
</TABLE>
-
</TD>
-
</TR>
-
<?php
-
}
-
if (mysql_num_rows($topic_query) < 1) {
-
?>
-
<TR height=300>
-
<TD WIDTH=100% BGCOLOR="#FFFFFF" HEIGHT=28 VALIGN=TOP>
-
<CENTER><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">
-
<BR><B>There Are No Topics</B><BR><BR></CENTER>
-
</TD>
-
</TR>
-
<?php } ?>
-
</TABLE>
-
</TD></TR>
-
</TABLE>
-
<?php
-
showfooter();
-
?>
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.
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: - CREATE TABLE posts (
-
ID int(5) DEFAULT '0' NOT NULL auto_increment,
-
TopicID int(5) DEFAULT '0' NOT NULL,
-
Name varchar(50) NOT NULL,
-
Email varchar(50) NOT NULL,
-
Password varchar(50) NOT NULL,
-
TimeStamp varchar(10) NOT NULL,
-
Post text NOT NULL,
-
PRIMARY KEY (ID)
-
);
-
-
CREATE TABLE topics (
-
ID int(5) DEFAULT '0' NOT NULL auto_increment,
-
TopicName varchar(50) NOT NULL,
-
PRIMARY KEY (ID)
-
);
-
-
I get this error returned from phpMyAdmin: - Error
-
-
SQL query:
-
-
CREATE TABLE posts(
-
ID int( 5 ) DEFAULT '0' NOT NULL AUTO_INCREMENT ,
-
TopicID int( 5 ) DEFAULT '0' NOT NULL ,
-
Name varchar( 50 ) NOT NULL ,
-
Email varchar( 50 ) NOT NULL ,
-
PASSWORD varchar( 50 ) NOT NULL ,
-
TimeStamp varchar( 10 ) NOT NULL ,
-
Post text NOT NULL ,
-
PRIMARY KEY ( ID )
-
);
-
-
MySQL said: Documentation
-
#1067 - Invalid default value for 'ID'
What does this mean?
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?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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,...
|
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...
|
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
|
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...
|
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...
|
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 --
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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,...
| |