• Home
    • Payments
  • Tools
    • Color Chart
  • Software
    • Windows tricks
      • Windows 11 Speed Up Tricks
      • Windows Command Prompt CMD
    • Android Phone
      • Android – Dangerous Settings to Turn Off
    • Projects
      • Copy Files
      • Php Autoscript
      • Web Tools
  • Notes
    • How to Code
    • System Tips
  • News
    • Comparing SSD to HDD

How to Code

ACCESS 2022 | Browsers | Css | Htacess | Html | Html5 | Javascript | Microsoft Excel | Mysql | Mysql Dumps | Php | Vb.net | VBscript | Windows <=8 | Windows >=10 | WP | WP Plugin | WP Themes | _Misc Software |

ABCDEFGHIJKLMNOPQRSTUVWXYZ
ON
PRT
OFF

<- Look Inside Data
Conditions:
Order:
1|2|3|4|5|6|7|8|
50 Language Operation Title
Keywords
Application
Code Languageid
Show Html
Show Iframe
Make Public
Viewed
Viewed Date
Microsoft Excel Language IF Usage In Excel
if( AND
Microsoft Excel



4
05/05/2026
Microsoft Excel Pdf Printing Group Of Sheets
create pdf worksheet groups excel
When you print a Microsoft Excel workbook to the Adobe PDF printer or the Acrobat Distiller printer, and the Print Entire Workbook option is selected in the Print dialog box, more than one PDF file is created (for example, Workbook 1, Workbook 2, and Workbook 3).

Solutions

Do one or more of the following:

Make sure that the print quality setting is the same for all of the worksheets in the workbook.

1. In Excel, hold down the Ctrl key (Windows) or the Shift key (Mac OS), and select all of the sheets in the Excel workbook.

2. Choose File > Page Setup > Page > Print Quality, and select a print quality setting. Adobe Technical Support recommends that you select 600 dpi, which is the default setting for the Adobe PDF and Acrobat Distiller printers.

I selected active sheets and pdf worked. Right click a tab to Ungroup the sheets.

Print the workbook to a PostScript file, and then use Acrobat Distiller to convert the PostScript file to a PDF file.

Print the workbook to a PostScript file using the Adobe PostScript printer driver (AdobePS), then use Acrobat Distiller to convert the PostScript file to a PDF file. Adobe Technical Support has achieved more consistent results using Acrobat Distiller when converting an Excel workbook to PDF.

Select Print Entire Workbook in the Print dialog box in Excel.

Select all of the sheets in the Excel workbook, then select the Print Entire Workbook option in the Print dialog box. To select multiple sheets, hold down the Control key (Windows) or the Shift key (Mac OS).
Microsoft Excel



1529
05/05/2026
Mysql Database Alter Table
change table alter table
Mysql



4
05/05/2026
Mysql Database Does Field Exit In Table
field exists
Developer
Mysql



2
05/05/2026
Mysql Database MySQL ALTER TABLE Statement
alter table drop add index modify
ALTER TABLE prices
ADD COLUMN inventory smallint AFTER invoice;

ALTER TABLE eqMaintenance ADD COLUMN filter2id smallint AFTER filterid

ALTER TABLE filters ADD COLUMN model varchar(75) AFTER description
ALTER TABLE filters ADD COLUMN code varchar(10) AFTER model

ALTER TABLE filters ADD COLUMN cost decimal (10,2) AFTER type_of
ALTER TABLE fertilizer_applied ADD COLUMN crop_year smallint AFTER acres

=================================
Add Table & Index
ALTER TABLE `map` ADD `crop_year` SMALLINT NOT NULL AFTER `crop`, ADD INDEX `cropYearIndex` (`crop_year`);

increase size:
ALTER TABLE `map` MODIFY `img` varchar (40);
ALTER TABLE table_name MODIFY COLUMN column_name SMALLINT;
ALTER TABLE `bible` MODIFY COLUMN `chapter` SMALLINT;
ALTER TABLE `transactions` MODIFY `description` varchar (400);
ALTER TABLE `lastbackup` MODIFY `source` varchar (500);
ALTER TABLE `fertilizer_applied` MODIFY `comments` varchar (400);

ALTER TABLE `purchases` MODIFY `description` varchar (400);
ALTER TABLE `equipment_photo` MODIFY `caption` varchar (100);


MySQL ALTER TABLE Statement
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

The ALTER TABLE statement is also used to add and drop various constraints on an existing table.

ALTER TABLE - ADD Column
To add a column in a table, use the following syntax:

ALTER TABLE table_name
ADD column_name datatype;
The following SQL adds an "Email" column to the "Customers" table:

ExampleGet your own SQL Server
ALTER TABLE Customers
ADD Email varchar(255);
ALTER TABLE - DROP COLUMN
To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column):

ALTER TABLE table_name
DROP COLUMN column_name;
The following SQL deletes the "Email" column from the "Customers" table:

Example
ALTER TABLE Customers
DROP COLUMN Email;
ALTER TABLE - MODIFY COLUMN
To change the data type of a column in a table, use the following syntax:

ALTER TABLE table_name
MODIFY COLUMN column_name datatype;
Mysql



2
05/05/2026
Mysql Database Query Language
num show
Developer
1. Using the SHOW TABLES Command:

You can use the SHOW TABLES command to list all tables in a specific database and then check if your table is among them.

SHOW TABLES LIKE 'your_table_name';
Mysql



2
05/05/2026
Mysql Database Truncate A Table
empty truncate delete
Empty Tables
TRUNCATE TABLE parts

When you truncate a table, the AUTO_INCREMENT counters on the table will be reset.
MySQL truncates the table by dropping and creating the table. Thus, the DELETE triggers for the table do not fire during the truncation.
Starting in MySQL 5.5, you can not truncate an InnoDB table that is referenced by a foreign key in another table.
Starting in MySQL 5.6, you can not truncate a NDB table that is referenced by a foreign key in another table.

Example

In MySQL, truncating a table is a fast way to clear out records from a table if you don't need to worry about rolling back. In most cases, MySQL handles the process of table truncation a bit differently than other databases such as Oracle or SQL Server.

Let's look at an example of how to use the TRUNCATE TABLE statement in MySQL.

For example:

TRUNCATE TABLE customers;

This example would truncate the table called customers and remove all records from that table.

It would be equivalent to the following DELETE statement in MySQL:

DELETE FROM customers;

Both of these statements would result in all data from the customers table being deleted. The main difference between the two is that you can roll back the DELETE statement if you choose, but you can't roll back the TRUNCATE TABLE statement.

Let's look at one more example where we prefix the table name with the database name.

For example:
Mysql



2
05/05/2026
Mysql Database Using IF In Your Sql Statements
if query
Filtering By Formula
n MySQL, you can use the
IF() function to implement conditional logic directly within your SQL queries.
MySQL IF() function syntax:
sql

IF(condition, value_if_true, value_if_false)

