I'm using PHP to generate an XML file, from the SQL database, but it's not displaying all the data. It cuts if off and only displays about 1/3 of it (cuts off after 3998 characters). Do I need to adjust my code, or does the php.ini file need adjusted somehow maybe? It's on a windows server though, and I don't see a php.ini file available to me anywhere...

MY CODE:

<?php

include('admin/functions.php');

$ConnString="DRIVER={SQL Server};SERVER=xxxxxx;DATABASE=xxxxxx";

$DB_User="xxxxxx";

$DB_Passwd="xxxxxxx";

$QueryString="SELECT id, Bio FROM Biography";

$Connect = odbc_connect( $ConnString, $DB_User, $DB_Passwd );

$Result = odbc_exec( $Connect, $QueryString );

$nl = "\r\n";

echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" . $nl;

echo "<ROOT>" . $nl;

while($r = odbc_fetch_array( $Result ) )

{

echo '<news id="' . $r['id'] . '">' . $nl;

echo '<body><![CDATA[' . stripslashes2($r['Bio']) . ']]></body>' . $nl;

echo '</news>' . $nl;

}

echo "</ROOT>" . $nl;

odbc_free_result( $Result );

odbc_close( $Connect );

?>

    add this to the top of your page:

    ini_set('error_reporting', E_ALL | E_STRICT);
    ini_set('display_errors', 'On');

    im willing to bet you are reaching the max_execution time limit

    See: set_time_limit

      Thanks for replying. I added that, but it didn't change anything or display any kind of error.

      <?php
      ini_set('error_reporting', E_ALL | E_STRICT);
      ini_set('display_errors', 'On');
      include('admin/functions.php');

      $ConnString="DRIVER={SQL Server};SERVER=xxxxxx;DATABASE=xxxxxx";
      $DB_User="xxxxxx";
      $DB_Passwd="xxxxxxx";
      $QueryString="SELECT id, Bio FROM Biography";
      $Connect = odbc_connect( $ConnString, $DB_User, $DB_Passwd );
      $Result = odbc_exec( $Connect, $QueryString );

      $nl = "\r\n";

      echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" . $nl;
      echo "<ROOT>" . $nl;

      while($r = odbc_fetch_array( $Result ) )
      {

      echo '<news id="' . $r['id'] . '">' . $nl;
      echo '<body><![CDATA[' . stripslashes2($r['Bio']) . ']]></body>' . $nl;
      echo '</news>' . $nl;
      }

      echo "</ROOT>" . $nl;

      odbc_free_result( $Result );
      odbc_close( $Connect );
      ?>

        Also, it only takes about a second or two for it to generate the XML file... It's pretty quick, and isn't hanging for 30 seconds or anything like that.

          scrupul0us;10881826 wrote:

          add this to the top of your page:

          ini_set('error_reporting', E_ALL | E_STRICT);
          ini_set('display_errors', 'On');

          im willing to bet you are reaching the max_execution time limit

          See: set_time_limit

          I replied to this earlier, but my post never showed up... I tried this and nothing changed. No errors showed up...just the same XML with the body cut short. I added these two lines just above my "include"...

            do you have the page on the interwebs so i can take a look at it?

              scrupul0us;10881864 wrote:

              do you have the page on the interwebs so i can take a look at it?

              You can see it in action HERE

                so its cutting off here:

                He had buddies like Jake Argo as his cre]]></body>

                is there more stored in the database?

                  scrupul0us;10881869 wrote:

                  so its cutting off here:

                  He had buddies like Jake Argo as his cre]]></body>

                  is there more stored in the database?

                  Yes, that's where it's ending. If you view the source you'll see the actual XML format. There is more in the database. When I view the data in the admin area, all the text shows up...just not when the XML file tries to display it.

                    do me a favor and just echo out the contents of $r["Bio"] pre-xml structure...

                      When I echo it before the XML structure, I get an 'undefined error'...because $r is defined inside the section that builds the XML I guess.

                      while($r = odbc_fetch_array( $Result ) )
                      {

                        And if I just put:

                        echo $r['Bio'] . $nl;

                        inside the area that builds the XML, it does the same thing as the current code.

                          well yea... i want to see the output of the variable without being confined to the XML structure...

                          just comment out the xml bits and just echo the variable...

                            Same result with this:

                            <?php
                            ini_set('error_reporting', E_ALL | E_STRICT);
                            ini_set('display_errors', 'On');

                            $ConnString="DRIVER={SQL Server};SERVER=xxxxxx;DATABASE=xxxxxx";
                            $DB_User="xxxxxx";
                            $DB_Passwd="xxxxxx";
                            $QueryString="SELECT Bio FROM Biography";
                            $Connect = odbc_connect( $ConnString, $DB_User, $DB_Passwd );

                            $Result = odbc_exec( $Connect, $QueryString );

                            while($r = odbc_fetch_array( $Result ) )
                            {

                            echo $r['Bio'] ;

                            }

                            odbc_free_result( $Result );
                            odbc_close( $Connect );
                            ?>

                              I emailed my host again, and asked them to check their settings. The first time I checked with them, they said they don't help with development issues, but this time I told them it looks like it has to be an issue with a setting somewhere...since this script is pretty basic now and still isn't working. I agree, it looks like the issue must be related to ODBC somehow.

                              I'll post a reply when I hear back from them again.

                                wow, GREAT! Good job on the search engine. I've been searching for two days and never ran across that article.

                                  resolved aye! freakin sweet dude!

                                  yea, i googled "odbc query limit" and came across that 😉

                                    Write a Reply...