Jump to content

Recommended Posts

I need some help.  I have a basic blog that I built using Dreamweaver and php.  The blog part works great by itself.  I can scroll through entries and I'm happy as a clam with that.  My next goal is to allow comments made by others.  Using my database I have created a second table and a form in DW that loads the database with comments.  That part also works great.  The problem comes when I try to display said comments.  Here is more details.

 

So far I have a database connection to make the blog work normal.  The table is called tblJournal which has three fields: ID, date, and entry.

 

In my data base I have a second table called tblJournalComments with these fields: ID, VisitorName, DateOfEntry, DateOfComment, and Comment.

 

With that information stated, I am going to DW and creating the connection, which SEEMS to work.  I load the appropriate peices into the page and save it to the server and test it out and I get the following error messages:

 

Warning: mysql_select_db(): supplied resource is not a valid MySQL-Link resource in /home/craiggr/public_html/journal/journal.php on line 78

 

Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in /home/craiggr/public_html/journal/journal.php on line 80

 

I am at a loss as to why.  I have done a TON of trouble shooting and can't get it.  I am new to SQL and MySQL and one attempt at the language I have used is this:

 

SELECT tblJournalComments.DateOfComment, tblJournalComments.`Comment`, tblJournal.`date`, tblJournalComments.VisitorName

FROM tblJournalComments, tblJournal

WHERE tblJournalComments.`dateofentry` = tblJournal.`date`

 

I have tried several other iterations of this so I don't know if the SQL is the problem or if I should be emailing my hosting company or if there is some small fix within DW.  HELP!

 

Here is a link to the damaged code:

 

http://www.craiggreenwood.com/journalcode.txt

 

You can see the site I am working on at www.CraigGreenwood.com but it may be in a state of flux as I attempt to correct this.  Currently I am going on week 4 of dealing with this.  I know it can't be too hard....you see comment sections all over the net.  What am I missing?

 

Humbly Yours,

Craig Greenwood

 

Link to comment
https://forums.phpfreaks.com/topic/52150-help-with-comment-section-of-a-blog/
Share on other sites

The 'backticks' (formally called grave accents) were added by DW.  I have tried less specific entries in the SQL statement (ie "select *...").  The SQL is the least of my worries though.  My problem is that the instant I create the second recordset in DW the page delivers the errors I mentioned above (whether I create any SQL or not).  My theory is that its the recordset that is causing the problem.  Does anyone have a solution?  I can't be the first to have this problem!

 

Craig

Step 1 of the solution might be to stop using DW for anything involving a database.  The backticks are ruining the sql query strings.  It'll never work with them.

 

Warning: mysql_select_db(): supplied resource is not a valid MySQL-Link resource in /home/craiggr/public_html/journal/journal.php on line 78

 

That's a very specific error message.  The database cannot be selected - there is some error is the database name, or your database connection variables, or the database doesn't exist, or you have a DW-induced syntax mumbo-jumbo.

 

mysql_select_db($database_Journal, $Journal);

 

Start with that - it's using the wrong values, perhaps.

Thanks for your time to help me with this!  I took your advice and tried removing the grave accents but to no avail.  After that I analyzed the names of the database and connections and they are being referred just fine.  Next I deleted the second recordset just to get the page working again, and found that the SQL statement works just fine with the grave accents as follows:

 

$query_Journal = "SELECT *  FROM tblJournal  ORDER BY tblJournal.`ID` desc";

 

(I can post the full code of the working page if you like.)

 

This makes sense because MySQL language is a bit different than SQL.  I know your feeling on using tools like DW to create PHP language.  It adds extra seemingly unnecessary code and it makes it beastly to go back and finetune like I am trying to do now.  One reason I am using DW is because I teach DW with databases at my job, so mastering this is important to me.  Please forgive me...I promise I'm not being stubborn!  Have you used DW to create database connections before?  I like it, but boy, I tell you, this is being a thorn in my side.

 

Thanks again for your guided assistance.

 

Craig

OK, how about some debugging help with the queries. That should point you in the right direction.  Try recoding your queries in similar fashion to this:

 

$query = " .... "; // whatever query string you want
$result = mysql_query($query) or die("Error ". mysql_error(). " with query ". $query); // show error

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.