Strange Database Error

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Okay, I've already managed to track down this bug and fix it.  But the thing  
is, I'm not quite sure why it happened and it's left me scratching my head.

I was setting up some scripts to display videos embedded in a webpage.  The  
program does some writing to a database to store captions and such.  For  
some reason, though, the database writing wasn't working.  I'd tested out  
the functions in other scripts and they went just fine.  I wasn't sure what  
was going on.  So I tested out the script by stopping it at certain points.  
If I stopped the script right after it wrote to the database, then the  
database was updated perfectly.  So doing this I narrowed down the source of  
my problem.

For some reason, the place at fault was much farther down in my code, and it  
had nothing to do with database access whatsoever.  It was a part of my  
script that I set up to embed RealPlayer to play .rm or .ram clips.  It came  
down to this code (which is part of a larger string to embed the player):

<EMBED src='$videofile' width='$vidwidth' height='$vidheight'
loop='0' type='audio/x-pn-realaudio-plugin' controls='imagewindow'  
console='video' autostart='0'>

The problem was that I put in the wrong variable instead of $videofile.  So  
the player didn't get the right filename and couldn't really play the video.  
Once I corrected that, the database problem disappeared.

But how is this code connected to the database in any way whatsoever??  I  
just don't get it!  

Re: Strange Database Error wrote:
Quoted text here. Click to load it

Perhaps: script abort caused uncommitted database actions to be rolled back?
Depends on which database (you didn't say) and if it was auto-committing or
not, but it is possible.

Re: Strange Database Error

Quoted text here. Click to load it

It's a MySQL database.  The rest of the page seemed to load up fine, even if  
the realplayer embed didn't quite work properly.

When does a database action become committed?  

Re: Strange Database Error wrote:
Quoted text here. Click to load it

If a database is doing "auto-commit", then each SQL statement is committed
as soon as it completes. If not in auto-commit mode, it takes an explicit
SQL "COMMIT" to actually apply the changes. With some databases, if the
connection is closed inside a transaction without a COMMIT, it acts like
you did ROLLBACK and undoes the changes. But it doesn't sound like this
will help.  Also I don't know much about MySQL specifically.

Site Timeline