Forums
This topic is locked
Multiple Recordsets on one DW page
28 Apr 2007 10:34:43 Craig G posted:
Hi there. Here is my goal, problem, and question in that order:Goal: To create a basic blog page that allows readers to post comments. Currently I have a working blog that does not accept comments. The blog was built primarily using DreamWeaver, and uses PHP to connect to a MySQL database using a table called tblJournal. tblJournal has a primary key. In the current iteration of the page it successfully cycles back and fourth through the records in the database on demand (ie the user clicks forward and back buttons). That part works great.
Problem: I have created a second table in my database called tblComments built to hold names and comments. As soon as I the second create the second recordset in DreamWeaver the page returns errors (even if I don't include any fields from the second recordset). The error I get is:
Warning: mysql_select_db(): supplied resource is not a valid MySQL-Link resource in /home/craiggr/public_html/journal/journal.php on line 77
Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in /home/craiggr/public_html/journal/journal.php on line 79
Line 77 and 79 are part of a larger block of code, but I am unfamiliar with the intricacies of PHP so I'm not sure how to troubleshoot.
Question(s): Has anyone seen this before? Is there a recommended way to include comments on a blog (I'm sure this is not all that uncommon)? What, if anything, do I need to do to build relationships in the MySQL database? I am used to working in Access where everything depends on relationships but I can't find a durn thing about relationships in MySQL so I assume that as long as you have your primary keys set up (which I do) it will figure it out on its own, but if I'm wrong, please correct me!
Thanks for reading, and I hope my question makes sense. You can see the page I am working on by going to www.craiggreenwood.com and clicking the link marked "Journal". (The pages use IFrames so direct linking would not lead you there!)
Craig
Replies
Replied 29 Apr 2007 01:54:20
29 Apr 2007 01:54:20 Kenneth Halley replied:
you need to post all your code- looks like your calling a variable for your sql that you have not set up first.
Not knowing the size of your page but it could just be that you have too many mysql_free_result() entries in the footer of your file, sometimes DW inserts extras especialliy if you have copied pages. Notice the error is a warning not a code error- so if you had errors tunred off in php.ini you would not see this.
Post the code for the whole page and it should be straight forward to sort.
Also you create relationships using joins- really thats all access does too but it does it from a graphical interface so you don't manually usually need to hand code the join or union statement. As I say post your code it should be easy to sort.
-----------------------------------
www.halleynet.co.uk
Edited by - kenneth_halley on 29 Apr 2007 02:02:11
Not knowing the size of your page but it could just be that you have too many mysql_free_result() entries in the footer of your file, sometimes DW inserts extras especialliy if you have copied pages. Notice the error is a warning not a code error- so if you had errors tunred off in php.ini you would not see this.
Post the code for the whole page and it should be straight forward to sort.
Also you create relationships using joins- really thats all access does too but it does it from a graphical interface so you don't manually usually need to hand code the join or union statement. As I say post your code it should be easy to sort.
-----------------------------------
www.halleynet.co.uk
Edited by - kenneth_halley on 29 Apr 2007 02:02:11
Replied 30 Apr 2007 02:48:34
30 Apr 2007 02:48:34 Craig G replied:
Thanks for your offer to help. The code for the page is quite long and will not fit in the forum. I've tried it within quotes and code blocks. I did get one thing working though. I can now successfully post comments into my database. The problem is going to come when I add the past comments to the page, but for right now I'm not worried about that one.
Here are some additional questions that have come up. First, allow me to introduce my tables to you along with their fields!
tblJournal
ID (This is the primary key for this table)
Entry
Date
tblJournalComments
ID
VisitorName
DateOfEntry (This is the primary key for this table)
DateOfComment
Comment
I want the user to fill in two fields only, VisitorName and Comment. Date of entry is currently loaded from Date from tblJournal. I would like DateOfComment to be loaded from the date of the comment [ie =Now()]. I think I need to do that with a variable (session or URL or environment I don't know). I know how to create all these variables within DW, however I do not know how to set them equal to today's date.
I have tried pasting my code and it won't all fit here. It might be best to go to www.craiggreenwood.com, click journal and then view the source for the IFrame on the left.
If you have another method of getting the full code to you I'd be happy to do it!
Thanks again!
Craig
Here are some additional questions that have come up. First, allow me to introduce my tables to you along with their fields!
tblJournal
ID (This is the primary key for this table)
Entry
Date
tblJournalComments
ID
VisitorName
DateOfEntry (This is the primary key for this table)
DateOfComment
Comment
I want the user to fill in two fields only, VisitorName and Comment. Date of entry is currently loaded from Date from tblJournal. I would like DateOfComment to be loaded from the date of the comment [ie =Now()]. I think I need to do that with a variable (session or URL or environment I don't know). I know how to create all these variables within DW, however I do not know how to set them equal to today's date.
I have tried pasting my code and it won't all fit here. It might be best to go to www.craiggreenwood.com, click journal and then view the source for the IFrame on the left.
If you have another method of getting the full code to you I'd be happy to do it!
Thanks again!
Craig
Replied 15 May 2007 22:03:17
15 May 2007 22:03:17 Craig G replied:
Here is a link that will display my full code. I am still needing help with this! I have been experimenting with inner joins but not with much luck. Help!
www.craiggreenwood.com/journalcode.txt
Craig
www.craiggreenwood.com/journalcode.txt
Craig
Replied 01 Jun 2007 08:20:19
01 Jun 2007 08:20:19 ahohddy ahohddy replied:
hey, thanks, this post is very useful
-------------------------------------
<b>Buy Software</b>
www.buydownload.net
-------------------------------------
<b>Buy Software</b>
www.buydownload.net