473,666 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I wrote code to connect to the database but it is showing in browser like this

25 New Member
this is the code i had written in php to connect to mysql
=============== =============== ==========


<? php
class Database
{
var $database_name;
var $database_user;
var $database_pass;
var $database_host;
var $database_link;

function Database()
{
$this->database_use r = "admin";
$this->database_pas s = "admin";
$this->database_hos t = "192.168.1. 50";
$this->database_nam e = "onlineauction" ;
}



function changeUser($use r)
{
$this->database_use r = $user;
}

function changePass($pas s)
{
$this->database_pas s = $pass;
}

function changeHost($hos t)
{
$this->database_hos t = $host;
}

function changeName($nam e)
{
$this->databse_name = $name;
}

function changeAll($user , $pass, $host, $name)
{
$this->database_use r = $user;
$this->database_pas s = $pass;
$this->database_hos t = $host;
$this->database_nam e = $name;
}


function connect()
{
$this->database_lin k = mysql_connect($ this->database_hos t, $this->database_use r, $this->database_pas s) or die("Could not make connection to MySQL");
mysql_select_db ($this->database_nam e) or die ("Could not open database: ". $this->database_name) ;
}



function disconnect()
{
if(isset($this->database_link) ) mysql_close($th is->database_link) ;
else mysql_close();
}



function iquery($qry)
{
if(!isset($this->database_link) ) $this->connect();
$temp = mysql_query($qr y, $this->database_lin k) or die("Error: ". mysql_error());
}



function query($qry)
{
if(!isset($this->database_link) ) $this->connect();
$result = mysql_query($qr y, $this->database_lin k) or die("Error: ". mysql_error());
$returnArray = array();
$i=0;
while ($row = mysql_fetch_arr ay($result, MYSQL_BOTH))
if ($row)
$returnArray[$i++]=$row;
mysql_free_resu lt($result);
return $returnArray;
}
}
?>



in browser it is showing like this
=============== ==========
database_user = "admin"; $this->database_pas s = "admin"; $this->database_hos t = "192.168.1. 50"; $this->database_nam e = "onlineauction" ; } function changeUser($use r) { $this->database_use r = $user; } function changePass($pas s) { $this->database_pas s = $pass; } function changeHost($hos t) { $this->database_hos t = $host; } function changeName($nam e) { $this->databse_name = $name; } function changeAll($user , $pass, $host, $name) { $this->database_use r = $user; $this->database_pas s = $pass; $this->database_hos t = $host; $this->database_nam e = $name; } function connect() { $this->database_lin k = mysql_connect($ this->database_hos t, $this->database_use r, $this->database_pas s) or die("Could not make connection to MySQL"); mysql_select_db ($this->database_nam e) or die ("Could not open database: ". $this->database_name) ; } function disconnect() { if(isset($this->database_link) ) mysql_close($th is->database_link) ; else mysql_close(); } function iquery($qry) { if(!isset($this->database_link) ) $this->connect(); $temp = mysql_query($qr y, $this->database_lin k) or die("Error: ". mysql_error()); } function query($qry) { if(!isset($this->database_link) ) $this->connect(); $result = mysql_query($qr y, $this->database_lin k) or die("Error: ". mysql_error()); $returnArray = array(); $i=0; while ($row = mysql_fetch_arr ay($result, MYSQL_BOTH)) if ($row) $returnArray[$i++]=$row; mysql_free_resu lt($result); return $returnArray; } } ?>
Aug 6 '07 #1
2 1395
nathj
938 Recognized Expert Contributor
Hi,

I see you have read the article on the forum about data abstraction layers. Excellent - it'll really help out.

Where is the code that uses this data abstraction layer? The that priduces the display on screen that you are not happy with?

If you could post that then that may help us get to the bottom of the problem.

