PHP Defines

You can just create a variable to hold define values like this: But this is the PHP correct way to define: Define an array defined() (ifdef)

Read More

Date And Time

Getting Date and Time Elements Using the current DateTime Using a DateTime variable Parameters you can use Calculations Date in # days time Compare Date Time Adjusting Date Time Values Values: MYSQL Date & Time To set a DateTime field to now use: (Don’t add single quotes around it) Is String A DateTime? Convert DateTime […]

Read More

Close Browser Window

PHP is executed at the server-side and thus does not know about clients, browsers or windows of those browsers. Some options though: Close button Close using java script

Read More

.Using Strings-Basics

Escape Characters In both types of string: In ” ” strings: Note, using say ‘\n’ will not create a newline character, it will create the characters \n !!!!! \n only works in a “” string!! Joining strings Use the period character ‘.’ You can also use .= Is String Empty Length ‘ vs “ ‘ […]

Read More

Debugging PHP

Useful debugging things Debugging arrays Display errors Add “display_errors = On” in your PHP configuration file to cause errors to be displayed.  This is a really useful debugging feature and is often the best first step of debuigging to determin why something isn’t working. Turning on in a file Tip: Look for a error_log file […]

Read More

.General PHP

Get PHP Info <?php phpinfo(); ?> Die (Exit page at this point) if (some_problem) { echo “There was an error.”; die(); }

Read More

Checking For Null Values

This will cause an error in code if reader1[0] is null: SomeVariableName += Convert::ToInt32(reader1[0]); Use this to detect if it is null: if (!reader1->IsDBNull(0)) SomeVariableName += Convert::ToInt32(reader1[0]);

Read More

Count Results

Total Number Of Some Column SELECT COUNT(SomeColumnName) FROM SomeTable WHERE … SELECT SomeColumnName, COUNT(SomeColumnName) FROM SomeTable WHERE … GROUP BY SomeColumnName //You can read it like this TotalVideosInSection = Convert::ToInt32(Row[0]); Total Number Of Rows SELECT COUNT(*) FROM SomeTable WHERE … Sum Of Some Column SELECT SUM(SomeColumnName) FROM SomeTable WHERE … Total Number Of True SELECT […]

Read More

GROUP BY

Group By Allows You To Return Results Grouped By A Certain Value Which Rows Share. Returns Total Number Of Rows For Each Value Present array ^Value = gcnew array(0); array ^MatchingRows= gcnew array(0); SqlClient::SqlConnection ^SqlConnection1 = gcnew SqlClient::SqlConnection(); SqlConnection1->ConnectionString = DataSourceString + DatabaseConnectionString; SqlConnection1->Open(); SqlClient::SqlCommand ^SqlCommand1; SqlCommand1 = gcnew SqlClient::SqlCommand(); SqlCommand1->Connection = SqlConnection1; SqlCommand1->CommandType = […]

Read More