SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Connecting to Mysql database

    Why does the following code works

    Code:
    $dbh = DBI->connect("DBI:mysql:$database2:$dbserver",$dbusername,$dbpassword);
    while this one doesn't?

    Code:
    $dbh = DBI->connect("DBI:mysql:$database2:$dbserver",$dbusername,$dbpassword) or die "Can't make 1st database connect: $DBI::errstr\n";
    Ballot-Box.net - free polls for webmasters
    FormLog.com - free form processor

  2. #2
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    from the DBI module:

    errstr

    $str = $h->errstr;

    Returns the native database engine error message from the last DBI method called. This has the same lifespan issues as the "err" method described above.

    The returned string may contain multiple messages separated by newline characters.

    The errstr() method should not be used to test for errors, use err() for that, because drivers may return 'success with information' or warning messages via errstr() for methods that have not 'failed'.

  3. #3
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe your second statement means

    $dbh = ((DBI->....) or (die ".."));

    The result being 1 = true.

    Bob

  4. #4
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bob742 View Post
    Maybe your second statement means

    $dbh = ((DBI->....) or (die ".."));

    The result being 1 = true.

    Bob
    Read my previous post, it explains what the problem is.

  5. #5
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sryk4 View Post
    Ok, thanks for the help buddies. I think he resolved his problem, right?
    Who are you? I smell spam.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •