JustinSmall
06-18-2006, 06:21 PM
I need help, I'm creating a relatively small billing system for my site...
I believe I'm connected to mysql, I'm not sure, because when I go to display the info of the mysql table, it doesnt do it.
Here we go.
Heres the "classes/mysql.php" which holds all the sql info in it.
<?php
class MySQL
{
function connect($host, $username, $password, $database)
{
mysql_connect($host, $username, $password);
mysql_select_db($database);
}
function safe_query($query)
{
return mysql_query( mysql_real_escape_string($query) );
}
function get_config()
{
$res = $this->safe_query("SELECT * FROM config");
while( $row[] = mysql_fetch_assoc($res) ){}
return $row;
}
}
?>
Heres the index.php file
<?php
include ("includes/connect.php");
include ("classes/mysql.php");
$openconnect = new MySQL();
$openconnect->connect($host, $username, $password, $database);
$openconnect->get_config();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $row["sitename"]; ?></title>
</head>
<body>
<?php
print_r($row);
?>
</body>
</html>
Plus I have the includes/connect.php file which just holds the sql connection info such as user and the database and whatnot, not really needed to be shown here.
Well when I go to display the info, it doesn't do anything. It's just blank.
Thanks in advance!
I believe I'm connected to mysql, I'm not sure, because when I go to display the info of the mysql table, it doesnt do it.
Here we go.
Heres the "classes/mysql.php" which holds all the sql info in it.
<?php
class MySQL
{
function connect($host, $username, $password, $database)
{
mysql_connect($host, $username, $password);
mysql_select_db($database);
}
function safe_query($query)
{
return mysql_query( mysql_real_escape_string($query) );
}
function get_config()
{
$res = $this->safe_query("SELECT * FROM config");
while( $row[] = mysql_fetch_assoc($res) ){}
return $row;
}
}
?>
Heres the index.php file
<?php
include ("includes/connect.php");
include ("classes/mysql.php");
$openconnect = new MySQL();
$openconnect->connect($host, $username, $password, $database);
$openconnect->get_config();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $row["sitename"]; ?></title>
</head>
<body>
<?php
print_r($row);
?>
</body>
</html>
Plus I have the includes/connect.php file which just holds the sql connection info such as user and the database and whatnot, not really needed to be shown here.
Well when I go to display the info, it doesn't do anything. It's just blank.
Thanks in advance!
