I cannot reference the values in side of config.php
$dbhost,$dbuser ,$dbpasswd ,$dbname why?
<?php
require_once('i ncludes/db.php'); //db connection functions
require_once('c onfig.php'); //db connection parameters
class DBRegion{
var $db;
function DBRegion(){
}
function open(){
$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname ,
false);
if( !$this -db -db_connect_id )
{
die( "Could not connect to the database" );
}
}
function close(){
$this -db -sql_close();
}
function updateName( $id, $name ){
$sql = "update web_coupon_regi on set name = '$name' where id = $id ";
$result = $this -db -sql_query( $sql ) or die( "Coun't proceed with
the following sql: ".$sql );
}
//UPDATE `web_coupon_reg ion` SET `mdate` = '2006-08-16 05:05:55' WHERE
`id` = '1' LIMIT 1 ;
function updateModDate( $id, $date )
{
//$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname ,
false);
$sql = "update web_coupon_regi on set mdate = '$date' where id = '$id'";
$result = $this -db -sql_query( $sql ) ;
if(!$result ){
$error = $this -db -sql_error();
die( "Coun't proceed with the following sql: ".$error['message'] );
}
}
}
?> 3 1928
try using global keyword ...
function open(){
global $dbhost;
global $dbuser;
global $dbpasswd;
global $dbname;
$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname ,
false);
if( !$this -db -db_connect_id )
{
die( "Could not connect to the database" );
}
}
.... make sure the file config.php is included before the file in which
the function open() is defined.
if you don't want to use global keyword then, declare the variable in
config.php as,
define('dbhost' , 'somehost');
define('dbuser' , 'someuser');
define('dbpassw d', 'somepassword') ;
define('dbname' , 'somedb');
and in function open(), use them as (without $ sign)
$this -db = new sql_db(dbhost , dbuser , dbpasswd , dbname , false);
Thanks.
mich dobelman wrote:
I cannot reference the values in side of config.php
$dbhost,$dbuser ,$dbpasswd ,$dbname why?
<?php
require_once('i ncludes/db.php'); //db connection functions
require_once('c onfig.php'); //db connection parameters
class DBRegion{
var $db;
function DBRegion(){
}
function open(){
$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname ,
false);
if( !$this -db -db_connect_id )
{
die( "Could not connect to the database" );
}
}
function close(){
$this -db -sql_close();
}
function updateName( $id, $name ){
$sql = "update web_coupon_regi on set name = '$name' where id = $id ";
$result = $this -db -sql_query( $sql ) or die( "Coun't proceed with
the following sql: ".$sql );
}
//UPDATE `web_coupon_reg ion` SET `mdate` = '2006-08-16 05:05:55' WHERE
`id` = '1' LIMIT 1 ;
function updateModDate( $id, $date )
{
//$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname ,
false);
$sql = "update web_coupon_regi on set mdate = '$date' where id = '$id'";
$result = $this -db -sql_query( $sql ) ;
if(!$result ){
$error = $this -db -sql_error();
die( "Coun't proceed with the following sql: ".$error['message'] );
}
}
}
?>
I will use the define.
Thank you very much for your help.
M.d
"Manish" <ye*********@gm ail.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
try using global keyword ...
function open(){
global $dbhost;
global $dbuser;
global $dbpasswd;
global $dbname;
$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname ,
false);
if( !$this -db -db_connect_id )
{
die( "Could not connect to the database" );
}
}
... make sure the file config.php is included before the file in which
the function open() is defined.
if you don't want to use global keyword then, declare the variable in
config.php as,
define('dbhost' , 'somehost');
define('dbuser' , 'someuser');
define('dbpassw d', 'somepassword') ;
define('dbname' , 'somedb');
and in function open(), use them as (without $ sign)
$this -db = new sql_db(dbhost , dbuser , dbpasswd , dbname , false);
Thanks.
mich dobelman wrote:
>I cannot reference the values in side of config.php $dbhost,$dbuse r ,$dbpasswd ,$dbname why? <?php
require_once('i ncludes/db.php'); //db connection functions require_once('c onfig.php'); //db connection parameters
class DBRegion{ var $db; function DBRegion(){
}
function open(){
$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname , false);
if( !$this -db -db_connect_id ) { die( "Could not connect to the database" ); } }
function close(){
$this -db -sql_close();
}
function updateName( $id, $name ){
$sql = "update web_coupon_regi on set name = '$name' where id = $id ";
$result = $this -db -sql_query( $sql ) or die( "Coun't proceed with the following sql: ".$sql );
}
//UPDATE `web_coupon_reg ion` SET `mdate` = '2006-08-16 05:05:55' WHERE `id` = '1' LIMIT 1 ;
function updateModDate( $id, $date ) {
//$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname , false); $sql = "update web_coupon_regi on set mdate = '$date' where id = '$id'";
$result = $this -db -sql_query( $sql ) ;
if(!$result ){ $error = $this -db -sql_error(); die( "Coun't proceed with the following sql: ".$error['message'] ); } } }
?>
mich dobelman wrote:
I cannot reference the values in side of config.php
$dbhost,$dbuser ,$dbpasswd ,$dbname why?
<?php
require_once('i ncludes/db.php'); //db connection functions
require_once('c onfig.php'); //db connection parameters
class DBRegion{
var $db;
function DBRegion(){
}
function open(){
$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname ,
false);
if( !$this -db -db_connect_id )
{
die( "Could not connect to the database" );
}
}
function close(){
$this -db -sql_close();
}
function updateName( $id, $name ){
$sql = "update web_coupon_regi on set name = '$name' where id = $id ";
$result = $this -db -sql_query( $sql ) or die( "Coun't proceed with
the following sql: ".$sql );
}
//UPDATE `web_coupon_reg ion` SET `mdate` = '2006-08-16 05:05:55' WHERE
`id` = '1' LIMIT 1 ;
function updateModDate( $id, $date )
{
//$this -db = new sql_db($dbhost , $dbuser , $dbpasswd , $dbname ,
false);
$sql = "update web_coupon_regi on set mdate = '$date' where id = '$id'";
$result = $this -db -sql_query( $sql ) ;
if(!$result ){
$error = $this -db -sql_error();
die( "Coun't proceed with the following sql: ".$error['message'] );
}
}
}
?>
IMHO it's better to pass the parameters to the function, i.e.
function open($host, $user, $passwd, $name){
$this -db = new sql_db($host , $user , $passwd , $name ,
false);
if( !$this -db -db_connect_id )
{
die( "Could not connect to the database" );
}
}
....
$dbregion = new $DbRegion();
$dbregion -open($dbhost, $dbuser, $dbpasswd, $dbname);
This gives you more flexibility in your code. Right now you may only
use one database on one host, for instance. But what about another
system - or later?
Or even now, you might have one user with limited privileges for the
general public, and another user with more privileges for admin users.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== === This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael J. Astrauskas |
last post by:
I have a site where a user logs in and a session variable I created
is used to keep track of the fact that the user is logged in. This
various pages query a MySQL database to get information (mostly to
generate a catalogue and news page). Occasionally when loading a page I
simply get the error "No database selected" when the PHP script attempts
to run the query. Usually I can press reload in my browser (Netscape,
IE, and Opera) and the...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
Hello,
I have a very simple problem but cannot seem to figure it out. I have a
very simple php script that sends a test email to myself. When I debug
it in PHP designer, it works with no problems, I get the test email. If
|
by: Jean-David Beyer |
last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2
V6.1 (with all the FixPacks) on my old machine.
I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat
Enterplise Linux 3 ES, and applied FixPack fp5_mi00069.tar to it. After
creating an instance, starting the database, creating a database, and
entering the table definitions, all of which seems to work OK, I entered a
tiny 8-row table and can do...
|
by: Kimmo Laine |
last post by:
I'm flipping my wig here, people. I'm using classes and making each class a
file. when I'm including dependet classess, I use require_once to avoid
multiple declarations - yet they happen. I put debug_print_backtrace in the
file to see how it is included, and here's the output:
#0 require_once() called at
#1 require_once(\eKirje.textGrid.class.php) called at
#0 require_once() called at
#1 require_once(\eKirje.kanava.class.php)...
|
by: Martin Jørgensen |
last post by:
Hi,
I don't understand these errors I get:
g++ Persort.cpp
Persort.cpp: In function 'int main()':
Persort.cpp:43: error: name lookup of 'j' changed for new ISO 'for' scoping
Persort.cpp:37: error: using obsolete binding at 'j'
| |
by: three-eight-hotel |
last post by:
I'm somewhat of a newbie to PHP coding, but have developed a site
using the technology, and have been pleasantly surprised by the
capabilities offered. I am more comfortable in the ASP world, however
and am really struggling with managing sessions in PHP, based on my
experiences with managing sessions in ASP.
99.9% of the feedback I have seen when dealing with the errors has
referred to having whitespace before the <?php or after the...
|
by: Ciegalo |
last post by:
Hi to all,
I'm getting my hands into PEAR for a small newsletter-sending project.
I need to boost the performance of the sending script and came accross
this mail_queue class that should queue the emails.
After sweating over the pear installation on myWindows Machine (IIS,
PHP 4.4.6, MySQL), I cannot even run the tutorial script.. I get :
Fatal error: Cannot redeclare class
mail_queue_container:mail_queue_container_db in...
|
by: Tyno Gendo |
last post by:
Has anyone come across this problem with require_once?
I was working on my local machine with apache and have included a file
like this:
require_once "welcome_patient.php";
Works fine, the file that "requires" this is in the same directory
/
|
by: Hazza |
last post by:
Hi, I am using PHP and mysql to create a website.
I am fairly new to PHP, and thus am grateful to anyone who helps!
Firstly I am running a homepage, that displays additional content if a user has logged in. I set a loggedin session in the log in page, which I have tested and works fine in other scripts.
I am displaying news on the homepage (which is stored in a mysql database), and this works fine when the user accesses the homepage...
|
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...
|
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...
| |
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |