Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

SMyCC - Simple MySQL Connection Class

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

stscac

A Wealth of KnowledgeVIP Member
Impact
73
Just writing code tonight and as always - used my connection class for connecting to mysql. Thought about it, and even for those who aren't that great with php/mysql, makes connecting to a database easier (and less repetitive - something classes/functions are great for).

So, I'm releasing it as "SMyCC - Simple MySQL Connection Class" to the Namepros Community, and then to the public.

PHP:
<?
/*
        SMyCC [Pronounced "smEEk"]
        (Simple MySQL Connection Class)
        © 2005-2006 Steve Castle
        http://www.stscac.com

*/
class mysql
{
    var $server;
    var $conn_username;
    var $conn_password;
    var $database_name;
    var $connection;
    var $select;
    var $query;

    function connect()
 {
    require "database.inc.php";
    
    $connection = mysql_connect($server,$conn_username,$conn_password);
	$select = mysql_select_db($database_name,$connection);
}
    function query($query)
    {
        $result = mysql_query($query);
        if (!$result) {
            echo 'Could not run query: ' . mysql_error();
            exit;
}
    }
    function end()
    {
        mysql_free_result($connection);
    }
}
To run the MySQL Connection, you will have to call a new instance of the class and tell it what function to run:
PHP:
$mysql = new mysql();
$mysql->connect();
To Run a specific Query on the database:
PHP:
// The Query here is a sample for this instance
$mysql->query("SELECT * FROM table WHERE something='something_else'");
To Close the MySQL Connection, Run the End function of the class instance:
PHP:
//You Must have run the $mysql->query to be able to use the $mysql->end function
$mysql->end();

If you read through the class code, you will have noticed that there is a reference to "database.inc.php". This is a file with the necessary connection data to access the database. It is available inside the download below.

The entire package is available for download on my (project) website:
http://www.stscac.com/dev/smycc/

Hope you like it.

-Steve
 
2
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Cool Steve. Not bad. Simple is sometimes....better =)
 
0
•••
thanks for this. Nice of you to release freely. Rep added!
 
0
•••
Approaching 450 downloads :)

Let me know what else you would like included.

Remember its a simple class, doesn't need to be extravagant.

Thanks

-Steve
 
0
•••
Approaching 1,000 downloads - not too bad for a tiny little script. Regardless, I am still looking for some feedback on what you would like to see.

Look for some more releases from me soon.

-Steve
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

More data. Your data. See what is new
Major update
We have made a number of features available to provide sellers more data for their domains and inquiries, and greater access to the data...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back