Select problem with Apache, php4.3 and Jet 4.0 via ODBC on Win 2k/xp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Morton

    Select problem with Apache, php4.3 and Jet 4.0 via ODBC on Win 2k/xp

    Hi,

    This is my first posting to this list, I guess a small intro should be
    first, been developing in PHP for sometime, mainly with Mysql and nearly
    always on Windows (oops, sorry).

    I have done some bizarre things with PHP, but now I am involved in
    re-writing an application (from ASP.NET).

    The database however I can't change so easily as there are other
    dependancies, and it's JET 4.0

    This is the table.
    TableRowID - AutoNumber
    UCID - Text
    TransactionTime - Date/Time

    etc...

    I have having trouble with getting any information out of it though...!

    I can complete the following:

    $db_resource = new accessDB();
    $db_resource->host=$dbDSN;
    $db_resource->username=$dbUs ername;
    $db_resource->open($dbPasswo rd);

    // build option list based on the field names in the table. Query is run
    to just get the fieldnames
    $query='SELECT * FROM TransTable'

    $db_resource->query($query );
    $db_resource->get_field_name s();



    and although the fieldnames are returned through my function, if I try
    to extract the data from the query none is there...


    if I add a where statement I get an error which I can't resolve:

    SELECT * FROM TransTable WHERE ((TransactionTi me>="2005-12-16 16:00:01")
    AND (TransactionTim e<="2005-12-21 16:00:00")) ORDER BY TableRowID

    Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access
    Driver] Too few parameters. Expected 2., SQL state 07001 in
    SQLExecDirect in c:\apache group\apache\ht docs\wmmc\db_ac cess_class.inc
    on line 58



    ideas?

    Thanks in advance

    Richard
  • Erwin Moller

    #2
    Re: Select problem with Apache, php4.3 and Jet 4.0 via ODBC on Win 2k/xp

    Richard Morton wrote:
    [color=blue]
    > Hi,
    >
    > This is my first posting to this list, I guess a small intro should be
    > first, been developing in PHP for sometime, mainly with Mysql and nearly
    > always on Windows (oops, sorry).
    >
    > I have done some bizarre things with PHP, but now I am involved in
    > re-writing an application (from ASP.NET).
    >
    > The database however I can't change so easily as there are other
    > dependancies, and it's JET 4.0
    >
    > This is the table.
    > TableRowID - AutoNumber
    > UCID - Text
    > TransactionTime - Date/Time
    >
    > etc...
    >
    > I have having trouble with getting any information out of it though...!
    >
    > I can complete the following:
    >
    > $db_resource = new accessDB();
    > $db_resource->host=$dbDSN;
    > $db_resource->username=$dbUs ername;
    > $db_resource->open($dbPasswo rd);
    >
    > // build option list based on the field names in the table. Query is run
    > to just get the fieldnames
    > $query='SELECT * FROM TransTable'
    >
    > $db_resource->query($query );
    > $db_resource->get_field_name s();
    >
    >
    >
    > and although the fieldnames are returned through my function, if I try
    > to extract the data from the query none is there...
    >
    >
    > if I add a where statement I get an error which I can't resolve:
    >
    > SELECT * FROM TransTable WHERE ((TransactionTi me>="2005-12-16 16:00:01")
    > AND (TransactionTim e<="2005-12-21 16:00:00")) ORDER BY TableRowID
    >
    > Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access
    > Driver] Too few parameters. Expected 2., SQL state 07001 in
    > SQLExecDirect in c:\apache group\apache\ht docs\wmmc\db_ac cess_class.inc
    > on line 58
    >
    >
    >
    > ideas?[/color]

    If memory serves me well, access wants the most bizarre format for dates.
    Try # instead of "

    That might fix it.

    Also, you might have a look at ADODB (www.phplens.com/adodb) and put that
    inbetween.
    Then use ADODB functions to do the formatting.
    Also use it for stringliterals and such. Some database want ' to be
    presented as \' others as '' etc.
    ADODB will take care of that.

    Nice extra feature is that next time you switch databsses, adodb will
    figure it all out for you, you only need to change the database used in
    adodb.

    Regards,
    Erwin Moller
    [color=blue]
    >
    > Thanks in advance
    >
    > Richard[/color]

    Comment

    • Richard Morton

      #3
      Re: Select problem with Apache, php4.3 and Jet 4.0 via ODBC on Win2k/xp

      Hi Erwin et al.

      Thanks for that. However I am still one step back from there. Even if I
      do the simplest of statements I can not get to the data.

      'Select * from table'

      I can't get to the data (I can however get the field names for some
      reason so I am connected to the datasource). The _second_ time I try to
      run the query I get the following:

      Warning: odbc_execute(): SQL error: [Microsoft][ODBC Microsoft Access
      Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecute
      in c:\apache group\apache\ht docs\wmmc\db_ac cess_class.inc on line 59

      To summarise:

      The first time I run a query (even a simple one) it it is silent and I
      can get field names but not any data.

      The second time I run the query I get the above error.

      Any ideas.

      Rich

      Erwin Moller wrote:[color=blue]
      > Richard Morton wrote:
      >
      >[color=green]
      >>Hi,
      >>
      >>This is my first posting to this list, I guess a small intro should be
      >>first, been developing in PHP for sometime, mainly with Mysql and nearly
      >>always on Windows (oops, sorry).
      >>
      >>I have done some bizarre things with PHP, but now I am involved in
      >>re-writing an application (from ASP.NET).
      >>
      >>The database however I can't change so easily as there are other
      >>dependancie s, and it's JET 4.0
      >>
      >>This is the table.
      >>TableRowID - AutoNumber
      >>UCID - Text
      >>TransactionTi me - Date/Time
      >>
      >>etc...
      >>
      >>I have having trouble with getting any information out of it though...!
      >>
      >>I can complete the following:
      >>
      >>$db_resourc e = new accessDB();
      >>$db_resourc e->host=$dbDSN;
      >>$db_resourc e->username=$dbUs ername;
      >>$db_resourc e->open($dbPasswo rd);
      >>
      >>// build option list based on the field names in the table. Query is run
      >>to just get the fieldnames
      >>$query='SELEC T * FROM TransTable'
      >>
      >>$db_resourc e->query($query );
      >>$db_resourc e->get_field_name s();
      >>
      >>
      >>
      >>and although the fieldnames are returned through my function, if I try
      >>to extract the data from the query none is there...
      >>
      >>
      >>if I add a where statement I get an error which I can't resolve:
      >>
      >>SELECT * FROM TransTable WHERE ((TransactionTi me>="2005-12-16 16:00:01")
      >>AND (TransactionTim e<="2005-12-21 16:00:00")) ORDER BY TableRowID
      >>
      >>Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access
      >>Driver] Too few parameters. Expected 2., SQL state 07001 in
      >>SQLExecDire ct in c:\apache group\apache\ht docs\wmmc\db_ac cess_class.inc
      >>on line 58
      >>
      >>
      >>
      >>ideas?[/color]
      >
      >
      > If memory serves me well, access wants the most bizarre format for dates.
      > Try # instead of "
      >
      > That might fix it.
      >
      > Also, you might have a look at ADODB (www.phplens.com/adodb) and put that
      > inbetween.
      > Then use ADODB functions to do the formatting.
      > Also use it for stringliterals and such. Some database want ' to be
      > presented as \' others as '' etc.
      > ADODB will take care of that.
      >
      > Nice extra feature is that next time you switch databsses, adodb will
      > figure it all out for you, you only need to change the database used in
      > adodb.
      >
      > Regards,
      > Erwin Moller
      >
      >[color=green]
      >>Thanks in advance
      >>
      >>Richard[/color]
      >
      >[/color]

      Comment

      • Erwin Moller

        #4
        Re: Select problem with Apache, php4.3 and Jet 4.0 via ODBC on Win 2k/xp

        Richard Morton wrote:
        [color=blue]
        > Hi Erwin et al.
        >
        > Thanks for that. However I am still one step back from there. Even if I
        > do the simplest of statements I can not get to the data.
        >
        > 'Select * from table'
        >
        > I can't get to the data (I can however get the field names for some
        > reason so I am connected to the datasource). The _second_ time I try to
        > run the query I get the following:
        >
        > Warning: odbc_execute(): SQL error: [Microsoft][ODBC Microsoft Access
        > Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecute
        > in c:\apache group\apache\ht docs\wmmc\db_ac cess_class.inc on line 59
        >
        > To summarise:
        >
        > The first time I run a query (even a simple one) it it is silent and I
        > can get field names but not any data.
        >
        > The second time I run the query I get the above error.
        >
        > Any ideas.[/color]

        Hi

        Try following an example that takes you through, step by step.
        Look at www.php.net and look up odbc.

        One thing you do wrong in your original code is that you do not store your
        result somewhere:[color=blue][color=green][color=darkred]
        >>>$query='SELE CT * FROM TransTable'
        >>>
        >>>$db_resour ce->query($query );
        >>>$db_resour ce->get_field_name s();[/color][/color][/color]

        That is not good.

        Try something like: $RS = $db_resource->query($query );

        Then use $RS for looping.
        But just look online and scout through the examples.

        Good luck.
        Regards,
        Erwin Moller
        [color=blue]
        >
        > Rich
        >
        > Erwin Moller wrote:[color=green]
        >> Richard Morton wrote:
        >>
        >>[color=darkred]
        >>>Hi,
        >>>
        >>>This is my first posting to this list, I guess a small intro should be
        >>>first, been developing in PHP for sometime, mainly with Mysql and nearly
        >>>always on Windows (oops, sorry).
        >>>
        >>>I have done some bizarre things with PHP, but now I am involved in
        >>>re-writing an application (from ASP.NET).
        >>>
        >>>The database however I can't change so easily as there are other
        >>>dependancies , and it's JET 4.0
        >>>
        >>>This is the table.
        >>>TableRowID - AutoNumber
        >>>UCID - Text
        >>>TransactionT ime - Date/Time
        >>>
        >>>etc...
        >>>
        >>>I have having trouble with getting any information out of it though...!
        >>>
        >>>I can complete the following:
        >>>
        >>>$db_resour ce = new accessDB();
        >>>$db_resour ce->host=$dbDSN;
        >>>$db_resour ce->username=$dbUs ername;
        >>>$db_resour ce->open($dbPasswo rd);
        >>>
        >>>// build option list based on the field names in the table. Query is run
        >>>to just get the fieldnames
        >>>$query='SELE CT * FROM TransTable'
        >>>
        >>>$db_resour ce->query($query );
        >>>$db_resour ce->get_field_name s();
        >>>
        >>>
        >>>
        >>>and although the fieldnames are returned through my function, if I try
        >>>to extract the data from the query none is there...
        >>>
        >>>
        >>>if I add a where statement I get an error which I can't resolve:
        >>>
        >>>SELECT * FROM TransTable WHERE ((TransactionTi me>="2005-12-16 16:00:01")
        >>>AND (TransactionTim e<="2005-12-21 16:00:00")) ORDER BY TableRowID
        >>>
        >>>Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access
        >>>Driver] Too few parameters. Expected 2., SQL state 07001 in
        >>>SQLExecDirec t in c:\apache group\apache\ht docs\wmmc\db_ac cess_class.inc
        >>>on line 58
        >>>
        >>>
        >>>
        >>>ideas?[/color]
        >>
        >>
        >> If memory serves me well, access wants the most bizarre format for dates.
        >> Try # instead of "
        >>
        >> That might fix it.
        >>
        >> Also, you might have a look at ADODB (www.phplens.com/adodb) and put that
        >> inbetween.
        >> Then use ADODB functions to do the formatting.
        >> Also use it for stringliterals and such. Some database want ' to be
        >> presented as \' others as '' etc.
        >> ADODB will take care of that.
        >>
        >> Nice extra feature is that next time you switch databsses, adodb will
        >> figure it all out for you, you only need to change the database used in
        >> adodb.
        >>
        >> Regards,
        >> Erwin Moller
        >>
        >>[color=darkred]
        >>>Thanks in advance
        >>>
        >>>Richard[/color]
        >>
        >>[/color][/color]

        Comment

        Working...