Hi,
Right if you read my other post you will know i wanted to build a CRM. So basically i am going to to it but with only basic knowledge of PHP and SQL i wanted a bit of help. This is not only so i can build a CRM but advance my skills also. First of all i have created the following:
db.config.php
db.class.phpCode:<?php $dbconfig[host] = "localhost"; // Server the databse is hosted on "localhost" for this server $dbconfig[username] = "***"; // Username for the database $dbconfig[password] = "***"; // Password for the database $dbconfig[database] = "***"; // database the information is in ?>I was told to set these both up as it would be easier to back up the database etc.Code:<? include("db.config.php"); class database { function init() { GLOBAL $dbconfig; $this->config = $dbconfig; $this->connection=mysql_connect($this->config[host], $this->config[username], $this->config[password]); mysql_select_db ($this->config[database], $this->connection); } function selects($select) { $this->result = mysql_query($select,$this->connection); } function inserts($insert) { mysql_query($insert,$this->connection); } function deletes($delete) { mysql_query($delete,$this->connection); } function countrows() { $rows = mysql_num_rows($this->result); return $rows; } function unbbcode($script) { $this->bbcode1 = array( "", "", "", "", "", "", "", "", "[LI]", "[li]" ); $this->bbcode2 = array( "<B>", "</B>", "<B>", "</B>", "<i>", "</i>", "<i>", "</i>", "<li>", "<li>" ); $this->completeText = str_replace($this->bbcode1,$this->bbcode2,$script); return $this->completeText; } } ?>
Then i want to setup a table so that i can add my users ect
so i set-up tables.php
Code:<?php require 'db_config.php'; require 'db_class.php'; $table = "CREATE TABLE users ( id int(10) DEFAULT '0' NOT NULL auto_increment, username varchar(40), password varchar(50), regdate varchar(20), email varchar(100), website varchar(150), location varchar(150), show_email int(2) DEFAULT '0', last_login varchar(20), PRIMARY KEY(id))"; $create = $db_object->query($table); //perform query if(DB::isError($create)) { die($create->getMessage()); } else { echo 'Table created successfully.'; } $db_object->disconnect(); ?>
But this is not working any reason why?


LinkBack URL
About LinkBacks
Reply With Quote
