//—– CONNECT TO DATABASE —– $dbname = "database_name"; $dbusername = "user_name"; $dbpassword = "password"; mysql_connect("localhost", $dbusername, $dbpassword, $dbname) or die("cannot connect"); mysql_select_db($dbname) or die(mysql_error()); //Select the database so it doesn't need to be specified in mysql functions Example Config File config.php <?php //Main Database: $main_db_host = 'localhost'; //Typically "localhost" or IP address if on another […]
All posts by
php.ini making changes
In the ".ebextensions" folder create a config file or add to your existing config file. In this example the config file is called "project.config" (the name doesn't actually matter) Add the following to it: files: "/etc/php.d/project.ini" : mode: "000644" owner: root group: root content: | upload_max_filesize = 64M post_max_size = 64M Note you must uses […]
AWS on Linux
See http://www.raspberry-projects.com/pi/category/programming-in-c/aws-amazon-web-services
Date input fields
Supported by some HTML5 browsers which will display a date picker datetime db field from date picker When handling form submission In the form
Create Array From
Create An Array From A String With A Delimiter Character Create array of individual digits from a number
Try Catch error handling
try { } catch (Exception $e) { echo 'Exception: ', $e->getMessage(), "\n"; }
.S3 General
Get AWS SDK Simple include the SDK .phar method Download the "aws.phar" file and store it in a subdirectory called, says awssdk. Then in your php files use: require 'awssdk/aws.phar'; Define your S3 access values ready to use in your code $AwsS3BucketName = ''; //<<<<SET THIS $AwsS3AccessKeyId = ''; //<<<<SET THIS $AwsS3AccessSecretKey = ''; //<<<<SET […]
.Install SDK
Include SDK Files Method http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html Use the "Installing via Phar" method, include the .phar
Universal Settings Table
Table Design RecordId Auto Increment int (unisigned) Primary Key SettingName varchar SettingValue text Is A Setting Enabled? //—– CHECK IF UPLOADS ARE ENABLED CURRENTLY —– $QueryString = @mysql_query("SELECT SettingValue FROM tblApiSettings WHERE SettingName = 'ArchiveDataUploadsEnabled'"); $result = @mysql_fetch_array($QueryString); $UploadsEnabled = $result[‘SettingValue’]; $UploadsEnabled = filter_var($UploadsEnabled, FILTER_VALIDATE_BOOLEAN); if (!$UploadsEnabled) die("Quitting – Uploads import is currently disabled"); Is […]
cron scheduled tasks
Create CRON Task For Web Server Environment Example Yes you can create cron tasks in the web server environment which can be handy when you want to do background things you'd otherwise have to spin up a worker environment to do (at extra running cost). You can create them in worker environments too but there's a simpler […]