IF(hour=1, (eqMaintenance.intervalof -(equipment.hours -eqMaintenance.hours)), (eqMaintenance.intervalof -(equipment.hours -eqMaintenance.miles)) AS DIFFERENCE

ORDER BY DIFFERENCE
Parameters:

condition: The condition to evaluate.
value_if_true: The value to return if the condition is true.
value_if_false: The value to return if the condition is false.

Example using IF() in a SELECT statement:
sql

SELECT product_id, price, IF(price > 100, 'Expensive', 'Affordable') AS category FROM products;

This query uses the IF() function to categorize products as 'Expensive' if the price is greater than 100, and 'Affordable' otherwise.
Using IF() with PHP:
You can incorporate the MySQL IF() function into your PHP code when constructing SQL queries. For example, to display a message based on the result of a database query, you can use PHP's if statements to handle different scenarios:
Mysql



3
05/05/2026
Mysql Date ADDDATE - Mysql
add date mysql
Mysql



5
05/05/2026
Mysql Date Select The MAX Date Of Each ID
max date unique group
Php
Mysql



4
05/05/2026
Mysql Query Generate The CREATE TABLE Statements
table create exec(
Table Dump
CREATE TABLE `cash` (
`cashid` mediumint(9) NOT NULL AUTO_INCREMENT,
`amount_total` smallint(6) NOT NULL,
`amount_split` smallint(6) NOT NULL,
`caleb` smallint(6) NOT NULL,
`jarrod` smallint(6) NOT NULL,
`received_on` datetime NOT NULL,
`farm` tinyint(4) NOT NULL,
`cutting` tinyint(4) NOT NULL,
`chk_cash` tinyint(4) NOT NULL,
`bale_count` smallint(6) NOT NULL,
`comment` varchar(50) NOT NULL,
`ave_price` decimal(8,2) NOT NULL,
PRIMARY KEY (`cashid`),
KEY `received_on` (`received_on`)
) ENGINE=MyISAM AUTO_INCREMENT=1683 DEFAULT CHARSET=latin1

CREATE TABLE `lastbackup` (
`backupid` mediumint(9) NOT NULL AUTO_INCREMENT,
`to` tinyint(4) NOT NULL,
`type` tinyint(4) NOT NULL,
`method` tinyint(4) NOT NULL,
`device` varchar(30) NOT NULL,
`table_name` varchar(30) NOT NULL,
` database_name` varchar(30) NOT NULL,
`destination` varchar(50) NOT NULL,
`received_on` datetime NOT NULL,
PRIMARY KEY (`backupid`),
KEY `received_on` (`received_on`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1




Programmatically with PHP
You can write a PHP script to connect to your MySQL database and execute queries to generate the CREATE TABLE statements. This is useful for building custom backup tools.
The following approach involves fetching table metadata and reconstructing the SQL, or leveraging PHP's ability to execute shell commands like mysqldump for simplicity:

Executing mysqldump from PHP: This method executes the command-line utility within your PHP script, which is often the most reliable way to get a perfect SQL structure dump.

php

=?php
$db_user = "your_username";
$db_pass = "your_password";
$db_name = "your_database";
$table_name = "your_table";
$output_file = "structure_export.sql";

// Command to export only the structure (--no-data)
$command = "mysqldump -u" . $db_user . " -p" . $db_pass . " " . $db_name . " " . $table_name . " --no-data > " . $output_file;

// Execute the command
exec($command, $output, $return_var);

if ($return_var === 0) {
echo "Table structure exported successfully to " . $output_file;
} else {
echo "Error exporting table structure.";
}
?=


=?php
ALL TABLES
function backup_mysql_database($host, $user, $pass, $dbname, $filename) {
// Ensure the output file has a .sql extension for clarity
if (substr($filename, -4) !== '.sql') {
$filename .= '.sql';
}

// Command to execute mysqldump:
// --opt is enabled by default and is recommended for speed and size
// --single-transaction allows a consistent backup without locking tables for InnoDB tables
$command = sprintf(
'mysqldump -h%s -u%s -p%s --opt --single-transaction %s > %s',
escapeshellarg($host),
escapeshellarg($user),
escapeshellarg($pass),
escapeshellarg($dbname),
escapeshellarg($filename)
);

$output = [];
$result_code = 0;

// Execute the command
exec($command, $output, $result_code);

if ($result_code === 0) {
return "Database dump successful. File saved as: $filename";
} else {
return "Error creating database dump. Command output: " . implode("n", $output);
}
}

// Configuration variables
$DBHOST = 'localhost';
$DBUSER = 'your_username';
$DBPASS = 'your_password';
$DBNAME = 'your_database_name';
$BACKUP_FILE = 'backup_' . date('Y-m-d_H-i-s') . '.sql';

// Run the backup function
$message = backup_mysql_database($DBHOST, $DBUSER, $DBPASS, $DBNAME, $BACKUP_FILE);

echo $message;
?=



=?php
$command = "ls -l"; // Command to list files and directories (on Unix-like systems)
$output_lines = [];
$return_status;

// Execute the command, capture output lines into $output_lines,
// and capture the exit code into $return_status
exec($command, $output_lines, $return_status);

echo "Command Executed:";
echo "$command";

echo "Output Lines:";

print_r($output_lines);
echo "Return Status:";
echo "$return_status"; // 0 usually means success
?=
Mysql



3
05/05/2026
Mysql Query Concat
concat mysql query
UPDATE parts SET pdf=CONCAT(partid,'.pdf'), part_image=CONCAT(partid,'.jpg') WHERE pdf=""

This example numbers the picture names to match the id of the record.

APENDING data before and after a field.
UPDATE `iwspackage` SET iwspackageimg=CONCAT('package',packageid,'.jpg');

UPDATE ads SET img1=CONCAT(adid,'a.jpg'), img2=CONCAT(adid,'b.jpg') , img3=CONCAT(adid,'c.jpg') , img4=CONCAT(adid,'d.jpg'), pdf=CONCAT(adid,'.pdf') WHERE adid>7;
Mysql



1935
05/05/2026
Mysql Query Group By
group by left join
SELECT category,categories.categoryid, COUNT(ads.categoryid) AS junk FROM categories LEFT JOIN ads ON categories.categoryid=ads.categoryid GROUP BY category ORDER BY category


SELECT products.productname, soldout, restock, count( orderedproducts.productid )
FROM categories, products, orderedproducts, orders
WHERE filled = 'Y'
AND orders.orderid = orderedproducts.orderid
AND orderedproducts.productid = products.productid
AND categories.catid = products.catid
AND orders.date>='2010-04-01' AND orders.date<='2010-04-30'
GROUP BY productname


SELECT * FROM `orderedproducts INNER JOIN orders ON orders.orderid=orderedproducts.orderid WHERE orders.date>='2010-04-01' AND orders.date<='2010-04-30'
Mysql



1333
05/05/2026
Mysql Query Finding Orphans Using Left Join
orphan parent left join null
Select * from table1groups left join table1 on table1groups.musgraveid=table1.musgraveid Where table1.musgraveid IS NULL LIMIT 0, 30

The results list only the records that do not have a parent
Mysql



1479
05/05/2026
Mysql Query Alter Tables
add field delete alter table rename update table auto increment engine collation
Mysql



1772
05/05/2026
Mysql Query Using INFORMATION_SCHEMA.COLUMNS To Retrieve Varchar Sizes
field size field length
Field Size Counter
php example stored field in an array
$r=new mysqli_swd();
$sql = "SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$database' AND TABLE_NAME = 'purchases' AND (DATA_TYPE = 'varchar' OR DATA_TYPE = 'text')";
$r->dbsql($sql);$result=$r->data;$num=$r->num;
if ($num > 0) {
while($row = $result->fetch_assoc()) {
$res[$row["COLUMN_NAME"]]= $row["CHARACTER_MAXIMUM_LENGTH"];
}
}
Mysql



2
05/05/2026
Mysql Query Different Types Of Queries
sum
Create Queries

SUM

SELECT SUM(amount) AS total_amount FROM orders;
Mysql



2
05/05/2026
Mysql Dumps Archive Database: `softwax3_myfiles
file contact
Mysql Dumps



5
05/05/2026
Mysql Dumps Archive Database: `softwax3_codeSaver`
code language operation
Backup
Mysql Dumps



5
05/05/2026
Php Archive Software Web Activation.php
reg75
Reg75.php
Php



4
05/05/2026
Php Archive Color Change Script
color convert javascript step
Home Page
Php



9
05/05/2026
Php Archive Code Zoom Backup Code
zoom format html_entity_decode
Codezoom.php
Php



2
05/05/2026
Php Archive Hempdbase Code Saved
hemp potency importPDF
Php



0
06/04/2026
Php Constants Setting The Absolute Path
absolute path define constant
Library
Php



5
05/05/2026
Php Customizing Convert Words Into A Graphic
text graphic image convert
$im = imagecreate(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);


*************************************
The below script would be called with a tag like this from a page:

Header("Content-type: image/gif");
if(!isset($s)) $s=11;
$size = imagettfbbox($s,0,"/fonts/TIMES.TTF",$text);
$dx = abs($size[2]-$size[0]);
$dy = abs($size[5]-$size[3]);
$xpad=9;
$ypad=9;
$im = imagecreate($dx+$xpad,$dy+$ypad);
$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "/fonts/TIMES.TTF", $text);
ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "/fonts/TIMES.TTF", $text);
ImageGif($im);
ImageDestroy($im);
?>

It is very important to realize that you cannot put any HTML tags in this file. There should also not be any spaces or blank lines before or after the tags. If you are getting a broken image using this script, chances are you have a stray carriage return somewhere outside the PHP tags
Php



1862
05/05/2026
Php Customizing Rename A File In PHP
rename file
Change File Names
rename a file in PHP, use the built-in
rename() function. This function takes the old filename/path and the new filename/path as mandatory arguments and returns true on success or false on failure.
rename() Function Syntax


rename($oldname, $newname, $context);

$oldname (Mandatory): Specifies the current name/path of the file or directory.
$newname (Mandatory): Specifies the new name/path for the file or directory.
$context (Optional): Specifies the behavior of the stream.
Php



2
05/05/2026
Php Customizing Using Strip_tags
strip tags html
Unwanted Table Breaks
Php



2
05/05/2026
Php Customizing Code That Is Being Debugged
backup debug testing
Php Script
Php



1
05/18/2026
Php Database Concat - Combine Fields Or Text
add join concat
Php



3
05/05/2026
Php Database Count
count query

count records that link to same file


$sql="SELECT * FROM eqMaintenance WHERE maintenanceid = $value_";
$r->dbsql($sql);$row=$r->data1;
$upfile="../maintenance/".$row['img'];

Start count query


$sql="SELECT count(img) as dog FROM eqMaintenance WHERE img='".$row['img']."' GROUP BY img";
$r->dbsql($sql);$dog=$r->data1[0];
if(file_exists($upfile) && $dog<2)unlink($upfile);

//example from php file creator

SELECT hide,count(hide) as dog FROM `invoice` GROUP BY hide LIMIT 0, 30

SELECT invoices.customerid, `last_name` , `first_name`, COUNT(`last_name`) AS dog,
count(if(`date`< ADDDATE(NOW(), INTERVAL -365 DAY), 1, null)) AS year1, count(if(`date`>= ADDDATE(NOW(), INTERVAL -365 DAY), 1, null)) AS year0, count(if(`date`< ADDDATE(NOW(), INTERVAL -730 DAY), 1, null)) AS year2
FROM `invoices`
INNER JOIN `customer` ON customer.customerid = invoices.customerid
GROUP BY invoices.customerid, `last_name` , `first_name`
ORDER BY year0,year1
Php



4
05/05/2026
Php Database Delete
left join delete orphans
Php



3
05/05/2026
Php Database Find Orphans
left join orphan delete
Php



3
05/05/2026
Php Database Group By
group by inner join
Php



3
05/05/2026
Php Database Insert Table
insert table
Php



3
05/05/2026
Php Database Insert Using Select
insert select
Php



3
05/05/2026
Php Database Variable Lenghts
variable description size
Php



2
09/09/2023
Php Database Inserting Multiple Rows Into A Table
insert multiple records
Database
Php



1
05/05/2026
Php Date Date Functions
time date
$sessionid=strtotime(date("Y-m-d H:i:s"));

format character Description Example returned values
a Lowercase Ante meridiem and Post meridiem am or pm
A Uppercase Ante meridiem and Post meridiem AM or PM
B Swatch Internet time 000 through 999
c ISO 8601 date (added in PHP 5) 2004-02-12T15:19:21+00:00
d Day of the month, 2 digits with leading zeros 01 to 31
D A textual representation of a day, three letters Mon through Sun
F A full textual representation of a month, such as January or March January through December
g 12-hour format of an hour without leading zeros 1 through 12
G 24-hour format of an hour without leading zeros 0 through 23
h 12-hour format of an hour with leading zeros 01 through 12
H 24-hour format of an hour with leading zeros 00 through 23
i Minutes with leading zeros 00 to 59
I (capital i) Whether or not the date is in daylights savings time 1 if Daylight Savings Time, 0 otherwise.
j Day of the month without leading zeros 1 to 31
l (lowercase 'L') A full textual representation of the day of the week Sunday through Saturday
L Whether it's a leap year 1 if it is a leap year, 0 otherwise.
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
O Difference to Greenwich time (GMT) in hours Example: +0200
r RFC 2822 formatted date Example: Thu, 21 Dec 2000 16:01:07 +0200
s Seconds, with leading zeros 00 through 59
S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
t Number of days in the given month 28 through 31
T Timezone setting of this machine Examples: EST, MDT ...
U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) See also time()
w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
W ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) Example: 42 (the 42nd week in the year)
Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003
y A two digit representation of a year Examples: 99 or 03
z The day of the year (starting from 0) 0 through 365
Z Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through 43200


