Let’s talk tech for a moment. Recently, the cool folks over at Macromedia released the much anticipated 2004 version of Dreamweaver MX. I have been working with the trial version of it to decide if my clients and I should upgrade – but it’s a done deal really, we should. Of course, there are some small teething problems. Read on for a tail of frustration, technical prowess and you might even find a solution or two.
The first one I encountered was that DW (Dreamweaver) now requires PHP 4.1 if you are going to use it’s code generators with a PHP server model. Hand coded PHP is not effected. Why? Because PHP 4.1 introduced the ability to access form variables as shown below instead of an older syntax:
$_POST[‘example’]
This is a pretty significant change. Enjoy that knowledge. Let it sink in. In fact, I will say it again because you now know the secret that took me most of a day of debugging PHP to realize. That’s OK though, cause now I understand intimately how DW deals with the server.
Dreamweaver MX2004 absolutely required PHP 4.1 or above.
The reason for the problem is simple… DW uploads a helper script in PHP when you are using the PHP model (other types for other models) that it uses as a sort of web service or proxy to access the metadata of the database. This is a pretty good idea in a lot of ways, not the least of which is it lets you work with a locked down database your hosting provider might not want to open up for off site access via a true client tool.
This web service is provided command data in the form of a post’ed [[wp:HTML]] for and returns the results as a mostly [[wp:XML]] document. I say mostly because I don’t thin it strictly conforms to all the formal requirements of a full on XML document; and herein lies the problem ๐
So I am working on a database, the same one that I had the above mentioned PHP issue with. Time is passing and it is all going well when !!BLAM!! another enigmatic error message without any help at all. This one came during my use of the “Insert Record Form” wizard:
“While executing onChange in ServerObject-InsRecPHP.htm, a JavaScript error occurred.”
Informative huh? You have to understand that DW uses [[wp:JavaScript]] as it’s internal scripting language. A good portion of the internal functionality and much of the ability to be extended comes from this. It is a pretty cool thing, except JavaScript is a pretty odd little language. Expecting this to turn out to be some simple problem I began idly looking into the bug, tracing the DW code back through the functions, debugging and so on.
This took a number of very educational hours.
The final result was be digging back into the code of the web service on the server, and finding out that there weren’t any issues I could see. It was running find and retuning the data back to DW. We could rule out a PHP error of that type.
I then did the only thing an obsessive/compulsive programmer would do that that point… I started looking at the db itself. I discovered that the functionality worked with another DB on the server and a db on another server. Honestly? I would have tried this much sooner if I hadn’t already been through the problem above with the PHP issue. Int he end, the problem lay with the returned XML:
DW MX can’t handle tables with a field named “length”. This bug is in both MX and MX2004.
For your edification, the returned XML from my debugging is shown below. I had to tidy it up some. The only difference is the change of the field named “length” to “length_safe”.
Failed XML
<RESULTSET> <FIELDS> <FIELD> <NAME>TABLE_CATALOG</NAME> </FIELD> <FIELD> <NAME>TABLE_SCHEMA</NAME> </FIELD> <FIELD> <NAME>TABLE_NAME</NAME> </FIELD> <FIELD> <NAME>COLUMN_NAME</NAME> </FIELD> <FIELD> <NAME>DATA_TYPE</NAME> </FIELD> <FIELD> <NAME>IS_NULLABLE</NAME> </FIELD> <FIELD> <NAME>COLUMN_SIZE</NAME> </FIELD> </FIELDS> <ROWS> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>id</VALUE> <VALUE>bigint</VALUE> <VALUE>NO</VALUE> <VALUE>20</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>title</VALUE> <VALUE>varchar</VALUE> <VALUE>NO</VALUE> <VALUE>128</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>active</VALUE> <VALUE>char</VALUE> <VALUE>NO</VALUE> <VALUE>1</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>catalog</VALUE> <VALUE>varchar</VALUE> <VALUE>YES</VALUE> <VALUE>128</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>topic</VALUE> <VALUE>varchar</VALUE> <VALUE>YES</VALUE> <VALUE>128</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>length</VALUE> <VALUE>varchar</VALUE> <VALUE>YES</VALUE> <VALUE>128</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>target</VALUE> <VALUE>text</VALUE> <VALUE>YES</VALUE> <VALUE/> </ROW> </ROWS> </RESULTSET>
Working XML
<RESULTSET> <FIELDS> <FIELD> <NAME>TABLE_CATALOG</NAME> </FIELD> <FIELD> <NAME>TABLE_SCHEMA</NAME> </FIELD> <FIELD> <NAME>TABLE_NAME</NAME> </FIELD> <FIELD> <NAME>COLUMN_NAME</NAME> </FIELD> <FIELD> <NAME>DATA_TYPE</NAME> </FIELD> <FIELD> <NAME>IS_NULLABLE</NAME> </FIELD> <FIELD> <NAME>COLUMN_SIZE</NAME> </FIELD> </FIELDS> <ROWS> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>id</VALUE> <VALUE>bigint</VALUE> <VALUE>NO</VALUE> <VALUE>20</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>title</VALUE> <VALUE>varchar</VALUE> <VALUE>NO</VALUE> <VALUE>128</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>active</VALUE> <VALUE>char</VALUE> <VALUE>NO</VALUE> <VALUE>1</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>catalog</VALUE> <VALUE>varchar</VALUE> <VALUE>YES</VALUE> <VALUE>128</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>topic</VALUE> <VALUE>varchar</VALUE> <VALUE>YES</VALUE> <VALUE>128</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>length_safe</VALUE> <VALUE>varchar</VALUE> <VALUE>YES</VALUE> <VALUE>128</VALUE> </ROW> <ROW> <VALUE/> <VALUE/> <VALUE/> <VALUE>target</VALUE> <VALUE>text</VALUE> <VALUE>YES</VALUE> <VALUE/> </ROW> </ROWS> </RESULTSET>
Comments
2 responses to “Semi-Deep Dreamweaver Voodoo…”
Hi, i runed into the same problem working with dreamweaver mx2004 while โInsert Record Form wizard” the result was an error: โWhile executing onChange in ServerObject-InsRecPHP.htm, a JavaScript error occurred.โ?. I look at what you write here but I do not anderstand what shoul i do to corect this error. If is not to much trouble i want to ask you to explain me in a way more simplistic what shoul i do, in way that i can understand. I’m not a newbie in this field and this error is above my skils. Tanks.
It means you have some field in your table named the same thing as a Dreamweaver XML keyword. In the example abive the offending item was “length”.
Change the name fo that field from “length” to something that isnt a keyword like “item_length” and all is well.