Wednesday, October 29, 2008

Invalid Parameter Submit.x in HTTP Post

I thought I'd done the code wrong though I was really wondering how it could go wrong with just some keys and values for my HTTP post. Usually, you'll just put the following code for your simple HTTP post, right?

< form method="post" action="(wherever you want to post this form to)" >

Upon posting, if you have images within the form, there will be additional parameters for its x and y positions. Thus if you're posting to a page which is strict with the parameters, you'll end up with an "invalid parameter" error or the like.

Just add an onsubmit attribute in your form tag to clean up the x and y parameters, like so:

< form method="post" action="(wherever you want to post this form to)" onsubmit="this.submit();return false;">

Thanks to webmasterworld for this info.

Monday, October 27, 2008

Using ClientFlags in ADODB Lite to Execute MySQL Stored Procedures

I am currently programming a cron in PHP using ADODB connection. (See sample connection.)

$dbConn =& ADONewConnection(DB_DRIVER);
$dbConn->Connect($dbServer, $dbUsername, $dbPassword, $dbName);
$dbConn->SetFetchMode(ADODB_FETCH_ASSOC);

I thought it worked fine but when I checked on the supposed updates in the database, I found that the stored proc wasn't executed. Upon checking on the net (and I might say it took a while on pinpointing the real problem due to limited sources), I found a solution that inserted the ff. code for clientflags similar with mysql connections:

$dbConn->clientFlags = 131074;

I needed to understand what 131074 means until I found an explanation (ironically on Drupal) with regards to this, telling that the value sets the client flags to CLIENT_MULTI_RESULTS.

The stored procedure doesn't know ahead of time how many results will be returned so the client needs to support reading any multiple of results.

So here's the corrected code:
$dbConn =& ADONewConnection(DB_DRIVER);
$dbConn->clientFlags = 131074;
$dbConn->Connect($dbServer, $dbUsername, $dbPassword, $dbName);
$dbConn->SetFetchMode(ADODB_FETCH_ASSOC);

Monday, September 1, 2008

How to View Content Body of Stored Procedure in MySQL

Unlike MSSQL's sp_helptext that lets you view the body of an SQL object (i.e. table, stored procedure, function), MySQL has different commands to view each object's contents.

The commands "show create procedure" and "show create function" are used to check on the contents of either a stored procedure or function, respectively. Simply append the name of the SP or function after the corresponding command like so:

show create procedure spGetData;


Note that you should have privileges for the said routine in order to display the contents of the SQL object. Otherwise, it would return NULL.
Your Ad Here