Unrecognized characters in the format string will be printed as-is. The Z format will always return 0 when using gmdate().

Example 1. date() examples
****************************************
a "am" or "pm"
A "AM" or "PM"
B Swatch Internet time
d day of the month, 2 digits with leading zeros; i.e. "01" to "31"
D day of the week, textual, 3 letters; i.e. "Fri"
F month, textual, long; i.e. "January"
g hour, 12-hour format without leading zeros; i.e. "1" to "12"
G hour, 24-hour format without leading zeros; i.e. "0" to "23"
h hour, 12-hour format; i.e. "01" to "12"
H hour, 24-hour format; i.e. "00" to "23"
i minutes; i.e. "00" to "59"
I (capital i) "1" if Daylight Savings Time, "0" otherwise.
j day of the month without leading zeros; i.e. "1" to "31"
l (lowercase 'L') day of the week, textual, long; i.e. "Friday"
L boolean for whether it is a leap year; i.e. "0" or "1"
m month; i.e. "01" to "12"
M month, textual, 3 letters; i.e. "Jan"
n month without leading zeros; i.e. "1" to "12"
r RFC 822 formatted date; i.e. "Thu, 21 Dec 2000 16:01:07 +0200" (added in PHP 4.0.4)
s seconds; i.e. "00" to "59"
S English ordinal suffix, textual, 2 characters; i.e. "th", "nd"
t number of days in the given month; i.e. "28" to "31"
T Timezone setting of this machine; i.e. "MDT"
U seconds since the epoch
w day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
Y year, 4 digits; i.e. "1999"
y year, 2 digits; i.e. "99"
z day of the year; i.e. "0" to "365"
Z timezone offset in seconds (i.e. "-43200" to "43200"). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive
Php



