in reply to Database access on your site, or "Where the hell is mysql?"

"Once there, the application runs without apparent error, but I don't think it is updating the database properly."

This is a good indication that you are not checking return code and SQLCODE in your code. Better fix the code. For any database operation, always always check the SQLCODE. For any perl function call, always check return code.

You must have some code similar to this:

$dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; $dbh = DBI->connect($dsn, $user, $password);

Change $hostname to where your MySQl resides. Make it configurable.

Also you have to configure mysql so that it allows remote access. (I guess your development box probably is the same where mysql sits.)

Replies are listed 'Best First'.
Re^2: Database access on your site, or "Where the hell is mysql?"
by SkipHuffman (Monk) on Oct 01, 2005 at 17:16 UTC

    You are correct, my error checking is quite inadequete. I intend for it to be fixed "properly" at some point. But for the moment I just want to get the general function working.

    My intention with this is for it to be a base/straw man so that I can hire a couple of more experienced programmers to work with me to make it correct. Thus my error checking is lousy.

    I do have the database connection information. And I believe the connection is working correctly. It is just the inserts that I think may be failing.

    My development box has MySQL installed locally and all the inserts, selects and all work fine with everything local. When I upload to my hosting provider, I am seeing some things that look like they are working, but I don't think it is inserting into the database, or perhaps I am not selecting back from the database correctly. I would like to try to figure out which. If I were on my development system, I would just pull up the mysql client and run some selects from there, but I do not seem to have that client available to me at my hosting provider. Is there an common way to get the equivalent of a mysql client on a remote database?

    I know that I have a lot of slop in the code. I am doing it as a demonstration so that I can hire a more experienced programmer to crawl in and fix it. Its easier to explain what I am trying to do by doing it than by waving my hands around. Thanks

    Skip
      Howdy!

      Putting in adequate error checking is part and parcel of getting the general function working. If your code can't tell if the database actions worked or not, it's broken. At the least, you can't demonstrate that it isn't broken.

      You could try setting RaiseError to true, which will make it blow up when a DBI error occurs. That will be better than nothing, especially if you couple that with CGI::FatalsToBrowser (or whatever that bit is that makes the CGI error messages go to the browser instead of the local error log where you might never see them.

      yours,
      Michael

        Oh, I don't disagree that error checking is essential. The code will not be ready for real use until it is there. Thanks

        Skip