You are here: Brisbane Web Design Blog
contact us

Windows

How to run a PHP script from command line

Posted in How To's, Web Development, Windows on July 9th, 2010 by Rachael – Be the first to comment

PHP is not only a powerful scripting language for web applications, but it can also be used to run command line scripts. This can be useful for running cron jobs, quickly testing a function, or running scripts which don’t need to be accessed via a web interface.

First, we need to set the path to the PHP executable, which we will use to run our script. This is found where PHP is installed. On Windows, we can set the path by opening the command console and typing:

PATH = %PATH%;path-to-php-executable;

This operation appends the path to the executable to the existing PATH variable.

Next we will edit our php.ini file to make use of short tags. Open up your version of PHP’s php.ini file (usually found where PHP is installed), and search for ’short_open_tag’, and ensure it says ’short_open_tag = On’. If it is off, change it to on. This simply allows us to use ‘‹?’ instead of the full PHP open tag ‘‹?php’.

Now we will create a new php file, called ‘myScript.php’. Insert the following code:

‹?
echo ‘Hello World! This is my first command line script’;
?›

Open up your command console in the directory where ‘myScript.php’ resides (tip: on Windows, you can do this by holding ‘Shift’ and right clicking on the directory folder and selecting ‘Open command window here’). We can run the script by typing into the console:

php myScript.php

console

There are some really handy options with the PHP executable. For example, you can check solely for syntax errors by running ‘php -l myScript.php’. Type ‘php -h’ for a full usage list.

How to take a screen shot on Windows and Mac

Posted in How To's, Web Design, Windows on September 2nd, 2009 by maurice – Be the first to comment

How to take a Print Screen

On Windows

1

First press the “Print Screen” button located on the top right of your keyboard (pictured right). Make sure you have exactly what you are wanting to capture opened at the time.

Note: For best aesthetical results, press the F11 button before doing step one when in a web browser. This will make the web brower appear in the “full screen” mode.

2

Open the Start bar and click on “All Programs”. Then navigate to the “Accessories” folder and click on the program called “Paint”. (pictured right)

3

Once in Paint, click “Edit” located at the top of the screen, and click “Paste”. This should paste the screen shot you took in step 1.

4

Now click File > Save As. Pick an appropriate place to save the file, like your Desktop. Now, pick a suitable file name, and finally make sure the “Save as type” has “JPEG” selected (!Important!).

Please note, if you are planning to email the screen shot, picking anything other than JPEG could result in a large file and take a long time to send (and to receive at the other end!)


Click to Enlarge

5

Your screen shot is now ready to be attached to an email, uploaded online, posted on a form, or used in a variety of ways. Enjoy!


On a Mac

Mac has a lot more functionally when taking a screen shot. There are ways to take a shot of only the window you are in, or manually select with the mouse what area you would like to take a shot of. But for this article I will show you the plainest, easier way to do this.

1

Simply hold down Command + Shift + Option + 8. This will take a full screenshot and save it to your desktop.

2

Your screen shot is now ready to be attached to an email, uploaded online, posted on a form, or used in a variety of ways.

Navicat MySQL 8.0.29 can’t connect to ntunnel_mysql.php Connection

Posted in Database, Troubleshooting, Windows on April 27th, 2009 by madhava – 14 Comments

UPDATE: This problem is now solved by a newer version of Navicat.
Thanks for everyones contributions to this thread and may Ntunnel rock on! :)

Navicat MySQL 8.0.29 can’t connect to ntunnel_mysql.php Connection
Error: 101 - wininet error # 126 : (Unknown WININET error)

Ok here’s a really strange one, if you’re reading this page you no doubt have the same error above as I did.

After lots of testing and Googling I have concluded the following:

- The problem is due to wininet.dll in the C:\windows\system32\ directory.
- The problem might in part be caused by Internet Explorer 8, apparently other users are reporting other similar errors since installing Microsofts latest FAIL piece of software.
- The problem seems to only effect Vista, (I am on SP1) however my Windows 7 build 7000 system was unaffected as was XP.

The solution?
People have been talking about replacing the dll with one from XP. I was hesitant to replace my Vista dlls with ones from half a decade ago. Instead I opted for the working Win7 Beta dll :)

EDIT:
If you don’t have a good wininet.dll handy, google around or download this one. Just remember I am not responsible if you damage your own system.

Download my wininet.dll from Windows 7 Beta build 7000

You will need WinRar to extract the archive

http://www.rarlab.com

It worked!

The only issue I had was actually replacing the file as it’s a system file and windows doesn’t take kindly to our kind around those parts.

I backed up my old file and then copied the Win7 version to my local machine.

The next step was to gain ownership of the file so I could replace it.

Step 1)
I downloaded a reg script which adds Right-Click “Take Ownership” functionality to your user account.
http://www.howtogeek.com/howto/windows-vista/add-take-ownership-to-explorer-right-click-menu-in-vista/
After I ran the reg file, I right clicked on the file C:\windows\system32\wininet.dll

Step 2)
To be sure, to be sure, I ran a command line ownership from my Administrator Level Command Prompt.
http://www.tech-recipes.com/rx/2204/vista_how_to_take_ownership_system_file/

takeown /f c:\windows\system32\wininet.dll

Step 3)
I then downloaded a nifty application called Replacer:
http://www3.telus.net/_/replacer/
Once running, I typed:
At the first prompt:
“C:\windows\system32\wininet.dll” <- this is my current version which must die
At the second prompt:
“C:\wininet.dll” <- this is the version I copied from my Win7 Build 7000 Beta box.
After a reboot my Navicat MySQL was connecting to ntunnel connections again.

Hooray!

Good bye: wininet error # 126 : (Unknown WININET error)
There might be some official fixes for this from Navicat and or Microsoft in the near future, but in the mean time this works.

Many of the other applications that use wininet.dll don’t seem to have problems so I am not sure what the conflict with Navicat is directly.

I have tested this on two machines now and both work great.

I am sure I won’t be the only person with Vista, IE8 and Navicat MySQL wanting to use an ntunnel connection.

Good luck!