Cheers
nathj
Aug 6 '07 #2
ak1dnar
1,584 Recognized Expert Top Contributor
in browser it is showing like this
=============== ==========
database_user = "admin"; $this->database_pas s = "admin"; $this->database_hos t = "192.168.1. 50"; $this->database_nam e = "onlineauction" ; } function changeUser($use r) { $this->database_use r = $user; } function changePass($pas s) { $this->database_pas s = $pass; } function changeHost($hos t) { $this->database_hos t = $host; } function changeName($nam e) { $this->databse_name = $name; } function changeAll($user , $pass, $host, $name) { $this->database_use r = $user; $this->database_pas s = $pass; $this->database_hos t = $host; $this->database_nam e = $name; } function connect() { $this->database_lin k = mysql_connect($ this->database_hos t, $this->database_use r, $this->database_pas s) or die("Could not make connection to MySQL"); mysql_select_db ($this->database_nam e) or die ("Could not open database: ". $this->database_name) ; } function disconnect() { if(isset($this->database_link) ) mysql_close($th is->database_link) ; else mysql_close(); } function iquery($qry) { if(!isset($this->database_link) ) $this->connect(); $temp = mysql_query($qr y, $this->database_lin k) or die("Error: ". mysql_error()); } function query($qry) { if(!isset($this->database_link) ) $this->connect(); $result = mysql_query($qr y, $this->database_lin k) or die("Error: ". mysql_error()); $returnArray = array(); $i=0; while ($row = mysql_fetch_arr ay($result, MYSQL_BOTH)) if ($row) $returnArray[$i++]=$row; mysql_free_resu lt($result); return $returnArray; } } ?>
Did You create a [dot] php file Or anyother extention.
Aug 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
1745
by: dogu | last post by:
I'm running Mandrake 10 PHP 4x Apache 2x The code below resides in /home/doug/public_html Apache is configured to allow user home drives and I can successfully load html. If I'm running Konqueror and launch the code below, the 'submit' button launches the php file and returns the expected data.
1
2595
by: kaiwing18 | last post by:
Hi , I have a problem relate to java and database. Could anyone answer me ?Please see the following code. import java.sql.*; public class Result { public static void main(String args) {
4
6164
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get values from a html form that consists of about 10 checkbox and a textbox where user have to key in a value to perform a search. From python tutors, I learned that I have to use the following method:
1
2294
by: DD | last post by:
I have the following code and my question is Do i use a Autoexec to fire this ? As: fGetLinkedTables("ODBC") Or how do i ?? do i replace the above as fGetLinkedTables("test_be") Or ???
3
12943
by: Greg Strong | last post by:
Hello All, Is there any way to close an ODBC connection via DSN without completely closing the Access front-end? I'm doing some testing with using Access as a front-end to Oracle 10g Express edition. When the user ID and password is entered on a form and after a successful connection it seems Access doesn't change the connection. Even if I enter an invalid user ID and/or password the connection continues to work.
16
2794
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
6
2171
by: fpcreator2000 | last post by:
Hello everyone. I'm having problems with a page I've created that is used to insert data into a database. It uploads two files into two distinct folder, and it takes the filenames and inserts them into a MYSQL database along with other product information. Here is the entire .php file. I list it because the errors are not showing at all, and I need a fresh pair of eyes to look at it. Any answers, critisims (constructive), or other talk...
5
1969
by: Evan Jou | last post by:
Hi there, I have a simple question for you experts here that I've installed Apache, PHP and MySQL on my Windows machine and set up a test script(test.php) like what is listed in a book. It's like <?php @mysql_connect("localhost","root","password") or die("Could not connect to MySQL server!); @mysql_select_db("mysql")
12
2356
by: Jonathan Wood | last post by:
Greetings, I wonder if anyone can help me with this. I have an XP laptop, and a Vista desktop computer. I use the laptop to run software remotely on the desktop using the Remote Desktop Connection software. Everything is working just fine. However, whenever I run an ASP.NET Website project in Visual Studio, the browser pops up a "Connect to localhost"
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.