Technologies Ignited

Technologies Ignited

How to downgrade your flash version in Google Chrome

leave a comment »

Here’s a tutorial in 6 small steps:

  1. Download the required version from http://helpx.adobe.com/flash-player/kb/archived-flash-player-versions.html
  2. Uninstall your flash version from Control Panel -> Programs and Features (Windows)
  3. Open chrome://plugins and disable the Flash plugin
  4. Install the required version, that you have downloaded
  5. Restart your Google Chrome
  6. Reopen chrome://plugins and check if the version is correct
Advertisements

Written by wyand

14 May 2012 at 11:43

Posted in Other

Tagged with ,

Debugging a PDO statement in a PHP system

leave a comment »

If you are wondering how to debug a PDO statement here are some advices.
There is no such thing as a final statement. If a statement looks like this:

SELECT group_id, count(*) AS cnt FROM chat_visited
WHERE user_id = :i_user_id GROUP BY group_id;

this is the way it’s sent to the database.
The parameters you bind withi this statement are declared as variables and the connecting between them happens on the database layer.

So how to debug such statement?

echo $stm->debugDumpParams();

will give you detailed information about the statement.

echo var_export($stm->errorInfo());

will give you the error of the statement.
In most cases the second line will be enought to debug your statements.

Written by wyand

7 May 2012 at 13:56

Posted in PHP

Tagged with ,

window.event does not work in FireFox

leave a comment »

window.event does not work well in FireFox. So if you are using something like this:

<textarea onkeypress="onButtonPressed()"></textarea>
function onButtonPressed()
{
	var key = window.event.keyCode;
	var shift = window.event.shiftKey;
	//DO SOMETHING
}

you will have problems. Here’s how to solve this problem:

<textarea onkeypress="onButtonPressed(event)"></textarea>

and define your javascript function the following way:

function onButtonPressed(event)
{
	if(event)
	{
		var key = event.keyCode;
		var shift = event.shiftKey;
	}
	else
	{
		var key = window.event.keyCode;
		var shift = window.event.shiftKey;
	}
	//DO SOMETHING
}

Written by wyand

25 April 2012 at 14:22

Posted in JavaScript

Tagged with ,

Set the auto-increment value of a table in MySQL

leave a comment »

Here’s the way to set the auto-increment value of a table in MySQL:
If the table exists:

ALTER TABLE groups AUTO_INCREMENT = 1234;

Here you have to be careful, because the new value must be greater than the current one.
Else you might have problems with duplicate primary key values.

If you are creating a new table:

CREATE TABLE IF NOT EXISTS groups (
  id int(11) NOT NULL AUTO_INCREMENT,
  value int(11) NOT NULL,
  PRIMARY KEY(id)
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1234;

The last and not so bright way is just to add multiple rows until you reach the required auto-increment value and then delete them.

Written by wyand

24 April 2012 at 16:56

Posted in Other

Tagged with ,

file_get_contents returns false on a new server

leave a comment »

If you’re using

$variable = file_get_contents($page);

and you are sure, that the $page page is available and the server has connectivity you can try using:

var_dump(file_get_contents($page));

If the result is

bool(false)

The function returns the read data or FALSE on failure.

You can check your php.ini if allow_url_fopen is as follows:

allow_url_fopen = On

Written by wyand

24 April 2012 at 10:39

Posted in Other

Tagged with ,

Scrolling an element to its bottom using jQuery

leave a comment »

Here’s a very nice example of scrolling a certain div to its bottom.
You might need such a thing, for example, if you are developing an ajax chat.
You must have the jQuery library loaded and in our case the div has id chatHolder.

	//Append the new content goes here
	//Getting the element's new height now
	var sHeight = $('#chatHolder')[0].scrollHeight;
	//Scrolling the element to the sHeight
	$('#chatHolder').scrollTop(sHeight);

Written by wyand

23 April 2012 at 11:41

Posted in Other

Tagged with , ,

Avoid confirm form resubmission

with one comment

Do you know we’ve moved on a new address. There will be no new articles on this blog anymore.┬áIf you still want to keep in touch with us, follow us @ Code Mamba!You can read the same article on our new domain by clicking here!
If you have a and you want to avoid the ‘confirm form resubmission’ message on refresh you can check theese advices:
If you’re able to change the POST variables to GET variables, you can use the idea from this script:

if(isset($_POST['query']))
{
	header
	(
		'Location: ?controller=currentPage&post1='
		.$_POST['post1'].'&post2='.$_POST['post2']
	); // and so on...
	exit;
}

If you can’t convert your variables, but your view does not depend on the posted data you can use the idea from this script:

	processPostData();
	header('Location: ?controller=currentPage');
	exit;

This will redirect you to ‘?controller=currentPage’ after processing the POST data and if you refresh the page you will stay on ‘?controller=currentPage’, but you will not get the ‘confirm form resubmission’ message, because you have no post data on the redirected page.
If you can’t convert your variables and your view depends on the posted data you can try and send only flag variables. You can use the idea from this script:

	if(processPostData() == isValid())
	{
		header('Location: ?controller=currentPage&flag=1');
	}
	else
	{
		header('Location: ?controller=currentPage&flag=0');
	}
	exit;

If none of theese works, just be creative or leave me a message here!

Written by wyand

28 November 2011 at 10:24

Posted in PHP

Tagged with , ,