2092
05/05/2026
Php Date Add Day
add day
Php



5
05/05/2026
Php Date Current Date
today
Php



4
05/05/2026
Php Date Getdate
date breakdown
Php



4
05/05/2026
Php Date Mktime - Create New Date
build date new date
Php



4
05/05/2026
Php Date String To Time
strtotime function convert
Php



6
05/05/2026
Php Files Download Files While Changing Name
download header
$filename = "theDownloadedFileIsCalledThis.mp3";
$myFile = "/absolute/path/to/my/file.mp3";

$mm_type="application/octet-stream";

header("Cache-Control: public, must-revalidate");
header("Pragma: hack"); // WTF? oh well, it works...
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($myFile)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binaryn");

readfile($myFile);
Php



1404
05/05/2026
Php Files Getting A Files Extension
file extension
File Management
Php



2
05/05/2026
Php Files Reading TXT Files
fclose fgets fopen fread filesize feof read file whole line character
[Reading the Whole File]
The fread function reads a number of bytes from a file, up to the end of the file (whichever comes first). The filesize function returns the size of the file in bytes, and can be used with the fread function, as in the following example.

$listFile = "junk.txt";
if (!($fp = fopen($listFile, "r")))
exit("Unable to open the input file, $listFile.");
$buffer = fread($fp, filesize($listFile));
print "$buffer
\n";
fclose($fp);
?>

