473,231 Members | 1,792 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,231 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 2426
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. ...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.