473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

mysql_connect works; DB::connect doesn't

When I execute the following script I can connect using 'mysqli_connect' but
I get a "DB Error: Not Found" when I display the $db->Message() after
attempting the DB::Connect.

And, "yes", the "restaurant" database does exist.

Where should I start looking?

PHP 5.0.4 / mySQL 4.1.13-nt / IIS / XP Pro

TIA,

Larry Woods
<?php
require 'DB.php';
$db=mysqli_connect('localhost','root','xxxx','rest aurant');
if (! $db ) {
die("Can't connect: ".mysqli_connect_error());
}
else {
echo "Connection successful!<br/>";
mysqli_close($db);
}
$db=DB::connect('mysql://root:xxxx@localhost/restaurant');
if (DB::isError($db)) {
die($db->getMessage());
}
else {
print "\$db connection was successful!";
}
?>
Aug 5 '05 #1
5 2434
lwoods wrote:
When I execute the following script I can connect using 'mysqli_connect' but
I get a "DB Error: Not Found" when I display the $db->Message() after
attempting the DB::Connect.

And, "yes", the "restaurant" database does exist.

Where should I start looking?

PHP 5.0.4 / mySQL 4.1.13-nt / IIS / XP Pro

TIA,

Larry Woods
<?php
require 'DB.php';
$db=mysqli_connect('localhost','root','xxxx','rest aurant');
if (! $db ) {
die("Can't connect: ".mysqli_connect_error());
}
else {
echo "Connection successful!<br/>";
mysqli_close($db);
}
$db=DB::connect('mysql://root:xxxx@localhost/restaurant');
if (DB::isError($db)) {
die($db->getMessage());
}
else {
print "\$db connection was successful!";
}
?>


When using mysqli_* try also mysqli_select_db and mysqli_query to see if
there are any odd errors there. Your dsn looks fine, and you check for
an error the correct way for a PEAR package, but I don't use DB, so the
only other suggestion I would have is to print_r the $db var if it is an
error and inspect the other properties. Sometimes the PEAR::Error object
holds more information than what is returned in getMessage (FME, anyway)
Aug 5 '05 #2
Thanks, Justin,

I'll play around with it a little more but I think your way is best: Don't
use DB!

Larry

"Justin Koivisto" <ju****@koivi.com> wrote in message
news:HU*****************@news7.onvoy.net...
lwoods wrote:
When I execute the following script I can connect using 'mysqli_connect' but I get a "DB Error: Not Found" when I display the $db->Message() after
attempting the DB::Connect.

And, "yes", the "restaurant" database does exist.

Where should I start looking?

PHP 5.0.4 / mySQL 4.1.13-nt / IIS / XP Pro

TIA,

Larry Woods
<?php
require 'DB.php';
$db=mysqli_connect('localhost','root','xxxx','rest aurant');
if (! $db ) {
die("Can't connect: ".mysqli_connect_error());
}
else {
echo "Connection successful!<br/>";
mysqli_close($db);
}
$db=DB::connect('mysql://root:xxxx@localhost/restaurant');
if (DB::isError($db)) {
die($db->getMessage());
}
else {
print "\$db connection was successful!";
}
?>


When using mysqli_* try also mysqli_select_db and mysqli_query to see if
there are any odd errors there. Your dsn looks fine, and you check for
an error the correct way for a PEAR package, but I don't use DB, so the
only other suggestion I would have is to print_r the $db var if it is an
error and inspect the other properties. Sometimes the PEAR::Error object
holds more information than what is returned in getMessage (FME, anyway)


Aug 5 '05 #3
lwoods wrote:
Thanks, Justin,

I'll play around with it a little more but I think your way is best: Don't
use DB!


I've actually been using MDB, but when I finally get a production server
with php5, I will have to check out sqllite to see if what I've been
doing with databases can all be accomplished with that. If that is the
case, then I'll get rid of abstraction all together since it will be
portable enough for my case.

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Aug 5 '05 #4
I'm going the sqlite direction myself because most of my databases are not
that complex. Also, the price is right...and it's installed everywhere php5
is installed.

