And So I Become More of a PHP Expert (I guess...) and Learn Some Flash
It really, really is a small world. Since I've starting publishing about PHP and answering questions on the PHP-General mailing list, random questions keep trickling in. First there was a "Ravi" who popped up on Yahoo Messenger asking me about how to send attachments from PHP using the IMAP functions. It turns out he was in India over a 28.8 line looking for help from me. It was almost surreal but he was pleasant so I got him what he needed and sent him on his way. I heard from again on another question so I guess my solution the first time worked.
Next was a Flash designer from England, Wolfgang, trying to do some interesting things running PHP scripts from his Flash code. Now this was just plain neat. Here he was capturing user input from a Flash application and trying to execute it with his PHP code by calling the url. Here was the rough development process:
- Help! (Via Email)
- Collaborate. Understand. (Via Email and ICQ)
- Design the DB Tables and Write the initial SQL Queries.
- Debug until worked locally. Move to hosting environment.
Once the code was moved to the hosting environment, it, of course, failed to work. The first thing we looked at was MySQL versions. The hosting had 2.37 versus 3.23*. Yikes. A quick jaunt to MySQL failed to reveal a version history (not that I could find easily at least) so I figured that the right thing to do was to look at the MySQL error messages. Given that the PHP script was being called from within the Flash application, all errors were being suppressed. My solution was to take a value as sent by the flash app, add it to the script as a variable and then run the script natively against the db. I also had Wolfgang change his query execute statement to be this:
$result = mysql_query($query) or die ('<H1 align=center><font color=red>Bad Database Request</font></H2> in :<BR>' .__FILE__ .' line '.__LINE__ .'<BR><br /><b>The query used was:</b><BR><BR> '.$query .'<BR><br /><b>MySQL says</b><BR><BR> '.mysql_error() .'<BR><BR>Email administrator for help at ' . $sysadminemail . ' for help' );
What this result statement does is (violently) display the error along with all error messages from the db that you don't necessarily see. I picked this up on the PHP-General mailing list from someone that I'd love to give credit to but can't remember the name. Wolfgang made the change and Voila! It turned out to be a quote error. A little Lingo code to fix the slashes and it worked just fine.
Why did this work locally, not remote?
Given that quote handling is always needed for MySQL (or any db usually), why did this happen only from Flash? Its unclear but my guess is that one server had "MagicQuotes" turned on and the other didn't. MagicQuotes attempts to handle this for you by processing all post and get requests without your knowledge. IMHO, its a brilliant idea in theory and a bloody abortion in practice. Given that you know that you need to escape the quotes, skilled developers end up with "quotitis" in their database. It cost me most of a weekend once. Watch out for this.
Anyway, Looking for a Very Talented Designer / Flash Designer?
In summary, I've learned some Flash, helped some folks and made a valuable contact. Looking for a talented designer, take a look at:
Nice guy, easy to work with, high quality stuff. Recommended.
9:18:02 AM
|