[Reading Line by Line]
The fgets function is used to read a line at a time. The function takes two parameters, the file handle, and the number of bytes to read. The function reads data up to a new line, or the number of bytes specified (whichever comes first), and returns the line read. The following is an example of using the fgets function.

if (!($fp = fopen("junk.txt", "r")))
exit("Unable to open the input file.");
while (!feof($fp))
{
$buffer = fgets($fp, 1024);
print "$buffer
\n";
}
fclose($fp);
?>

[Reading a Character at a time]
The fgetc() function is used to read a single character from a file.

Note: After a call to this function the file pointer has moved to the next character.

Example
The example below reads a file character by character, until the end of file is true:

if (!($f=fopen("welcome.txt","r")))
exit("Unable to open file.");
while (!feof($f))
{
$x=fgetc($f);
echo $x;
}
fclose($f);
?>
Php



1291
05/05/2026
Php Files Write To Txt File
fopen fwrite rewind fopen write file
Writing to Files
The fwrite function is used to write a string, or part of a string to a file. The function takes three parameters, the file handle, the string to write, and the number of bytes to write. If the number of bytes is omitted, the whole string is written to the file. If you want the lines to appear on separate lines in the file, use the \n character. Note: Windows requires a carriage return character as well as a new line character, so if you're using Windows, terminate the string with \r\n.

