php shopping cart
free shopping cart   shopping cart software

Free Shopping Cart PHP Software


Back to Functions List
This Function Has Been Available Since:
(AFCommerce v 2.1,     Functions v 1.1)


string = afc_sql_connect (SQLHOST, SQLLOGIN, SQLPASS, DATABASE)

This function makes a connection to the database you are using. By default, this is mysql. Since AFCommerce only uses one database, this function also calls the database selection function, for mysql this function is "mysql_select_db". So when defining a new database type you should find the equivalent functions for the database type you want to use.

All the afc_sql functions are found in database-mysql.php (by default AFCommerce uses mysql by default). When new database types are added in to the default version, the file would be named database-dbtype.php, and if you add your own database type, you simply need to change a few lines in this file, and replace the mysql functions with the functions for the database type you are using. This establishes a universal database system that AFCommerce uses, simply include the file that declares the database functions, and AFCommerce can use any type of database out there. You would only need to change the file that the database functions are declared in, and all of the scripts will automatically use the new database type, that is the purpose of the custom database functions that version 2 uses. Inside the web directory, there is a file called "dbconfig.php" which tells AFCommerce which file to include, so you will see right now that your cart will have this variable set to "mysql", hence why the file database-mysql.php is called. If you changed this value to xxx, where xxx is the name of the database type you are using, AFCommerce will automatically know to include a file called database-xxx.php (which you would need to create if that database type doesn't exist in the default version). You only need to understand this if you are creating your own database function declaration file.


SQLHOST (string) - Database Host Address. If you don't know what this is, you can find out from your web hosting company.

SQLLOGIN (string) - Database User Name

SQLPASS (string) - Database Password

DATABASE (string) - The Database Name

Return Values

Returns the connection resource which will be used in all database queries. This resource will be available until the script finishes executing.

Open Source: Yes

Paul's Examples

There are currently no examples for this function.

Back to Functions List


There are currently no posts for this topic.

AFCommerce Documentation

High End Website DevelopmentCompletely Free
Dating Service
Copyright 2004 - 2006
AFCommerce Website
And Cart Builder