In Feburary 2016 25,
The list of permissions you supply to the 'mkdir' function are valid only on Linux-based file systems. This means you cannot associate permissions with a directory you create under Windows. If you pass permissions with the 'mkdir' function under Windows, PHP simply ignores them.
Default User Account
Remember that a script run on a Web server from a browser runs under the default user account on the Web server such as 'www-data,' not under your user account. If directory permissions are not working, it may be because you are testing a script under your account instead of the default user account. You can test the script as the default user by typing 'su www-data' and exploring the directory permissions assigned to that user.
Directory Mask
If the resulting permissions of a new directory are different from what you passed, it may be because of a directory mask applied to the permissions. The mask is maintained by the Web server, not by PHP. To circumvent the mask, use the 'umask' function to set the mask to zero, create the directory using 'mkdir' and change the directory permissions using the 'chmod' function. For example:
$save = umask(0);
if (mkdir($newdir)) chmod($newdir, 0755);
umask($save);
?>
Recursive Assignment
The 'mkdir' function takes a second optional argument that creates nested directories recursively. When you assign directory permissions recursively, the permissions may not be executed in the proper order and you might get different results from what you expected. To ensure the proper order, use the 'chmod' function to assign directory permissions to the new directory after you create it with the 'mkdir' function. For example:
if (mkdir($newdir, 0755, true)) chmod($newdir, 0755);
?>
In Feburary 2016 25,
Showing posts with label script. Show all posts
Showing posts with label script. Show all posts
Thursday, 25 February 2016
Monday, 22 February 2016
How to Read an XLS File in PHPIn Feburary 2016 22,
In Feburary 2016 22,
Go to the PHP Excel Reader download site, and download the package called 'php-excel-reader' (see Resources).
Unzip the downloaded file by double-clicking on it.
Upload the file called 'excel_reader2.php' to your website. Use FTP or your Web hosting service's file upload service to do this. The file should be placed in a folder where your PHP scripts can find it. You can put it in the same folder as the PHP script you wish to read Excel files in, or you can put it in a folder that is in the 'include path.' The 'include path' is a set of folders where you can put files that your PHP script will always be able to find, even if your script is in a totally different place. Your website might have a folder called 'includes' that is in the include path. If it does, put 'excel_reader2.php' there. If it doesn't, put it in the same folder as the PHP scripts with which you wish to use it.
Read an XLS File
Upload an Excel file to use as an example. Create a simple Excel file, and save it as 'example.xls'. Open the file and fill in the first three columns of the first row with the words 'column 1', 'column 2' and 'column 3'. Then on the second row, fill the first three columns with the text '1-1', '2-1' and '3-1'. Then fill the first three columns of the third row with the text '1-2', '2-2' and '3-2'. Save the file and upload it to the same folder where you uploaded excel_reader2.php.
Open your favorite text editor, and save a text file called 'example.php'. This will be your PHP script for this tutorial.
Write your PHP script to open the Excel file, read the table of data and then print the data out in the user's Web browser. Use this code to do it:
rowcount(); $r++) { //walk through each rowfor ($c = 1; $c
colcount(); $c++) { //walk through each column
echo $xls->raw($r, $c) . ' '; //Display the data in that cell
}echo '\n'; //make a new line at the end of each row} echo '
'; //close the HTML we made earlier?>
Save and upload your PHP file to your website. If you were able to put PHP Excel Reader in the include path, you may put your PHP file wherever you wish. If not, put your PHP file in the same folder as PHP Excel Reader.
To check your work, visit example.php in your Web browser. You should see the table of data from your Excel file printed in your browser window.
In Feburary 2016 22,
Go to the PHP Excel Reader download site, and download the package called 'php-excel-reader' (see Resources).
Unzip the downloaded file by double-clicking on it.
Upload the file called 'excel_reader2.php' to your website. Use FTP or your Web hosting service's file upload service to do this. The file should be placed in a folder where your PHP scripts can find it. You can put it in the same folder as the PHP script you wish to read Excel files in, or you can put it in a folder that is in the 'include path.' The 'include path' is a set of folders where you can put files that your PHP script will always be able to find, even if your script is in a totally different place. Your website might have a folder called 'includes' that is in the include path. If it does, put 'excel_reader2.php' there. If it doesn't, put it in the same folder as the PHP scripts with which you wish to use it.
Read an XLS File
Upload an Excel file to use as an example. Create a simple Excel file, and save it as 'example.xls'. Open the file and fill in the first three columns of the first row with the words 'column 1', 'column 2' and 'column 3'. Then on the second row, fill the first three columns with the text '1-1', '2-1' and '3-1'. Then fill the first three columns of the third row with the text '1-2', '2-2' and '3-2'. Save the file and upload it to the same folder where you uploaded excel_reader2.php.
Open your favorite text editor, and save a text file called 'example.php'. This will be your PHP script for this tutorial.
Write your PHP script to open the Excel file, read the table of data and then print the data out in the user's Web browser. Use this code to do it:
rowcount(); $r++) { //walk through each rowfor ($c = 1; $c
colcount(); $c++) { //walk through each column
echo $xls->raw($r, $c) . ' '; //Display the data in that cell
}echo '\n'; //make a new line at the end of each row} echo '
'; //close the HTML we made earlier?>
Save and upload your PHP file to your website. If you were able to put PHP Excel Reader in the include path, you may put your PHP file wherever you wish. If not, put your PHP file in the same folder as PHP Excel Reader.
To check your work, visit example.php in your Web browser. You should see the table of data from your Excel file printed in your browser window.
In Feburary 2016 22,
Saturday, 20 February 2016
How to Add a Foreign Key to MySQLIn Feburary 2016 20,
In Feburary 2016 20,
Click the Windows 'Start' button and click 'All Programs.' Click 'MySQL' and then click 'MySQL Workbench' to open your main console.
Click 'Edit SQL Script' in the main console window. This opens a SQL editor where you create the foreign key.
Type the following code into your editor:alter table table_name add constraint key_name foreign keyreferences tbl_name primary_keyThe first line sets the foreign key. Replace 'table_name' with the name of your table. 'Key_name' is the name of the column in your table you want to set as the foreign key. The second line is the primary key information to link to the foreign key. Replace 'tbl_name' with the table that contains the primary key and 'primary_key' with the primary key column name.
Click 'Run' to run your SQL statement. The foreign key is created, and your tables are set up with the linked attributes.
In Feburary 2016 20,
Click the Windows 'Start' button and click 'All Programs.' Click 'MySQL' and then click 'MySQL Workbench' to open your main console.
Click 'Edit SQL Script' in the main console window. This opens a SQL editor where you create the foreign key.
Type the following code into your editor:alter table table_name add constraint key_name foreign keyreferences tbl_name primary_keyThe first line sets the foreign key. Replace 'table_name' with the name of your table. 'Key_name' is the name of the column in your table you want to set as the foreign key. The second line is the primary key information to link to the foreign key. Replace 'tbl_name' with the table that contains the primary key and 'primary_key' with the primary key column name.
Click 'Run' to run your SQL statement. The foreign key is created, and your tables are set up with the linked attributes.
In Feburary 2016 20,
Friday, 12 February 2016
How to Make a Proxy WebsiteIn Feburary 2016 12,
In Feburary 2016 12,
Open an account at a web host that allows proxy websites. Many hosting companies do not allow proxies because they can generate a large amount of traffic that overloads the servers. Those that do allow proxy websites will typically prefer that you have a Virtual Private Server (VPS) or a dedicated server. Most hosts do not allow web proxies on a shared server.
Obtain a copy of PHProxy. This script acts as the software to power your proxy site. PHProxy is available free of charge, so anyone can make a proxy website without spending a lot of money.
Log into the control panel for your web hosting account. Create a MySQL database that will be used by the PHProxy script. Make note of the database name, user name and password that is associated with the database. This information is needed to configure the script to communicate with the database.
Edit the config.php file that is included with the script. Open the file with a HTML editor so that you can edit the contents of the file and save the new copy. Use Windows Notepad if you do not have a HTML editor. Simply open the file, edit the website name, website address, database name, database user name and database password. Save the file after the information has been edited.
Use an FTP program to upload all of the files to your hosting account. You can download a free copy of Filezilla FTP if you do not already have a program. Simply upload all of the files and folders included with PHProxy to your web hosting account. Your proxy website should now be operational.
Read the documentation that is included with PHProxy. Follow the instructions in the documentation to customize your script, such as changing colors, page layout or other visual elements. This will help you make a FTP website that stands out.
In Feburary 2016 12,
Open an account at a web host that allows proxy websites. Many hosting companies do not allow proxies because they can generate a large amount of traffic that overloads the servers. Those that do allow proxy websites will typically prefer that you have a Virtual Private Server (VPS) or a dedicated server. Most hosts do not allow web proxies on a shared server.
Obtain a copy of PHProxy. This script acts as the software to power your proxy site. PHProxy is available free of charge, so anyone can make a proxy website without spending a lot of money.
Log into the control panel for your web hosting account. Create a MySQL database that will be used by the PHProxy script. Make note of the database name, user name and password that is associated with the database. This information is needed to configure the script to communicate with the database.
Edit the config.php file that is included with the script. Open the file with a HTML editor so that you can edit the contents of the file and save the new copy. Use Windows Notepad if you do not have a HTML editor. Simply open the file, edit the website name, website address, database name, database user name and database password. Save the file after the information has been edited.
Use an FTP program to upload all of the files to your hosting account. You can download a free copy of Filezilla FTP if you do not already have a program. Simply upload all of the files and folders included with PHProxy to your web hosting account. Your proxy website should now be operational.
Read the documentation that is included with PHProxy. Follow the instructions in the documentation to customize your script, such as changing colors, page layout or other visual elements. This will help you make a FTP website that stands out.
In Feburary 2016 12,
Monday, 8 February 2016
How to Split a String Into Two Variables in PowerShellIn Feburary 2016 08,
In Feburary 2016 08,
Start Windows PowerShell by clicking the Windows 'Start' button and typing 'powershell' into the 'Search programs and files' text box. This will open the Windows PowerShell console.
Type 'notepad split.ps1' in the PowerShell console to open Microsoft Notepad and create a new script called 'split.ps1.' Click 'Yes' when prompted by Notepad to allow the new file to be created.
Type the following commands into the new file, then save the file:$text = 'Windows PowerShell - Hello world!'$split = $text.split('-')echo $split[0]echo $split[1]First, a string is created named '$text' which holds the text to be split. The string is then split using the PowerShell 'Split' function, passing in the character the string is to be split by. In the code above, the string is split at the location of the hyphen. This creates an array in '$split' with two elements. The first element contains all the text up to the hyphen and the second element contains all the text after the hyphen. The contents of the two elements are then displayed to verify the command has worked.
Run the script in PowerShell by typing '.\split.ps1' and the display will show the output below, indicating the command was successful:Windows PowerShellHello World!
In Feburary 2016 08,
Start Windows PowerShell by clicking the Windows 'Start' button and typing 'powershell' into the 'Search programs and files' text box. This will open the Windows PowerShell console.
Type 'notepad split.ps1' in the PowerShell console to open Microsoft Notepad and create a new script called 'split.ps1.' Click 'Yes' when prompted by Notepad to allow the new file to be created.
Type the following commands into the new file, then save the file:$text = 'Windows PowerShell - Hello world!'$split = $text.split('-')echo $split[0]echo $split[1]First, a string is created named '$text' which holds the text to be split. The string is then split using the PowerShell 'Split' function, passing in the character the string is to be split by. In the code above, the string is split at the location of the hyphen. This creates an array in '$split' with two elements. The first element contains all the text up to the hyphen and the second element contains all the text after the hyphen. The contents of the two elements are then displayed to verify the command has worked.
Run the script in PowerShell by typing '.\split.ps1' and the display will show the output below, indicating the command was successful:Windows PowerShellHello World!
In Feburary 2016 08,
Thursday, 4 February 2016
How to Fix the Ran Online Script ErrorIn Feburary 2016 04,
In Feburary 2016 04,
Click the 'Tools' menu in the Internet Explorer window.
Click the 'Internet Options' button.
Click on the 'Advanced' tab.
Click the 'Disable Script Debugging' tab.
Click the 'OK' button.
Unblock Active Scripting
Open Internet Explorer.
Click the 'Tools' button and then click the 'Internet Options' menu.
Click the 'Security' tab.
Click 'Default Level.'
Click the 'OK' button.
Remove Temporary Internet Files
Open Internet Explorer.
Click the 'Tools' button and then click 'Internet Options.'
Click on the 'General' tab. Click the 'Settings' button under the 'Temporary Internet Files' menu.
Click 'Delete' files and click 'OK.' Click the 'Delete Cookies' button and then click the 'OK' button.
Click the 'Clear History' button and then click 'Yes.' Click the 'OK' button.
In Feburary 2016 04,
Click the 'Tools' menu in the Internet Explorer window.
Click the 'Internet Options' button.
Click on the 'Advanced' tab.
Click the 'Disable Script Debugging' tab.
Click the 'OK' button.
Unblock Active Scripting
Open Internet Explorer.
Click the 'Tools' button and then click the 'Internet Options' menu.
Click the 'Security' tab.
Click 'Default Level.'
Click the 'OK' button.
Remove Temporary Internet Files
Open Internet Explorer.
Click the 'Tools' button and then click 'Internet Options.'
Click on the 'General' tab. Click the 'Settings' button under the 'Temporary Internet Files' menu.
Click 'Delete' files and click 'OK.' Click the 'Delete Cookies' button and then click the 'OK' button.
Click the 'Clear History' button and then click 'Yes.' Click the 'OK' button.
In Feburary 2016 04,
Subscribe to:
Posts (Atom)