Advertisement

05.14.2008 at 04:53AM PDT, ID: 23401004
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.3

How to call a function ( from class) in to a page

Asked by fosiul01 in MySQL Server, PHP Scripting Language, PHP and Databases

Tags:

HI,
I have attached code for a class .  if you see the Code, private function connectToDB(), you will see if there is any problem in connection it will through exception.

in that code, i wrote, if everything is fine( connection), then show " which datbase i am connected"

Now if i call this class to my index.php, if everythign fine, it will show that comment in the page ( see the picture please) , this is happenning because
 i have Added following line to private function connectToDB()

else
                  echo("Connected to the Server");
                  echo("<br>");
                  echo( "You are Connected to:"); echo ( $this->dbName );

MyQuestion:
if dont Add above code ( else ........ echo ( $this->dbName );) in private function connectToDB(), then how i will show in my page that which database i am connected ??

What i want is : i want to call this function in my index.php, and then use this condition ( if  every connection is fine then show which database i am connected to)

hope this make sence ??  Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
**********************
mysql.php
*********************
<?php
// MySql Class and its properties 
 
class MySql 
{
 
	   
	/**
	 * MySql Server Host name
	 * @access private
	 *@var string
	*/
	var $host;
	
	/**
	 * Mysql username
	 *@access private
	 *@var string
	 */
	 var $dbUser;
	 
	 /**
	 * MySql user's password
	 *@access private
	 *@var String
	 */
	 var $dbPass;
	 
	 /**
	  * Name of the database to use
	  * @access private
	  * @var String
	  */
	  var $dbName;
	 /**
	  *MySql resorce link identifier stored here
	  *@access private
	  *@var STring
	  */
	  var $dbConn;
	  
	  /**Store Error message for connection Errors
	  *@access private
	  *@var String
	  */
	 
	 /**
	  * Mysql Constructor
	  *@param string host (Mysql server host name)
	  *@param String dbUser( Mysql user name)
	  *@param String dbPass ( Mysql user password)
	  *@param String dbName( Database to select)
	  *@access public
	  */
	  public function MySql ($host,$dbUser,$dbPass,$dbName)
	  
	  	{
		
			$this->host =$host;
			$this->dbUser = $dbUser;
			$this->dbPass = $dbPass;
			$this->dbName = $dbName;
			$this->connectTodb();		
		}	
		
	/**
	 *Establish Connection to Mysql database and select a database
	 *@return void
	 *@access private
	 */
	 private function connectToDB()
	 	{
			// Make Connection to the Server
			if (!$this->dbConn = @mysql_connect($this->host,$this->dbUser,$this->dbPass)) 
				
				{ 
					trigger_error ('Could not connect to server');
					$this->connectError = true;
				}
				// Select Database
			elseif (!@mysql_select_db($this->dbName,$this->dbConn))
			
				{
					trigger_error ('could not Select Database');
					$this->connectError = true ;
				
				}
			else 
			echo("Connected to the Server");
			echo("<br>");
			echo( "You are Connected to:"); echo ( $this->dbName );
				
		}    
		
		/**
		 *Checks for MySql Error
		 *@Return boolean
		 *access public
		 */
		 
		public function isError()
		  {
		  
		  	if($this->connectError) 
				{
					return true;
				}
			$error = mysql_error ($this->dbConn);
			
			if (empty($error)) 
			
				{
					return false;
				} 
			else 
				{
					return true;
				}
		  
		  }
}
 
 
 
?>
 
***********************
index.php
**********************
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="test,diagnosis,repair,service,electronic,manufacturer,photocopier,fax,scanner,printer,starwriter,monitor,crt,tft,vending,warranty,retrofit,refurbish" />
<meta name="description" content="Electroversal is a provider of electronic service and repair solutions for copier,fax,scanner,printer,monitor,vending,EPOS,power supply" />
<title> &gt; Home</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<link rel="shortcut icon" href="favicon.ico" />
</head>
 
<body><div id="wrap">
<?php
include('menu.inc.php');
?> 
 <div id="content">
 
<?php
 
// Include the MySQL class
require_once('DBClass/MySQL.php');
require_once ('DBClass/ConnectionString.php');
// Connect to MySQL
$db = & new MySQL($host,$dbUser,$dbPass,$dbName);
?>
 
<!-- Bellow code is to create html base form to get username and password  -->
<form action="" method="post">
 
<table>
<tr>
        <td>Username</td>
        <td><input type="text" name="username"></td>
</tr>
<tr>
        <td>Password</td>
        <td><input type="password" name="password"></td>
</tr>
<tr>
        <td></td>
        <td><input type="submit" name="submit" value="Login!"></td>
</tr>
</table>
</form>
 
 
 
</div>
<br />
<div id="footer">&copy;<?=date("Y");?> Calyx Group</div>
 
</div>
</body>
</html>
Attachments:
 
index
index
 
[+][-]05.14.2008 at 05:38AM PDT, ID: 21563406

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 05:43AM PDT, ID: 21563460

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 05:44AM PDT, ID: 21563468

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 05:48AM PDT, ID: 21563497

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:05AM PDT, ID: 21563657

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:07AM PDT, ID: 21563683

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:10AM PDT, ID: 21563721

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:11AM PDT, ID: 21563734

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:22AM PDT, ID: 21563833

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:29AM PDT, ID: 21563898

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:30AM PDT, ID: 21563909

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:36AM PDT, ID: 21563979

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:44AM PDT, ID: 21564061

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:48AM PDT, ID: 21564111

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:51AM PDT, ID: 21564144

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MySQL Server, PHP Scripting Language, PHP and Databases
Tags: php
Sign Up Now!
Solution Provided By: peter_thomas
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.14.2008 at 06:54AM PDT, ID: 21564180

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:55AM PDT, ID: 21564190

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:56AM PDT, ID: 21564209

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:56AM PDT, ID: 21564212

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 07:11AM PDT, ID: 21564380

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628