Jump to content

darkgr33n

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Posts posted by darkgr33n

  1. Try typecasting the object to an array. E.g.

     

    
    $foo = $ThestdClass;
    
    $bar = (array)$foo;
    
    no that should convert the stdClass into an array
    
    

     

    Thanks, although not used directly, it did get me looking further, and I've come up with the following, although still seems quite long-winded. Perhaps there's no shorter way. I wish the SOAP return would add a sequential suffix to the tag names, but I don't have control over that :(

     

    $foo = array (
      (object) array("Label" => "Street", "Line" => "Stanley Road"),
      (object) array("Label" => "Town", "Line" => "Manchester"),
      (object) array("Label" => "Number of Rules", "Line" => "2"),
      (object) array("Label" => "Rule", "Line" => "X014"),
      (object) array("Label" => "Rule Text", "Line" => "Rule text for X014"),
      (object) array("Label" => "Rule", "Line" => "X015"),
      (object) array("Label" => "Rule Text", "Line" => "Rule text for X015"),
      );
    
    function objectToArray( $object )
        {
            if( !is_object( $object ) && !is_array( $object ) )
            {
                return $object;
            }
            if( is_object( $object ) )
            {
                $object = get_object_vars( $object );
            }
            return array_map( 'objectToArray', $object );
        }
    
    // cast the object 
    $array = (array) $foo;
    
    // convert array to object 
    $array = (array) objectToArray($foo);
    
    /*
    
    which gives:
    
    Array ( 
    [0] => Array ( [Label] => Street [Line] => Stanley Road ) 
    [1] => Array ( [Label] => Town [Line] => Manchester ) 
    [2] => Array ( [Label] => Number of Rules [Line] => 2 ) 
    [3] => Array ( [Label] => Rule [Line] => X014 ) 
    [4] => Array ( [Label] => Rule Text [Line] => Rule text for X014 ) 
    [5] => Array ( [Label] => Rule [Line] => X015 ) 
    [6] => Array ( [Label] => Rule Text [Line] => Rule text for X015 ) )
    */
    
    $suffix = 0;
    $array_count = count($array)-1;
    
    for ($i=0;$i<=$array_count ;$i++)
    {
    if ($array[$i]['Label'] != 'Rule' AND $array[$i]['Label'] != 'Rule Text')
    {
    $_SESSION[$array[$i]['Label']] = $array[$i]['Line'];
    }
    else
    {
    switch ($array[$i]['Label'])		
    {			
    case 'Rule':			
    $suffix ++;			
    $_SESSION[$array[$i]['Label'].$suffix] = $array[$i]['Line'];			
    break;			
    
    case 'Rule Text':			
    $_SESSION[$array[$i]['Label'].$suffix] = $array[$i]['Line'];			
    break;		
    }
    }
    }
    
    var_dump($_SESSION);
    
    /*
    
    prints out:
    
    array(7) { 
    ["Street"]=> string(12) "Stanley Road" 
    ["Town"]=> string(10) "Manchester" 
    ["Number of Rules"]=> string(1) "2" 
    ["Rule1"]=> string(4) "X014" 
    ["Rule Text1"]=> string(18) "Rule text for X014" 
    ["Rule2"]=> string(4) "X015" 
    ["Rule Text2"]=> string(18) "Rule text for X015" 
    } 
    

  2. ok, i've got something now, although still not too happy about two foreach loops for one iteration.

     

    foreach($foo as $bar)
    {
      	if ($bar->Label != 'Rule' AND $bar->Label != 'Rule Text') 
    {
    	$_SESSION[$bar->Label] = $bar->Line;
    } 
    else 
    {
    	switch ($bar->Label)
    	{
    		case 'Rule':
    		$suffix ++;
    		$rules[$bar->Label.$suffix] = $bar->Line;
    		break;
    		case 'Rule Text':
    		$rules[$bar->Label.$suffix] = $bar->Line;
    		break;
    	}
    }
    }
    
    foreach ($rules as $key => $value)
    {
    $_SESSION[$key] = $value;
    }
    
    

     

    which gives the following:

     

    var_dump ($_SESSION);
    
    array(7) { 
    ["Street"]=> string(12) "Stanley Road"
    ["Town"]=> string(10) "Manchester" 
    ["Number of Rules"]=> string(1) "2" 
    ["Rule1"]=> string(4) "X014" 
    ["Rule Text1"]=> string(18) "Rule text for X014"
    ["Rule2"]=> string(4) "X015" 
    ["Rule Text2"]=> string(18) "Rule text for X015" 
    } 
    

     

    which is pretty much what I was after, but open to any cleaner suggestions ;)

  3. Ok, I've got it down a little, and am using arrays ;)

     

    $foo = array (	(object) array("Label" => "Street", "Line" => "Stanley Road"),	(object) array("Label" => "Town", "Line" => "Manchester"),	(object) array("Label" => "Number of Rules", "Line" => "2"),	(object) array("Label" => "Rule", "Line" => "X014"),	(object) array("Label" => "Rule Text", "Line" => "Rule text for X014"),	(object) array("Label" => "Rule", "Line" => "X015"),	(object) array("Label" => "Rule Text", "Line" => "Rule text for X015"));
    
    $suffix = 0;
    $rules = array();
    
    foreach($foo as $bar)
    {
      	if ($bar->Label == 'Rule')
      	{
    	$suffix ++;
    	$rules[] = array($bar->Label.$suffix => $bar->Line);
    }
    elseif ($bar->Label == 'Rule Text')
      	{
    	$rules[] = array($bar->Label.$suffix => $bar->Line);
    }
    else
    {
    	echo ("{$bar->Label} : {$bar->Line}<br>");
    }
    }
    print_r ($rules);
    

     

    which returns:

     

    Street : Stanley Road
    Town : Manchester
    Number of Rules : 2
    Array ( 
    [0] => Array ( [Rule1] => X014 )
    [1] => Array ( [Rule Text1] => Rule text for X014 ) 
    [2] => Array ( [Rule2] => X015 ) 
    [3] => Array ( [Rule Text2] => Rule text for X015 )
    ) 
    

     

    which I think I can work with. The SOAP Response is always going to be a Rule followed by a Rule Text, so I should be safe ... I think ...

  4. Just remember that you can store arrays in $_SESSION.  Anytime you find yourself with variables like var1, var2, var3 in PHP you are definitely doing things wrong :P

     

    Arrays are WIN.

     

    lol, thanks for the tip, i like WIN;

    being self-taught I've missed some of those fundamental pearls of wisdom - i shall carry it with me always :)

  5. Thanks for that. I've gone down a similar road, spurred on by your first post:

     

    
    $rule_suffix = 0;
    $text_suffix = 0;
    
    foreach($foo as $bar)
    {
      	if ($bar->Label == 'Rule')
      	{
    	$rule_suffix ++;
    	echo ("RULE" . $rule_suffix . " : " . $bar->Line ."<br>");
    }
    elseif ($bar->Label == 'Rule Text')
      	{
    	$text_suffix ++;
    	echo ("RULE TEXT" . $text_suffix . " : " . $bar->Line ."<br>");
    }
    else	
    {
    	echo ("{$bar->Label} : {$bar->Line}<br>");
    }
    }
    
    

     

    But you're right, not sure it is the best way to go, but it works at least, so I am further on than I was.

     

    As an overview, I'm receiving a SOAP Reponse, in the format of the $foo object, and just need to parse the object, pull out the variables into Session variables, and then write to a database;

     

    Obviously if we didn't have elements of the same name returned, it would be a lot less convoluted, but unfortunately, they're the requirements we're working to.

     

    Thanks again for helping me out, I appreciate that. Also encouraged that I came up with something similar, although not as robust as yours.

     

     

  6. You mean like this?

     

    <?php
    
    $foo = array (
    (object) array("Label" => "Street", "Line" => "Stanley Road"),
    (object) array("Label" => "Town", "Line" => "Manchester"),
    (object) array("Label" => "Number of Rules", "Line" => "2"),
    (object) array("Label" => "Rule", "Line" => "X014"),
    (object) array("Label" => "Rule Text", "Line" => "Rule text for X014"),
    (object) array("Label" => "Rule", "Line" => "X015"),
    (object) array("Label" => "Rule Text", "Line" => "Rule text for X015")
    );
    
    foreach ($foo as $bar) {
    echo "{$bar->Line}<br />";
    }
    

     

    Yes, sort of!

     

    But, rather than echoing them out, I need to set a session variable named from the Label, which is why I tried putting them in an array, and when I get to the Rule session variable, I can add a number suffix.

     

    Sorry, maybe my initial post wasn't that clear.

     

    I really want to achieve being able to set the sessions like this:

     

    $_SESSION['Street'] = "Stanley road";
    $_SESSION['Town'] = "Manchester";
    $_SESSION['Rule1'] = "X014";
    $_SESSION['RuleText1'] = "Rule text for X014";
    $_SESSION['Rule2'] = "X015";
    $_SESSION['RuleText2'] = "Rule text for X015";
    

     

    so, when I come across a Rule or Rule Text Label, I need to add a count suffix to the name, so

     

    Rule + 1

    Rule + 2

    etc

     

    Does that make more sense ?

     

    Sorry. I've tried a few things, but it starts to get really convoluted, and I'm sure there must be an easier way!

     

    Cheers

  7. Hi

     

    I've got a StdClass Object that I need to parse. I can parse specific elements, but not sure how to parse when there is more than one element with the same name.

     

    example:

     

     

    $foo = array (
      (object) array("Label" => "Street", "Line" => "Stanley Road"),
      (object) array("Label" => "Town", "Line" => "Manchester"),
      (object) array("Label" => "Number of Rules", "Line" => "2"),
      (object) array("Label" => "Rule", "Line" => "X014"),
      (object) array("Label" => "Rule Text", "Line" => "Rule text for X014"),
      (object) array("Label" => "Rule", "Line" => "X015"),
      (object) array("Label" => "Rule Text", "Line" => "Rule text for X015")
      );
    
    /*
    
    this is what $foo contains with print_r
    
    Array ( 
    [0] => stdClass Object ( 
      [Label] => Street 
      [Line] => Stanley Road ) 
    [1] => stdClass Object ( 
      [Label] => Town 
      [Line] => Manchester ) 
    [2] => stdClass Object ( 
      [Label] => Number of Rules 
      [Line] => 2 ) 
    [3] => stdClass Object ( 
      [Label] => Rule 
      [Line] => X014 ) 
    [4] => stdClass Object ( 
      [Label] => Rule Text 
      [Line] => Rule text for X014 ) 
    [5] => stdClass Object ( 
      [Label] => Rule 
      [Line] => X015 ) 
    [6] => stdClass Object ( 
      [Label] => Rule Text 
      [Line] => Rule text for X015 ) 
    ) 
    
    */
    
    foreach($foo as $foo_data)
    {
      $foo_list [$foo_data->Label] = $foo_data->Line;
    }
    
    echo ($foo_list["Street"] . "<br>");
    echo ($foo_list["Town"] . "<br>");
    echo ($foo_list["Number of Rules"] . "<br>");
    echo ($foo_list["Rule"] . "<br>");
    echo ($foo_list["Rule Text"] . "<br>");
    echo ($foo_list["Rule"] . "<br>");
    echo ($foo_list["Rule Text"] . "<br>");
    
    /*
    
    this is what is written with the echo's above - two sets of X015
    
    Stanley Road
    Manchester
    2
    X015
    Rule text for X015
    X015
    Rule text for X015
    
    */
    

     

    There is a "Number of Rules" element which will tell me how many Rule elements I'm expecting.

     

    This could be anything between 0 and 10 rule/rule text element pairs, the example above having 2.

     

    Any ideas how I would parse the entire array correctly [i'm going to be putting them into separate variables to use in a database, just using echo in the example.

     

    I need to see:

     

     

    Stanley Road
    Manchester
    2
    X014
    Rule text for X014
    X015
    Rule text for X015
    

     

    Thanks

  8. Does anyone know how to build a SOAP request using non-wsdl soap client ?

     

    It looks like it may achieve what I'm after, but I'm not sure what to put in location or uri

     

    It works something like:

     

    $client = new SoapClient(null, array('location' => "http://localhost/soap.php",
                                         'uri'      => "http://test-uri/",
                                         'style'    => SOAP_DOCUMENT,
                                         'use'      => SOAP_LITERAL));
    
    

     

    And then I think you can add XML in the form of a variable.

     

    Anyone have any experience sending custom SOAP Requests like this ??

     

    Thanks

  9. I'd like to change it but I can't as it's automatically created from the soapClient call, I seem to have no control over it. I wish I did. I'd like to say URI = "qas" or something, but I've searched for what seems like days, and can see no way of doing it. I've come across a few posts that call this a PHP bug, but I'm not sure.

     

    I wonder if the WSDL file is at fault ?

     

    I have no idea how these things work yet, but if it helps, here are the first few lines of the WSDL file in question:

     

    <?xml version="1.0" encoding="utf-8" ?> 
    - <definitions name="QAS" targetNamespace="http://www.qas.com/web-2005-10" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:qas="http://www.qas.com/web-2005-10">
    - <types>
    - <xs:schema elementFormDefault="qualified" targetNamespace="http://www.qas.com/web-2005-10" xmlns="http://www.w3.org/2001/XMLSchema">
    

     

  10. Hi All.

     

    I'm struggling with my SOAP request, and am really at a dead-end. I am not in control of the wsdl file I am referencing, just trying to format my request correctly. I am using the same wsdl file for other requests, which all work, but this one has me stumped.

     

    The reason is, I have been told I need to amend the namespace on the Request, but I have no idea how to do that, as I don't explicitly set them anywhere.

     

    Can I amend the namespace ?

     

    Here's how I make my request:

     

    $authenticate = array( 
    'Country' => 'GBR', 
    'Engine' => array ('_' => 'Authenticate', 'Flatten' => true, 'PromptSet' => 'Default'), 
    'Layout' => '< Default >', 
    'SearchSpec' => array( 
      array('_' => 'Yes', 'Key' => 'CTRL_SEARCHCONSENT'), 
      array('_' => 'MR', 'Key' => 'NAME_TITLE'), 
      array('_' => 'Zuzu', 'Key' => 'NAME_FORENAME'), 
      array('_' => '', 'Key' => 'NAME_INITIALS'), 
      array('_' => 'Zuzu', 'Key' => 'NAME_SURNAME'), 
      array('_' => '12/12/1956', 'Key' => 'NAME_DATEOFBIRTH'), 
      array('_' => 'M', 'Key' => 'NAME_SEX'), 
      array('_' => '', 'Key' => 'ADDR_FLAT'), 
      array('_' => '', 'Key' => 'ADDR_HOUSENAME'), 
      array('_' => '27', 'Key' => 'ADDR_HOUSENUMBER'), 
      array('_' => 'Manor Road', 'Key' => 'ADDR_STREET'), 
      array('_' => 'Alresford', 'Key' => 'ADDR_DISTRICT'), 
      array('_' => 'Zuzuchester', 'Key' => 'ADDR_TOWN'), 
      array('_' => '', 'Key' => 'ADDR_COUNTY'), 
      array('_' => 'CO4 4LT', 'Key' => 'ADDR_POSTCODE') 
      ) 
    ); 
    
    $response_doAuthenticate = $client->DoSearch($authenticate);
    
    

     

     

     

    and this is what I get when I grab getLastRequest:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.qas.com/web-2005-10">
    <SOAP-ENV:Body>
    <ns1:QASearch>
    <ns1:Country>GBR</ns1:Country>
    <ns1:Engine Flatten="true" PromptSet="Default">Authenticate</ns1:Engine>
    <ns1:Layout><Default></ns1:Layout>
    <ns1:SearchSpec>
    <ns1:SearchTerm Key="CTRL_SEARCHCONSENT">Yes</ns1:SearchTerm>
    <ns1:SearchTerm Key="NAME_TITLE">MR</ns1:SearchTerm>
    <ns1:SearchTerm Key="NAME_FORENAME">Zuzu</ns1:SearchTerm>
    <ns1:SearchTerm Key="NAME_INITIALS"></ns1:SearchTerm>
    <ns1:SearchTerm Key="NAME_SURNAME">Zuzu</ns1:SearchTerm>
    <ns1:SearchTerm Key="NAME_DATEOFBIRTH">12/12/1956</ns1:SearchTerm>
    <ns1:SearchTerm Key="NAME_SEX">M</ns1:SearchTerm>
    <ns1:SearchTerm Key="ADDR_HOUSENUMBER">27</ns1:SearchTerm>
    <ns1:SearchTerm Key="ADDR_STREET">Manor Road</ns1:SearchTerm>
    <ns1:SearchTerm Key="ADDR_DISTRICT">Alresford</ns1:SearchTerm>
    <ns1:SearchTerm Key="ADDR_TOWN">Zuzuchester</ns1:SearchTerm>
    <ns1:SearchTerm Key="ADDR_POSTCODE">CO4 4LT</ns1:SearchTerm>
    </ns1:SearchSpec>
    </ns1:QASearch>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

     

    BUT I have been told that the ns1: on all tags, is causing an error - but only on one line, here:

     

    <ns1:Engine Flatten="true" PromptSet="Default">Authenticate</ns1:Engine>

     

    I need this to construct is as here:

     

    <qas:Engine Flatten="true" PromptSet="Default">Authenticate</qas:Engine>

     

    or with no namespace at all:

     

    <Engine Flatten="true" PromptSet="Default">Authenticate</Engine>

     

    Is this possible ??

     

    Perhaps I shouldn't be using soapClient.

     

    Any ideas ?!

     

    Thanks

     

     

  11. UPDATE:

     

    Managed to get this working if anyone else is interested. I just needed to query the whole statement, rather than running separate queries:

     

    $sql_query = "BEGIN TRANSACTION\n";

    $sql_query .= "BEGIN TRY\n";

     

    foreach($insert_array as $value)

    {

      $sql_query .= "${$value}\n";

    }

           

    $sql_query .= "COMMIT TRANSACTION\n";

    $sql_query .= "END TRY\n";

     

    $sql_query .= "BEGIN CATCH\n";

    $sql_query .= "ROLLBACK TRANSACTION\n";

    $sql_query .= "END CATCH\n";

     

  12. UPDATE:

     

    Managed to get this working if anyone else is interested. I just needed to query the whole statement, rather than running separate queries:

     

    $sql_query = "BEGIN TRANSACTION\n";

    $sql_query .= "BEGIN TRY\n";

     

    foreach($insert_array as $value)

    {

      $sql_query .= "${$value}\n";

    }

     

    $sql_query .= "COMMIT TRANSACTION\n";

    $sql_query .= "END TRY\n";

     

    $sql_query .= "BEGIN CATCH\n";

    $sql_query .= "ROLLBACK TRANSACTION\n";

    $sql_query .= "END CATCH\n";

     

     

  13. I use mysqli's autocommit and rollback methods, so it looks a bit different.

     

    Ah, ok, thanks. Don't think mssql has anything like that.

     

    If I actually surpress the ROLLBACK query with @mssql_query("ROLLBACK TRAN"), everything works as expected, but not sure running and hiding from the error [The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION] is the correct thing to do ??

     

    mssql_query("BEGIN TRAN");

     

    foreach($insert_array as $value)

    {

      $result = @mssql_query(${$value});

      if(!$result)

      {

      @mssql_query("ROLLBACK TRAN");

      }

    }

     

    @mssql_query("COMMIT TRAN");

     

    I do remember reading something about COMMIT/ROLLBACK not working if more than one mssql_query is run as it loses its memory, but also read somewhere that was untrue. Not sure what to think.

     

    Maybe I'm better using the pseudo rollback, rather than surpress the error on the real one [even though it seems to work; it doesn't write to the DB if there's an data error, and if the data is fine, it writes ok]

     

    Way out of my depth on this one.

     

    ?

     

     

     

  14. If I do the following, it sort of works, a psudeo-rollback if you like, as it does not write to the DB on an error, but the auto-incrementing ID field in the table is incremented by one. I'm guessing a proper ROLLBACK does not increment this.

     

    $commit = TRUE;

     

    if(mssql_query("BEGIN TRAN"))

    {

    foreach($insert_array as $value)

    {

    $result = @mssql_query(${$value});

    if(!$result)

    {

    $commit = FALSE;

    }

    }

    if ($commit)

    {

    mssql_query("COMMIT TRAN");

    }

    else

    {

    // mssql_query("ROLLBACK"); // Doesn't work, ignore

    echo ("DO SOMETHING TO DEAL WITH THE ERROR");

    }

    }

     

     

    What do other people do with multiple inserts ?

     

    FYI, the for loop adds about 6 INSERT commands to 6 tables. If I have no error, this works fine, but I need to make sure if I do get an error nothing is written, and ideally, nothing is incremented.

     

  15.  

    The $query is defined as:

     

    $query = "SELECT ENTITY_DATA.CustomerName, POLLING_DATA.ProductLine, POLLING_DATA.ProductVersion";

    $query .= "FROM ENTITY_DATA INNER JOIN (SELECT row_number() over(partition by EntityID order by PollingID desc) as seq, ProductLine, ProductVersion, EntityID, PollingID FROM POLLING_DATA) POLLING_DATA";

    $query .= "ON ENTITY_DATA.EntityID = POLLING_DATA.EntityID";

    $query .= "WHERE POLLING_DATA.seq = 1";

     

    Any help would be much appreciated!

     

    Is it something as silly as a lack of white space at the end of each addition ? To me, your SELECT would read:

     

    SELECT ENTITY_DATA.CustomerName, POLLING_DATA.ProductLine, POLLING_DATA.ProductVersionFROM ENTITY_DATA INNER JOIN (SELECT row_number() over(partition by EntityID order by PollingID desc) as seq, ProductLine, ProductVersion, EntityID, PollingID FROM POLLING_DATA) POLLING_DATA

     

    .......ProductVersionFROM ENTITY_DATA......

     

    adding a space at the end may work:

    $query = "SELECT ENTITY_DATA.CustomerName, POLLING_DATA.ProductLine, POLLING_DATA.ProductVersion ";

  16.  

    The following is what plan on using. Is it sufficient?

     

    $input = str_replace("'", "''", $input);
    mssql_query (sprintf ("UPDATE Login SET user = '%s'", $input));
    

     

    Any input would be helpful.

     

     

    That's what I've done and it seems to work

    . I did a fair amount of research, and read a couple of times that this was the preferred method.
  17. UPDATE:

     

    While ROLLBACK is still giving me errors, I can impersonate/bodge this by not calling the COMMIT. I've also added the error supressing @ on the looped query and am testing by passing a varchar to an int field.

     

     

    $commit = TRUE;

     

    if(mssql_query("BEGIN TRAN"))

    {

      foreach($insert_array as $value)

      {

          $result = @mssql_query(${$value});

          if(!$result)

          {

          $commit = FALSE;

          }

      }

      if ($commit)

      {

        mssql_query($commit_transaction);

      }

      else

      {

        echo ("DEAL WITH THE ERROR");

      }

    }

     

    While it seems to work, I have no idea whether this is good practice or if it will cause a bucket of problems.

     

     

    Just to recap on the basic question:

    I have multiple inserts [account table, application table, customer table etc], and want to only write to the database if all inserts were successful. Tried using ROLLBACK, but was getting the error in the first post. I have since read, that you can't use ROLLBACK on multiple mssql_query's, as it can only hold one in memory ?

     

    Any help or guidance would be appreciated, thanks.

  18. Hi

     

    I'm trying to use transactions, but am coming across the following error, which I can't sort out:

     

    "The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION".

     

    The code is as follows [excerpt] :

     

    mssql_query("BEGIN TRAN");

     

    foreach($value)

    {

      $result = mssql_query($value);

      if(!$result)

      {

          mssql_query("ROLLBACK TRAN");

          exit;

      }

    }

     

    mssql_query("COMMIT TRAN");

     

     

    The $value is one of five INSERTS, which all insert fine. If I come across an error in the insert, for example "Conversion failed when converting the varchar to data type int", I would expect ROLLBACK to be called, and nothing be written to the database, but I'm constantly getting the error above.

     

    ANY IDEAS ?

     

    Thanks for reading.

     

    Paul

     

  19. Hi

     

    I'm trying to use transactions, but am coming across the following error, which I can't sort out:

     

    "The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION".

     

    The code is as follows [excerpt] :

     

    mssql_query("BEGIN TRAN");

     

    foreach($value)

    {

      $result = mssql_query($value);

      if(!$result)

      {

          mssql_query("ROLLBACK TRAN");

          exit;

      }

    }

     

    mssql_query("COMMIT TRAN");

     

     

    The $value is one of five INSERTS, which all insert fine. If I come across an error in the insert, for example "Conversion failed when converting the varchar to data type int", I would expect ROLLBACK to be called, and nothing be written, but I'm getting the error above.

     

    ANY IDEAS ?

     

    Thanks for reading.

     

    Paul

     

  20. Hi All

     

    I'm trying to find out if its possible to take PHP form data, update the fields on an existing editable PDF with the data [already has dynamic fields] and then email the resulting PDF, pre-populated.

     

    I can already take the form data and then open a pre-populated PDF in a browser window for printing, but can I edit the PDF server-side [without it opening on the client], and then attach to an email and send?

     

    The scenario is a PHP form [name,address etc], which the customer fills in, and when they submit the form it needs to email to populated PDF to the customer.

     

    Any direction welcomed!

     

    Thanks

  21. Hi Tom

    Er, to be honest, I don't know!  :-[

    When I read the tutorial you pointed me to, it seemed to be about creating the PDF from scratch - setting fonts, positioning of logo's etc - whereas I already have the PDF fully designed (with InDesign) and then with Acrobat Pro, I've added some text boxes, checkboxes etc, and just need to post the HTML form variables into the PDF.

    The first version of my form worked fine. It filled the PDF with the info, but then opened it into a browser window. The reason I thought I needed to go down the FDF route, was so I could take the HTML form data, fill the PDF with it, and then email it to the client, all without them seeing it.

    When I managed (thanks!) to get an FDF that I could double click and open, I thought I was there.

    Maybe I've gone down the wrong route.

    Don't you just love noobs ...  :-\ !!

    Thanks

    P
×
×
  • 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.