Select Page

Quick mysql_connect php script

The below script is a quick PHP script that connects to a mysql database to test connectivity.

<html>
<body>
<?
$host = "xxx.xxx.xxx.xxx";
$username = "username";
$password = "password";

        /* Connecting, selecting database */
        $conn = mysql_connect($host, $username, $password)
        or die("Could not connect");
        /* select the database */
        mysql_select_db("user") or die("Could not select database <I>user</I> Database<br>");
?>
</body>
</html>

PHP script to send email

Very simple php script that sends email.  I use this from time to time to test the functionality of sendmail and php.

<?php 
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );
    $from = "emailtest@YOURDOMAIN";
    $to = "YOUREMAILADDRESS";
    $subject = "PHP Mail Test script";
    $message = "This is a test to check the PHP Mail functionality";
    $headers = "From:" . $from;
    mail($to,$subject,$message, $headers);
    echo "Test email sent";
?>