help with PEAR::DB vs mysql_connect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have 2 seperate scripts. On useing PEAR::DB and the other using
mysql_connect.

mysql_connect works and PEAR::DB does not.

This is what I have...

the 'mysql_connect' script...

   $db_host = 'myHost';
   $db_user = 'myUser';
   $db_pass = 'myPass';
   $db_name = 'myDB';

   $link = mysql_connect($db_host, $db_user, $db_pass)
      or die("Could not connect: " . mysql_error());

   mysql_select_db($db_name, $link);

   $result = mysql_query("SELECT * FROM myTable", $link);
   $num_rows = mysql_num_rows($result);

   echo "$num_rows Rows\n";

this gives me '38', which it is supposed to.


the PEAR::DB sscript...

   $db_type = 'mysql';
   $db_host = 'myHost';
   $db_user = 'myUser';
   $db_pass = 'myPass';
   $db_name = 'myDB';

   $dsn = "$db_type://$db_user:$db_pass@$db_host/$db_name";

   $db = DB::connect($dsn);

   if (DB::isError($db))
      die ($db->getMessage());
   else
      echo "DB Connected to $db_name \n\n";

   $result = $db->query(("SELECT * FROM myTable");

   echo 'rec count: ' . $result->numRows();

This gives me...

   DB Error: connect failed

I have no idea what I am doing wrong!

Both scripts work on my local machine, but only the 'mysql_connect' works on
the production server.

I even took the step of placing the vars in an include file that open open,
just to make sure both were using the same values.

Any ideas what I'm doing wrong?

Thanks

Walter

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux