OOPS - MySQL - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-06-2009, 07:33 AM   #1 (permalink)
Junior Member
 
Join Date: Jul 2009
Posts: 22
Default OOPS - MySQL

Hey guys,
I am looking for help with my OOPS code for connecting to MySQL, just for people that don't know what OOPS is Object Oriented Programming.

I am trying to connect to my database (MSQL) using this technology, however all my coding just does not seem to be working

The first code I tried was this one, however since i am on a shared server it seems that mysqli does not work??? DONT ask me why.
and as i am trying to make something for other site owners to use i need it to work with out them having to contact there administrators asking them to allow mysqli
$mysqli = new mysqli("localhost", "desvisa_v", "******", "desvisa_site");

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}


if ($result = $mysql->query("SELECT title FROM push_content LIMIT 10")) {
printf("Select returned %d rows.\n", $result->num_rows);

/* free result set */
$result->close();
}

$mysqli->close();
My second code, well i did not make the code, just copied and paste, BUT man it is way to confussing and i am just not understanding it.
class MyDatabase
{
// The var that stores the last
// used SQL statement
var $SQLStatement = "";

// The var that stores the error
// (if any)
var $Error = "";

function MyDatabase()
{
// Config for the database
// connection
$this->DBUser = "desvisa_v";
$this->DBPass = "*****";
$this->DBName = "desvisa_site";
$this->DBHost = "localhost";
}

function Connect()
{
//Connect to a mysql database
$this->db = mysql_connect($this->DBHost,
$this->DBUser, $this->DBPass) or
die("MYSQL ERROR: ".mysql_error());
// Select the database
mysql_select_db($this->DBName,
$this->db) or die("MYSQL ERROR:
".mysql_error());
}

// Disconnect from the MYSQL database
function Disconnect()
{
mysql_close($this->db) or die("MYSQL
ERROR: ".mysql_error());
}
}
So if any one can come up with a OOPS way to connect to a mysql database, I would be forever in your debt.
gilbertsavier is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:24 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting