Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 4th, 2004, 01:15 PM
Authorized User
 
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to a DB from another server...

Hello all,

Iam trying to connect to another location where the db is located and am having no success.

I keep on receiving the following error:

Fatal error: Call to undefined function: mysql_connect() in /home/uwo/wwwroot/testing/db_connect.inc on line 47


which is basically this code here...

$dbhost = '000.000.000';
$dbusername = 'username';
$dbuserpassword = 'pass';
$default_dbname = 'testing';
$user_tablename ='table';

function db_connect($dbname='') {
   global $dbhost, $dbusername, $dbuserpassword, $default_dbname;
   global $MYSQL_ERRNO, $MYSQL_ERROR;

   $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
   if(!$link_id) {
      $MYSQL_ERRNO = 0;
      $MYSQL_ERROR = "Connection failed to the host $dbhost.";
      return 0;
   }
   else if(empty($dbname) && !mysql_select_db($default_dbname)) {
      $MYSQL_ERRNO = mysql_errno();
      $MYSQL_ERROR = mysql_error();
      return 0;
   }
   else if(!empty($dbname) && !mysql_select_db($dbname)) {
      $MYSQL_ERRNO = mysql_errno();
      $MYSQL_ERROR = mysql_error();
      return 0;
   }
   else return $link_id;
}

Now this code actually work in my test environment but does not work when I try to connect from a php page that I know works 100%. am I missing a variable somewhere. Cause On the linux box where the .inc file is located it return that error... I want it to go to a windows box which has the mysql db located...


Thanks for all your assistance..
 
Old May 7th, 2004, 11:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I can only assume you have PHP compiled without MySQL support. AS an aside, I seem to recall that Redhat installations, in particular, default to installing PostgreSQL support, but leave off MySQL support (damned stupid distribution, if you ask me - but we have ample evidence, from elsewhere, to show that ineptitude is no hinderance to becoming a software juggernaught).





Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting web server and remote db server via asp moreyt Classic ASP Databases 0 May 31st, 2005 12:13 AM
Connecting to Pubs DB on SQL server..easy !!! tumbleweed VB Databases Basics 2 January 12th, 2005 04:40 PM
Connecting to Access Db mattastic Classic ASP Databases 3 October 14th, 2004 02:32 AM
error while connecting to DB using DSN Lakshmi KS VB Databases Basics 2 October 1st, 2004 08:08 AM
Connecting to another Access db with different IP ckentebe Access VBA 3 April 21st, 2004 12:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.