Sunday, October 10, 2010

PHP - @mysql_query vs. mysql_query

Don't you ever wonder the difference between @mysql_query vs. mysql_query, like I do? What does the "@" symbol do in here? Here is what I find out:

If error reporting is set to *show*, the @ symbol before a function call will prevent the error from displaying.

However, for MySQL, it would show the syntax error only. To display MYSQL returned errors, you would need to use mysql_error() or mysql_errno() functions.

Little details like above is always helpful... :)

Sunday, August 8, 2010

Add auto scroll bars to Silverlight app

Without below code, if your user control is bigger than browser's resolution, the scrollbars will not show.

private void Application_Startup(object sender, StartupEventArgs e)
{

ScrollViewer root = new ScrollViewer();
root.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
root.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
root.Content = new MainPage();
this.RootVisual = root;


}

Saturday, July 24, 2010

My Silverlight Application

Just finished my Silverlight Application. It was fun.

Annoying PHP warning - Cannot modify header information

All of sudden I got below error -

"Warning: Cannot modify header information - headers already sent by (output started at XXXXXX.php:23) in XXXXXX.php on line 143"

WTH!

Then searched online and found out that you should not have white spaces or blank lines before "?php", and after "?". Did that, still got the same error.

Do more researching..., and found out this - In the PHP.ini file, you need to turn on the buffer.
"output_buffering = On"

After I updated the this PHP.ini file, this annoying error is finally gone now.

More on MVC...

click here to view in full size


Sunday, July 11, 2010

Silverlight navigation - open a pop-up screen

Some useful code: Navigate to the next page in a pop-up window in Silverlight 3, if pop-up is allowed. If not allowed, navigate to it in the same window.

"HtmlPopupWindowOptions options = new HtmlPopupWindowOptions();
options.Left = 0;
options.Top = 0;
options.Width = 600;
options.Height = 400;
if (true == HtmlPage.IsPopupWindowAllowed)
{
HtmlPage.PopupWindow(new Uri("http://www.yahoo.com"), "new", options);
}
else //if pop up not allowed, to render it in the same page
{
HtmlPage.Window.Navigate(new Uri("http://www.yahoo.com", UriKind.Absolute));

}"

Sunday, July 4, 2010

PHP Trouble-Shooting and Self References

Session Warning

Problem: Start getting session warning today - "Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/dbconnect.php:10) ..."

Solution: To fix this issue, I had to move "session_start();" to the begining of the page. Then it all started working fine. This was not an issue before. I read from some posts that if you are using cookie based session, you need to call this statement before anything else. Anyway, log this for future reference, in case I forget about it, as I always do. ;)