Loading ...
Sorry, an error occurred while loading the content.

asp && DBlib

Expand Messages
  • Mike Witkowski
    Does anyone have an idea on this? === $dbh = Sybase::DBlib- dblogin($usr, $pwd, $server, cipro_2k ); $dbh - dbcmd( select * from $table_name where userid =
    Message 1 of 2 , Mar 13, 2002
    • 0 Attachment
      Does anyone have an idea on this?

      ===
      $dbh = Sybase::DBlib->dblogin($usr, $pwd, $server, 'cipro_2k');
      $dbh -> dbcmd("select * from $table_name where userid = '$usr' ");
      ===

      yields an error ::

      ===
      [error] [asp] [15319] [error] Can't call method "dbcmd" on an undefined
      value at session_query_parse.psp line 35. <--> ,
      /usr/local/share/perl/5.6.1/Apache/ASP.pm line 1550
      ===

      when I try to run it in an asp file

      But I can connect to the db server fine when I write a stand alone
      script?

      What am I missing?
      Any thoughts or ideas would be appreciated!


      bigger code excerpt
      =====
      <%@ PerlScript %>

      <%
      use Sybase::DBlib;
      use strict;

      ...
      my vars...
      ...

      $dbh = Sybase::DBlib->dblogin($usr, $pwd, $server, 'cipro_2k');
      $dbh->dbcmd("select * from $table_name where userid = '$usr' ");
      $dbh->dbsqlexec;
      $dbh->dbresults;

      while (@data = $dbh->dbnextrow)
      {
      $i = 1;
      while ($i)
      {
      $stringb = $dbh -> dbcolname($i);
      if (!$stringb) {last}
      $data_hsh{$stringb} = $data[$i-1] unless (!$data[$i-1]);
      $i++;
      }
      }
      %>
      <HTML>
      <HEAD></HEAD>
      <BODY>
      <H1>Say Hello, Boys!</H1>

      <% my @onehit = ("Bel", "Biv", "DeVoe"); %>

      <P>
      <%= $onehit[0] %> says "Hello."
      <BR>
      <%= $onehit[1] %> says "Hello."
      <BR>
      <%= $onehit[2] %> says "Hello."
      <BR>
      <% foreach $key (keys %data_hsh)
      { %>
      <%= $data_hsh{$key}%> <BR>
      <% } %>

      </P>
      </BODY>
      </HTML>
      =====

      Thanks

      Michael Witkowski


      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...
    • Joshua Chamas
      ... Is there anything in $! ? Is there any way to get this to trigger a better error like RaiseError in DBI ? ... My experience with Oracle has been similar,
      Message 2 of 2 , Mar 13, 2002
      • 0 Attachment
        Mike Witkowski wrote:
        >
        > Does anyone have an idea on this?
        >
        > ===
        > $dbh = Sybase::DBlib->dblogin($usr, $pwd, $server, 'cipro_2k');
        > $dbh -> dbcmd("select * from $table_name where userid = '$usr' ");
        > ===
        >
        > yields an error ::
        >
        > ===
        > [error] [asp] [15319] [error] Can't call method "dbcmd" on an undefined
        > value at session_query_parse.psp line 35. <--> ,
        > /usr/local/share/perl/5.6.1/Apache/ASP.pm line 1550
        > ===
        >

        Is there anything in $! ? Is there any way to get this to trigger
        a better error like RaiseError in DBI ?

        > when I try to run it in an asp file
        >
        > But I can connect to the db server fine when I write a stand alone
        > script?
        >
        > What am I missing?
        > Any thoughts or ideas would be appreciated!
        >

        My experience with Oracle has been similar, where so much gets
        configured from the environment variables, that the difference
        between running perl code from the httpd & another user environment
        can make programs not work.

        Running perl code from the httpd causes not only the %ENV to be
        different ( which can be a big deal ) but also causes the user
        itself to be different, so there may be permissions issues.
        Also if you have gone & done something like chroot or jail
        your web server, lots of other things could not be working
        right because of those limitations.

        I would first look and see what is different between %ENV
        as a user from the command line, and in mod_perl. Then I
        would make those parts that might be Sybase related
        the same by doing something like init %ENV variables in
        Script_OnStart on in the script itself to start with.

        If you still have problems, there might be a user permissions
        issue, in which case I would configure the httpd to run
        as the same user as you run scripts from the command line.
        I would not run the web server this way in production, but
        this may help isolate what the problems are. If the user
        you run the web server as normally does not have read access
        to the Sybase libs for example that could cause problems.

        --Josh
        _________________________________________________________________
        Joshua Chamas Chamas Enterprises Inc.
        NodeWorks Founder Huntington Beach, CA USA
        http://www.nodeworks.com 1-714-625-4051

        ---------------------------------------------------------------------
        To unsubscribe, e-mail: asp-unsubscribe@...
        For additional commands, e-mail: asp-help@...
      Your message has been successfully submitted and would be delivered to recipients shortly.