Jump to content

Thrakorzog

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Posts posted by Thrakorzog

  1. I am not exactly a new-b, but I am not so old hat to know what's going on with this one, and can use some sage advice.

    I have the following code that fails:
    [color=red]//Create Tasks
    for ($n = 0 ; $n < count ($TN) ; $n++)
    {
    $sql="INSERT INTO Task (ParentProject, ParentTask, Desc, TimeEstimate, Lvl) ";
    $sql=$sql."VALUES (";
    $sql=$sql."0, ";
    $sql=$sql.$proj_ID.", ";
    $sql=$sql."'".$TN[$n]."', ";
    $sql=$sql.$TT[$n].", ";
    $sql=$sql.$LV[$n].")";

    [color=limegreen]$rs=odbc_exec($conn,$sql);[/color] [i][b] //<-this is line 77[/b][/i]
    if (!$rs)

      {

      exit("Error in SQL:".$sql);

      }
    }[/color]

    ===================================\

    OK, it looks clean, but that usually means you have a database side problem except for two factors:
    1) I have another statement just a few lines up that calls successfully:
    [color=red]//Create SQL statement
    $sql="INSERT INTO Project (ProjName, POC, ScopeState, DesignConcepts, Deliverables, ";
    $sql=$sql."Boundaries, SuccessCriteria, Resources, RisksMit, Assumptions, ";
    $sql=$sql."StakeHolders, ProjectManager, ProjectSponsor) ";
    $sql=$sql."VALUES ('".$PN."', '".$PC."', '".$SC."', '".$DC."', '".$DE;
    $sql=$sql."', '".$BO."', '".$SU."', '".$RS."', '".$RM."', '".$AS;
    $sql=$sql."', '".$ST."', ".$PM.", ".$PS.")";

    //Execute SQL statement
    $rs=odbc_exec($conn,$sql);

    if (!$rs)

      {

      exit("Error in SQL:".$sql);

      }


    //Get ID just inserted Into Database
    $pre_SQL="SELECT TOP 1 ProjID FROM Project ORDER BY ProjID DESC";

    //Execute SQL statement
    $pre_rs=odbc_exec($conn,$pre_SQL);

    if (!$pre_rs)

      {

    exit("Error in SQL".$pre_sql);

      }

    while (odbc_fetch_row($pre_rs))

      {

      $proj_ID=odbc_result($pre_rs,"ProjID");

      }
    [/color]
    ==============================================================

    and .......
    2) the error indicates a problem with my syntax:
    [color=blue]Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLExecDirect in C:\Webroot\matrix\Olive\Functions\NewProjectCreate.php on line 77
    Error in SQL:INSERT INTO Task (ParentProject, ParentTask, Desc, TimeEstimate, Lvl) VALUES (0, 0, '1', 1, 0)[/color]

    Thanks for any insight.
  2. Your code is kinda hard to read, but I have a similar setup, I use the following as an include file:

     

    <?php

     

    $conn=odbc_connect('databaseName','UN','PW');

     

    if (!$conn)

     

      {

     

          exit("Connection Failed: " . $conn);

     

      }

     

    ?>

     

    I have had the ODBC setup for a long time using it with ASP, but I am converting my stuff to PHP.  Everything else outside of this call, was done in the System DSN to setup the database as an ODBC accessible datasource.

     

    Hope that helps

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.