Latest Post

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the ne...

Thursday, April 23, 2009

Close window without the prompt message in IE7

If you tried to close a window using javascript window.close() method in IE7, and as you may noticed a message will prompt "The Webpage you are viewing is trying to close the window. Do you want to close this window". Because of the security enhancements in IE7, you can't close a window unless it is opened by a script. So the walkaround will be to let the browser thinks that this page is opened using a script then closing the window as outlined below.

Create a javascript function which will be called to close the window

function CloseMe(){'','_self','');

The code in bold is used to open a window in this case it's not defined into the current window. In this way, we let the browser thinks that the current window is opened using javascript, so when the window.close() is executed it will close it without the message being displayed.

You can now close the popup window by calling the CloseMe() function at the point where you want to close your page.

Hope this helps

Wednesday, April 8, 2009

mysql 'not a valid result resource' errors

Here's what's going on with 'not a valid result resource' errors. Take the following example:

PHP Code:
 $query 'SELECT * from table';
$result mysql_query($query);
$row mysql_fetch_array($result))
   { echo 
$row['foo']; }  
In the above, the mysql_query() function is sending the specific query to the database and returning a 'resource identifier', which is being set as the value of $result. These are not the results themselves -- if you echo $result at this point, you'll get 'Resource id #x'. The mysql_fetch_array() function in your while loop takes this resource identifier and creates an array of the actual db contents that you can use.

If your mysql_query() function fails to get a resource id, it returns a boolean FALSE instead. FALSE, of course, isn't a resource identifier, so when you try to pass it to mysql_fetch_array(), it will cough up the 'not a valid result resource' error. So all of you are getting failures in your mysql_query() function.

Using 'or die(mysql_error())' at the end of your mysql_query() call, will, instead of setting $result to FALSE, kill the script and, more importantly, return a more descriptive error message. 

Probably 80%+ of the time, a failed mysql_query() is caused by a syntax error in the query itself. Be especially mindful of any variables you're using in your query -- if they're not being set correctly, they can cause a syntax error. A failure to connect to the database can also cause mysql_query() to fail, so keep that in mind. Either way, the mysql_error() function will give you more information.

Thursday, April 2, 2009

My popular readings of the week

Microsoft Preps Open-Source Apps Marketplace
Microsoft is in the process of building out a marketplace for open-source applications that could work like an equivalent to an app store for applications, services and support for open-source technology that runs on the Windows platform. At MIX09, Microsoft released several components of the Microsoft Web Platform, an integrated set of tools, servers and frameworks that work seamlessly together and interoperate with popular open-source applications and products that are used in the community. Microsoft is looking at Windows Azure as a potential distribution platform for these applications. read more ...

Microsoft Open Sources .NET MVC Framework
Further evidence of Microsoft's growing commitment towards interoperability and open source — the ASP.NET MVC source code has been released under the Microsoft Public License (MS-PL). read more ...

Highly anticipated open-source releases coming in '09
When big companies release new software, they launch it with lots of hoopla: press tours, technical conferences, free T-shirts. Open-source projects, even the well-known ones, generally release their major new versions with a lot less fanfare. The FOSS (free and open-source software) community is often too busy coding and testing to bother with marketing, even when the new "point release" of the software is really remarkable. read more ...

More Stories

Chitika Ads