[PHP-DB] Re: Cannot connect to a MySQL DB using a Class
Neil - Thank you for noticing my typo. The actual PHP code has both choices with one commented out. When I constructed the message for the forum I selected the wrong one - not the one I actually am using. Todd Neil Smith [MVP, Digital media] wrote: At 00:46 05/01/2006, you wrote: Message-ID: <[EMAIL PROTECTED]> To: php-db@lists.php.net Date: Wed, 04 Jan 2006 16:45:54 -0800 From: Todd Cary <[EMAIL PROTECTED]> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: CAnnot connect to a MySQL DB using a Class No doubt I am over looking something very simple, nevertheless I am baffled by not being able to connect to a MySQL DB. // Error produced here!! $this->db=mysql_connect($this->host,$this->user,$this->password); mysql_select_db($this->database); Surely you meant mysql_select_db($this->db); since that's what you connected to ? Cheers - Neil -- Ariste Software 2200 D Street Ext Petaluma, CA 94952 (707) 773-4523 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Cannot connect to a MySQL DB using a Class
At 00:46 05/01/2006, you wrote: Message-ID: <[EMAIL PROTECTED]> To: php-db@lists.php.net Date: Wed, 04 Jan 2006 16:45:54 -0800 From: Todd Cary <[EMAIL PROTECTED]> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: CAnnot connect to a MySQL DB using a Class No doubt I am over looking something very simple, nevertheless I am baffled by not being able to connect to a MySQL DB. // Error produced here!! $this->db=mysql_connect($this->host,$this->user,$this->password); mysql_select_db($this->database); Surely you meant mysql_select_db($this->db); since that's what you connected to ? Cheers - Neil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: CAnnot connect to a MySQL DB using a Class
Todd Cary wrote: No doubt I am over looking something very simple, nevertheless I am baffled by not being able to connect to a MySQL DB. Here is the code that will use the Class: $host='192.168.0.12'; $user='todd'; $password='mypassword'; $database='calevent'; /* $retval=mysql_connect($host,$user,$password); if ($retval) { echo "Success"; if (mysql_select_db($database)) echo "Selected"; else echo "Cannot select"; } else echo "Failed"; exit; */ $cal=new CALEVENTS(); $cal->setInfo($host,$user,$password,$database); The commented out debug code (my debugging) works fine...connects! This code in the Class produces an error: function CALEVENTS($host="",$user="",$password="",$database="") { $this->setInfo($host,$user,$password,$database); } function setInfo($host,$user,$password,$database) { $this->host=$host; $this->user=$user; $this->password=$password; $this->database=$database; //echo $this->host . ""; for debugging //echo $this->user . ""; //echo $this->password . ""; //echo $this->database . ""; // Error produced here!! $this->db=mysql_connect($this->host,$this->user,$this->password); mysql_select_db($this->database); } This is the error: Warning: mysql_connect(): Access denied for user 'apache'@'localhost' (using password: NO) in /home/httpd/calendar/calendarevents/php/calevents.inc.php on line 42 Found the error! The open is called twice! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php