Array confusion....

Discussion in 'PHP' started by ghadacr, Aug 2, 2007.

  1. #1
    This array does seem to work with this stored procudure....
    
    <?PHP include 'opendb.php'; ?>
    
    <?PHP include 'header.php'; ?>
    
    <?php 
    
    $title   = $_GET['title'];
    $firstname  = $_GET['firstname'];
    $surname  = $_GET['surname'];
    $ChildAdult  = $_GET['ChildAdult'];
    $cost  = $_GET['cost'];
    $notes  = $_GET['notes'];
    $FlightID  = $_GET['FlightID'];
    $ClientDetailID  = $_GET['ClientDetailID'];
    
    
    //----Query 5------
    $query = mssql_init ("sp_insertFlightSpaces"); 
    $data = array( 
    mssql_bind($query, "@FlightID", $FlightID, SQLVARCHAR));
    
    mssql_bind($query, "@ClientDetailID", $ClientDetailID, SQLINT2};
    
     'ChildAdult' => array mssql_bind($query, "@ChildOrAdult", $ChildAdult, SQLVARCHAR);
    
    
     'cost' => array mssql_bind($query, "@cost", $cost, SQLVARCHAR);
    
     'notes' => array mssql_bind($query, "@notes", $notes, SQLVARCHAR);
    
     'title' => array mssql_bind($query, "@Title", $title, SQLVARCHAR);
    
     'firstname' => array mssql_bind($query, "@FirstName", $firstname, SQLVARCHAR);
    
     'surname' => array mssql_bind($query, "@Surname", $surname, SQLVARCHAR);
    };
    
    if (($result = mssql_execute($query)) === false) 
    { 
        die('Could not execute the query query 2(Insert client)'); 
    } 
    
    ///--------------------------------------------
    
    
    	}
    
    	
    						
    	
    mssql_close()
    
    ?>
    <?PHP include 'footer.php'; ?>
    
    
    PHP:
    Then i'm getting errors such as this:

     
    ghadacr, Aug 2, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Which line and file? Please copy the whole error next time. By the way, the way your array is constructed is whacked!
    It should be like so (or so I think :p):
    <?php include 'opendb.php'; ?>
    
    <?php include 'header.php'; ?>
    
    <?php
    
    $title   = $_GET['title'];
    $firstname  = $_GET['firstname'];
    $surname  = $_GET['surname'];
    $ChildAdult  = $_GET['ChildAdult'];
    $cost  = $_GET['cost'];
    $notes  = $_GET['notes'];
    $FlightID  = $_GET['FlightID'];
    $ClientDetailID  = $_GET['ClientDetailID'];
    
    //----Query 5------
    $query = mssql_init("sp_insertFlightSpaces");
    
    mssql_bind($query, "@FlightID", $FlightID, SQLVARCHAR);
    mssql_bind($query, "@ClientDetailID", $ClientDetailID, SQLINT2);
    mssql_bind($query, "@ChildOrAdult", $ChildAdult, SQLVARCHAR);
    mssql_bind($query, "@cost", $cost, SQLVARCHAR);
    mssql_bind($query, "@notes", $notes, SQLVARCHAR);
    mssql_bind($query, "@Title", $title, SQLVARCHAR);
    mssql_bind($query, "@FirstName", $firstname, SQLVARCHAR);
    mssql_bind($query, "@Surname", $surname, SQLVARCHAR);
    
    if (($result = mssql_execute($query)) === false)
    {
        die('Could not execute the query query 2(Insert client)');
    }
    
    mssql_close()
    
    ?>
    
    <?php include 'footer.php'; ?>
    PHP:
     
    krt, Aug 2, 2007 IP
  3. ghadacr

    ghadacr Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah thats the bit i'm trouble with.... but i think you posted the wrong code, its the same as the one above without the array........
     
    ghadacr, Aug 2, 2007 IP
  4. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #4
    What was the point of the array? I removed it because there seemed to be no need for it.

    Or is this what you wanted? (I'm confused :p)
    $data = array( 
      mssql_bind($query, "@FlightID", $FlightID, SQLVARCHAR),
      mssql_bind($query, "@ClientDetailID", $ClientDetailID, SQLINT2),
      'ChildAdult' => mssql_bind($query, "@ChildOrAdult", $ChildAdult, SQLVARCHAR),
      'cost' => mssql_bind($query, "@cost", $cost, SQLVARCHAR),
      'notes' => mssql_bind($query, "@notes", $notes, SQLVARCHAR),
      'title' => mssql_bind($query, "@Title", $title, SQLVARCHAR),
      'firstname' => mssql_bind($query, "@FirstName", $firstname, SQLVARCHAR),
      'surname' => mssql_bind($query, "@Surname", $surname, SQLVARCHAR),
    );
    Code (markup):
     
    krt, Aug 2, 2007 IP
  5. ghadacr

    ghadacr Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sorry i didnt get it yesterday, thats what happens when you look at code for the five hourse straight, do you think a for each would be better
     
    ghadacr, Aug 3, 2007 IP