The following example logs the visitor to a file, then displays all the entries in the file.

$logFile = "stats.txt";
// Open the file in append/read mode
$fp = fopen($logFile, "a+");
// Create a string containing the user details
$userDetails = $HTTP_USER_AGENT;
if (isset($HTTP_REFERER))
$userDetails = $userDetails . " $HTTP_REFERER
\r\n";
else
$userDetails = $userDetails . "
\r\n";
// Write the user details to the file
fwrite($fp, "$userDetails");
// Move to the start of the file
rewind($fp);
$entries = 0;
// Display each line in the file
while(!feof($fp))
{
$buffer = fgets($fp, 1024);
if ($buffer != "")
{
print $buffer;
$entries++;
}
}
// Show a summary
print "There are $entries entries in the log file
";
fclose ($fp);
?>



Php



992
05/05/2026
Php Files Clean Url
? url clean & #
if you ever add variables to the url line you need to use this function
urldecode for passing gets.
$urlpart1=urldecode($urlpart1);
$urlpart2=urldecode($urlpart2);
$url="http://www.mydomain.com?$urlpart1&$urlpart2;

Do not use it on a completed url. It will totally mess everything up.
Php



1326
05/05/2026
Php Files Warning: Mkdir() [function.mkdir]: Permission Denied
mkdir permission denied 777
I had difficulty using mkdir() function until I set the above folder permission to 777. So anytime you write files or create directories using php, check your folder permissions using your cpanel's file manager. 755 did not help only 777 would work for me.

$topDir=dirname(__FILE__);
$folder0="/".$PHPfolder;
$source_dir = $topDir."/"; //.$folder0."/";
if(is_dir($topDir."/BACKED")==false){ mkdir($topDir."/BACKED", 0777,true); }
Php



1196
09/09/2023
Php Files Making An Image Viewer
files images viewer
Sometimes i have pictures that people want to view but are too numerous or inconvenient to email.
I just do a batch conversion on the images (I use Irfan view a free app) and upload them to a new folder I called "stylists". Using this script in an index.php, I dump it with the pictures. It will show them in your browser.

[Create image viewer]
$imagedirectory="../stylists/";
$dir = opendir($imagedirectory);

while ($file = readdir($dir)){
//for ($i=1; $i<=500; $i++){
// $file = readdir($dir);
$fullpath=$current_dir.$file;

echo "

$file
";
}
closedir($dir);
?>

You can tweak it to your folder requirements
Php



753
05/05/2026

Software Web Design