Larry

"Justin Koivisto" <ju****@koivi.com> wrote in message
news:3g*****************@news7.onvoy.net...
lwoods wrote:
Thanks, Justin,

I'll play around with it a little more but I think your way is best: Don't use DB!


I've actually been using MDB, but when I finally get a production server
with php5, I will have to check out sqllite to see if what I've been
doing with databases can all be accomplished with that. If that is the
case, then I'll get rid of abstraction all together since it will be
portable enough for my case.

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com


Aug 5 '05 #5

Two things:

1) your DSN for the DB should be:

'mysqli://root:xxxx@localhost/restaurant'

(see details on:
http://pear.php.net/manual/en/packag....intro-dsn.php)

2) You probably want to do this instead:

$db =& DB::connect(....);

There is little point copying the object.

And don't get discouraged. DB works very well indeed, and will allow
you to switch your DB at any point later (unlike using the mysqli...
methods).

/Marcin

lwoods wrote:
When I execute the following script I can connect using 'mysqli_connect' but
I get a "DB Error: Not Found" when I display the $db->Message() after
attempting the DB::Connect.

And, "yes", the "restaurant" database does exist.

Where should I start looking?

PHP 5.0.4 / mySQL 4.1.13-nt / IIS / XP Pro

TIA,

Larry Woods
<?php
require 'DB.php';
$db=mysqli_connect('localhost','root','xxxx','rest aurant');
if (! $db ) {
die("Can't connect: ".mysqli_connect_error());
}
else {
echo "Connection successful!<br/>";
mysqli_close($db);
}
$db=DB::connect('mysql://root:xxxx@localhost/restaurant');
if (DB::isError($db)) {
die($db->getMessage());
}
else {
print "\$db connection was successful!";
}
?>

Aug 8 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ralphie | last post by:
Hello everyone, I was wonerding if anybody has a problem that when you try and instantiate DB class it just returns a blank page ... my code is function session() { 1. $this->_oConn =&...
3
by: MadCrazyNewbie | last post by:
Hey Again Group, Sorry to be a pain:( On my App I have serveral forms All with a Database Connection, and then Several Data Adapters. Is this the best way to do it? i.e have a seperate...
2
by: Sugapablo | last post by:
I have a small test script connecting to a MySQL database. It seems to work, unless I try to use the resource link identifier returned by mysql_connect(); This works and returns all the rows in...
6
by: GD | last post by:
Hi All, I've got MySQL 5.0.21 running on Windows Server 2003, and php running on Apache on a Linux box (Fedora Core 4). Previously when the pages were running on an IIS server the connection...
2
by: gavino | last post by:
http://philip.greenspun.com/wtr/aolserver/introduction-1.html reading this stuff and aolserver+tcl seemed to have some amazing features Why You'd Want to Use AOLserver AOLserver delivers the...
18
by: Bruce A. Julseth | last post by:
I have the following code $Host = "localhost"; $User = "Fred"; $Database = "house"; $Password = "mypw" echo "before mysqli<br />Host: " . $Host . "<br />" . $User . "<br />" . $Database;
3
by: Gregor =?UTF-8?B?S292YcSN?= | last post by:
Hi! Is it possible to alter tablespace so that you don't connect to the database? The problem I have is this. I got a DB backup from a machine with 16 Gb of RAM. There was a bufferpool set to...
9
by: Peter Lux | last post by:
I'm fairly new to c#, but not new to programming. I'm tasked with rewriting our Gupta/Sqlwindows apps (5 years worth of development) in dot Net. The main reason is that virtually no one knows the...
1
by: pravinkedia | last post by:
When I am trying to connect to DB2 using, db2 connect to <database name> is giving error "DB2 Shared memory insufficient" So I tried to change(increase) the kernal values of shmmax, shmmin etc. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.