php-general Digest 28 Sep 2007 06:31:05 -0000 Issue 5042

Topics (messages 262527 through 262549):

Re: counting with leading zeros
        262527 by: tedd
        262546 by: brian

Re: languages and PHP
        262528 by: Per Jessen
        262531 by: Colin Guthrie
        262536 by: Edward Vermillion
        262537 by: Per Jessen
        262538 by: Per Jessen
        262539 by: mike
        262540 by: Edward Vermillion
        262541 by: Per Jessen

Re: problems with donwload
        262529 by: Jim Lucas

Re: simple product selection guide
        262530 by: tedd

Re: PDOStatement execute memory issue?
        262532 by: Carlton Whitehead
        262535 by: Carlton Whitehead

Conditional jump menu
        262533 by: Steve Marquez
        262534 by: Jay Blanchard

want to learn about zend
        262542 by: Gonzalo PHPFan
        262544 by: Tijnema

Curl Timeout causing Firefox to Download PHP File ?!?
        262543 by: Rahul Sitaram Johari

SimpleXMLElement is not Simple
        262545 by: Jeffery Fernandez
        262547 by: Nathan Nobbe
        262548 by: Jeffery Fernandez

trigger_error() problems
        262549 by: Alexander A Miroch

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
At 10:39 PM -0400 9/26/07, brian wrote:
Now you're obviously just trying to be a dickhead.

While someone is, it's not Rob.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 3:58 PM -0400 9/26/07, brian wrote:

Well, this is almost precisely the same thing i have, save for using POSIX character classes, str_pad instead of sprintf(), and incrementing elsewhere. What i was really wondering is if there was
 a *much simpler* way to do this, not just re-arranging things.

Rob just gave you code that works better than what you did and you're
 bitching about it?

Look, none of us are on your payroll so appreciate what you're given.

My advice, says thanks and if the code doesn't meet your expectations
 then learn how to better phrase your question next time.

tedd


I wasn't bitching! And i *thought* that my numerous attempts at
explaining such would have been enough. Obviously not, but wtf can you
do with people who seem to want only to stir up shit?

Jim Lucas wrote:
Well, I didn't want to get into the middle of this cat fight, but now
 that the talks have completely gotten off topic.  I will
interject...


Perfect timing, then.

Here is a function that is a bit simpler then either of yours.

Now, if you plan to delete any images in the list, this will not work.

There's a daemon that locks the dir, zips up the contents, moves it
elsewhere, then removes everything at once.

<?php

function getNextImage($path, $prefix) { $filelist = glob("${path}${prefix}*") or return '01'; return str_pad(((int)count($filelist)+1), 2, '0', STR_PAD_LEFT); }

?>

Sweet! Thanks much!

brian

--- End Message ---
--- Begin Message ---
David Christopher Zentgraf wrote:

> Your biggest problem will be if you accept any kind of user input
> which could be in any kind of language.
> Depending on your server configuration you'll probably have some
> serious cleaning and filtering to do.
> I often have to employ this line for example:
> foreach (array_keys($_POST) as $key) $clean[$key] =
> mb_convert_encoding($_POST[$key], "UTF-8");
> 
> Trying to make sure that you'll receive UTF-8 helps as well:
> <form action="form.php" method="post" enctype="multipart/form-data"
> accept-charset="utf-8">

I work almost exclusively in UTF-8 (language irrelevant), but I've never
had to do any of the above.  The mb_convert_encoding() from UTF-8 to
UTF-8 doesn't seem to make much sense? 


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
Per Jessen wrote:
> David Christopher Zentgraf wrote:
> 
>> Your biggest problem will be if you accept any kind of user input
>> which could be in any kind of language.
>> Depending on your server configuration you'll probably have some
>> serious cleaning and filtering to do.
>> I often have to employ this line for example:
>> foreach (array_keys($_POST) as $key) $clean[$key] =
>> mb_convert_encoding($_POST[$key], "UTF-8");
>>
>> Trying to make sure that you'll receive UTF-8 helps as well:
>> <form action="form.php" method="post" enctype="multipart/form-data"
>> accept-charset="utf-8">
> 
> I work almost exclusively in UTF-8 (language irrelevant), but I've never
> had to do any of the above.  The mb_convert_encoding() from UTF-8 to
> UTF-8 doesn't seem to make much sense? 

I agree. Provided you HTML is dished out with UTF-8 in the doctype
definiton etc. then all forms are automatically sent in UTF-8....

Also for multilingual content (labels etc.) in PHP have a look at the
gettext extension. This will let you code in your default language with
a minimal wrapper and translate to other languages with catalog files.

Be careful about breaking strings tho' as the xgettext crawler file will
not be able to extract strings properly. Also do not use variable
substituion but rather use printf/sprintf e.g.:
  $var = sprintf(_('Here is %d example of a translatable string.'), 1);

That way the string you translate is nice and standard.(here _() is the
name of the gettext function which is quite common).

You may leave this up to your templating engine (e.g. no labels in
code), so it may not matter.

Also if you are writing modular code, ensure you think about the gettext
domains first and you'll probably want to pass the domain in with
*every* string in your system to ensure it's modular design (e.g. each
module has it's own gettext domain). If you want a good example of
modular gettext usage, I'd recommend looking at the source of gallery2.

HTH.

Col

--- End Message ---
--- Begin Message ---

On Sep 27, 2007, at 10:09 AM, Colin Guthrie wrote:

Per Jessen wrote:
David Christopher Zentgraf wrote:

Your biggest problem will be if you accept any kind of user input
which could be in any kind of language.
Depending on your server configuration you'll probably have some
serious cleaning and filtering to do.
I often have to employ this line for example:
foreach (array_keys($_POST) as $key) $clean[$key] =
mb_convert_encoding($_POST[$key], "UTF-8");

Trying to make sure that you'll receive UTF-8 helps as well:
<form action="form.php" method="post" enctype="multipart/form-data"
accept-charset="utf-8">

I work almost exclusively in UTF-8 (language irrelevant), but I've never
had to do any of the above.  The mb_convert_encoding() from UTF-8 to
UTF-8 doesn't seem to make much sense?

I agree. Provided you HTML is dished out with UTF-8 in the doctype
definiton etc. then all forms are automatically sent in UTF-8....


But what happens if you get data that's *not* UTF-8? Just because your html/form is set to UTF-8 doesn't mean that all your incoming data will be UTF-8.

Ed

--- End Message ---
--- Begin Message ---
Colin Guthrie wrote:

> Per Jessen wrote:
>> I work almost exclusively in UTF-8 (language irrelevant), but I've
>> never had to do any of the above.  The mb_convert_encoding()
>> fromUTF-8 to UTF-8 doesn't seem to make much sense?
> 
> I agree. Provided you HTML is dished out with UTF-8 in the doctype
> definiton etc. then all forms are automatically sent in UTF-8....

Quite so.

> Also for multilingual content (labels etc.) in PHP have a look at the
> gettext extension. This will let you code in your default language
> with a minimal wrapper and translate to other languages with catalog
> files.

I haven't done much with gettext yet - I use apache language content
negotiation, separate source-files per language, and try hard to keep
my PHP code language neutral.


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
Edward Vermillion wrote:

> But what happens if you get data that's *not* UTF-8? Just because
> your html/form is set to UTF-8 doesn't mean that all your incoming
> data will be UTF-8.

Yes it does. If your HTML page was sent in UTF-8, any request
originating from that page will also be in UTF8. 


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
On 9/27/07, Edward Vermillion <[EMAIL PROTECTED]> wrote:

> But what happens if you get data that's *not* UTF-8? Just because
> your html/form is set to UTF-8 doesn't mean that all your incoming
> data will be UTF-8.

just my experience, but as long as it has the meta tag w/ utf-8 in it,
the browser sends (and receives) utf-8. i can store the strings in
mysql without modification or character set conversion, it works like
a charm.

the only thing that might need help then is doing string modifications
like urlencoding, or replacement on the utf-8 characters... i haven't
had to do that yet, but otherwise the end-to-end utf-8 solution has
worked like a charm for me.

but yes, it does require browsers+utf8, running it out of that context
may or may not work depending on what you're trying to do with the
data..

--- End Message ---
--- Begin Message ---

On Sep 27, 2007, at 1:49 PM, Per Jessen wrote:

Edward Vermillion wrote:

But what happens if you get data that's *not* UTF-8? Just because
your html/form is set to UTF-8 doesn't mean that all your incoming
data will be UTF-8.

Yes it does. If your HTML page was sent in UTF-8, any request
originating from that page will also be in UTF8.



... and you can guarantee that any data coming into your site comes from your form?!? WOW!!!

;)

So back to my original question, what breaks if you're *expecting* UTF-8 and you don't *get* UTF-8?

Ed

--- End Message ---
--- Begin Message ---
Edward Vermillion wrote:

> ... and you can guarantee that any data coming into your site comes
> from your form?!? WOW!!!
> 
> ;)
> 
> So back to my original question, what breaks if you're *expecting*
> UTF-8 and you don't *get* UTF-8?

As long as my server isn't vulnerable to it, I couldn't care less. I'm
certainly not going to be that defensive and write my code to deal with
such situations.  If someone POSTs or GETs something not in UTF-8 from
outside my site, and I can't deal with it, it's their problem, not
mine. 

And with PHP being the solid platform it is, it wouldn't dream of taking
down my server just because I get KOI8-R when I expected UTF-8 :-)


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
Hulf wrote:
Under the results there are 3 files to download. Some users are getting an uable to read or corrupt message.

http://vps.aztechost.co.uk/~trisco/index.php


and 3 here

http://vps.aztechost.co.uk/~trisco/rankings.php


The upload script is similar


if(isset($_POST['_upload'])  && $_FILES['userfile']['size'] > 0)
{


$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);

if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}


$id= $_POST['id'];
/*$query = "UPDATE results SET title='$title', file_name='$fileName', size='$fileSize', type='$fileType', content='$content', last_updated=CURDATE() WHERE id=$id";*/

$query ="INSERT INTO results (title, content, file_name, size, type, last_updated) VALUES ('$title', '$content', '$fileName', '$fileSize', '$fileType', CURDATE())";

mysql_query($query);
echo mysql_error();

}


and the download....

<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database
include("/home/trisco/public_html/secure/scripts/connect.php");

$id    = $_GET['id'];
$query = "SELECT file_name, type, size, content FROM results WHERE id = '$id'";

$result = mysql_query($query) or die(mysql_error());;
list($file_name, $type, $size, $content) =

here you set a variable called $file_name

mysql_fetch_array($result);

/*echo $file_name;
echo $type;
echo $size;*/


header("Content-Type: $type");
header("Content-Disposition: attachment; filename=$file_name");

here you are using $file_name

header("Content-Length: ".filesize($file));

here you are using $file

Isn't this something that someone pointed out earlier in the week?

from the input script, it looks like you should be using $size instead of 
filename($file)

header("Accept-Ranges: bytes");
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-transfer-encoding: binary");

echo $content;
exit;

}

?>
Thanks,


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--- End Message ---
--- Begin Message ---
At 12:07 PM -0400 9/26/07, David wrote:
This is probably pretty basic but : I'd like to create a page where the end
result is the product(s) listed based on certain criteria selected by the
user, so I would like a drop down menu or other means that they select from
and based on that selection a second list apears and then a third list, and
then from those criteria have the product or products listed....  I have a
php/mysql host.  What would you recomend to develop this.  Thanks.


A lot of work in both php and mysql.

Here's an example:

http://ancientstones.com

It's quite involved.

Good luck, it can be done.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message --- The problem is isolated to PDO ODBC -- old school ODBC works fine. Below are my test cases.

Plain old ODBC:

<?php
// lobtestOdbc.php
$res = odbc_connect('fmarchive_mssql', 'change', 'me');
if (!$res) { die ('failed to connect'); }

$stp = 'SELECT attdata FROM fm_faxin_att WHERE id = 119085913400004 AND attid = 0'; // statement to prepare
$ps = odbc_prepare($res, $stp);
if (!$res) { die ('failed to prepare statement'); }

$execResult = odbc_execute($ps);
echo var_export($execResult, true);

?>

The output from the plain old ODBC test case is: true
(indicating that odbc_execute succeeded, see http://www.php.net/manual/en/function.odbc-execute.php).

Next up, PDO ODBC:

<?php
// lobtestPdoOdbc.php
try
{
   $db = new PDO('odbc:fmarchive_mssql', 'change', 'me');
$stp = 'SELECT attdata FROM fm_faxin_att WHERE id = 119085913400004 AND attid = 0'; // statement to prepare
   $ps = $db->prepare($stp);
   $execResult = $ps->execute();
   var_export($execResult, true);
}
catch (PDOException $e)
{
   die($e->getMessage());
}

?>

When running lobtestPdoOdbc.php, I get the same old error:

*Fatal error*: Out of memory (allocated 262144) (tried to allocate 4294967295 bytes) in *C:\Inetpub\wwwroot\FMarchive\lobtestPdoOdbc.php* on line *9*

I tried removing the try-catch blocks with no change in output (still gets the exact same Fatal Error) -- not like that would be an acceptable solution anyway.

It appears this is a problem with PDO. I'm starting to really get out of my league now. How can I go about fixing this?

Regards,
Carlton Whitehead

Larry Garfield wrote:
On Wednesday 26 September 2007, Carlton Whitehead wrote:

Could this be some bug in the way PHP, PDO, ODBC, and/or MS SQL are
communicating?  Maybe 'image' columns aren't being handled correctly?
I'm fairly certain my code is correct.  I appreciate all of your comments.

Has anyone even tried querying an 'image' type column out of MS SQL 2005
using PDO ODBC?

Regards,
Carlton Whitehead

Try isolating the problem. If you have a literal query through PDO that fails, in isolation, try the same query using the old-skool odbc routines; just a trivial test script. If that works but the same test script converted to minimal PDO fails, you've found a bug. If it fails in both cases, I'd start blaming something else.


--- End Message ---
--- Begin Message ---
Hi Colin,

The MS documentation says the image type can hold up to 2GB: 
http://technet.microsoft.com/en-us/library/ms187993.aspx

It appears someone beat me to filing a bug report about this: 
http://bugs.php.net/bug.php?id=42765

I guess that's that for now until this gets fixed.

Regards,
Carlton Whitehead

----- Original Message -----
From: "Colin Guthrie" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Thursday, September 27, 2007 4:04:53 AM (GMT-0500) America/New_York
Subject: [PHP]  Re: PDOStatement execute memory issue?

Carlton Whitehead wrote:
> Is something causing the memory allocation
> to loop until it reaches this maximum value?

I don't think so as the 4GB value is mentioned in the error message.
Usually when memory is exhausted in a loop it will say "(tried to
allocate 100 bytes)" - e.g. a little amount.

This appears to do it in one chunk.

I wonder if this is trying to allocate memory for the maximum potential
size of your field in the DB? Perhaps read up on PDO/ODBC/MSSQL and how
they treat BLOBs.... (I don't know myself).

Col

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Does anyone know how to create a field based on a menu choice?

When the menu is selected, then another field is created with an associated
number. 

For instance:

Selection = Collie   Field = 1
Selection = Akita    Field = 2

And so on...

Thanks,

--
Steve M.

--- End Message ---
--- Begin Message ---
[snip] Does anyone know how to create a field based on a menu choice?

When the menu is selected, then another field is created with an
associated
number. 

For instance:

Selection = Collie   Field = 1
Selection = Akita    Field = 2
[/snip]

Javascript, DHTML, and AJAX

--- End Message ---
--- Begin Message ---
hello people anyone know a good tutorial to learn the basics of zend, how it
works and how to use?

Regards,
Gonzalo

--- End Message ---
--- Begin Message ---
On 9/27/07, Gonzalo PHPFan <[EMAIL PROTECTED]> wrote:
> hello people anyone know a good tutorial to learn the basics of zend, how it
> works and how to use?
>
> Regards,
> Gonzalo
>

Google: "Zend Basics"
First result: Understanding the Zend Framework, Part 1: The basics
www.ibm.com/developerworks/opensource/library/os-php-zend1

Tijnema


-- 
If this is a mailing list: DO NOT TOP POST! why?:
http://www.caliburn.nl/topposting.html

Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! ->
http://gpcc.tijnema.info

--- End Message ---
--- Begin Message ---
Ave,

I¹m not sure what¹s causing the problem, but I have a feeling that its¹ a
timeout issue.
I have a curl function that retrieves specific data from a remote webpage.
The script works fine on my localhost, but when I upload it to my remote
server, the script tries to execute, but 10 ­ 15 seconds into it, Firefox
gives me an option to download the PHP script. Googling it I found that the
Curl function taking too long might cause a timeout, which Firefox
interprets by giving a Download option for the script. Safari on the other
hand says ³Could not load data from script². Again, same script works on
localhost on both browsers.

I don¹t know if that¹s the real cause or if something is wrong with my
script. Note that latest PHP & Curl are enabled and working on the remote
server, and other PHP pages & curl functions run on that remote server, so
that¹s not an issue.

Here¹s my curl function:

<?php
# Gather cookies in a Jar
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, ³path-to-cookieFileName");
curl_setopt($ch, CURLOPT_URL,"http://www.mywebsite.com";);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
ob_start();      // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean();  // stop preventing output
curl_close ($ch);
unset($ch);

# Login with your Cookie Jar
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "usr=usrname&pwd=password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, path-to-cookieFileName");
curl_setopt($ch, CURLOPT_URL,"http://www.mywebsite.com";);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec ($ch);
curl_close ($ch);

# Get the text in the middle of ...
function get_middle($source, $beginning, $ending, $init_pos) {
    $beginning_pos = strpos($source, $beginning, $init_pos);
    $middle_pos = $beginning_pos + strlen($beginning);
    $ending_pos = strpos($source, $ending, $beginning_pos + 1);
    $middle = substr($source, $middle_pos, $ending_pos - $middle_pos);
    return $middle;
}

# trim result and get what you need ...
$share_ratio = get_middle($result, 'Share ratio', '</tr>', 0);
$share_ratio2 = trim(ereg_replace("[\n\r\t]", "", $share_ratio));
$share_ratio3 = substr($share_ratio2, 25, 5);
echo "Ratio: <STRONG>$share_ratio3</STRONG>";
?>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]

³I morti non sono piu soli ... The dead are no longer lonely²


--- End Message ---
--- Begin Message ---
I am having nightmares with this bit off code.

The following code work perfectly fine:

$soap_request_string = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:ns1="urn:Gateway_Proxy" xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:enc="http://www.w3.org/2003/05/soap-encoding";>
<env:Body>
  <ns1:make_proxy_payment 
env:encodingStyle="http://www.w3.org/2003/05/soap-encoding";>
    <payment_id>61ecc268-1cd0-f468</payment_id>
    <payment_amount>15495</payment_amount>
    
<callback_query_string>&amp;payment_id=61ecc268-1cd0-f468</callback_query_string>
    <transaction_note>Order from Student Library Fees with Payment Id: 
61ecc268-1cd0-f468</transaction_note>
  </ns1:make_proxy_payment>
</env:Body>
</env:Envelope>
XML;

$xml = new SimpleXMLElement($soap_request_string, NULL, false, 
'http://www.w3.org/2003/05/soap-envelope');
print_r($xml);
$ns = $xml->getNamespaces(true);
//print_r($ns);

foreach ($xml->children($ns['env']) as $body)
{
    //printf("%s<br />", $body->getName());
       
        foreach ($body->children($ns['ns1']) as $function)
        {
            printf("function %s()<br />", $function->getName());
           
            foreach ($function->children() as $parameters)
            {
                    printf("%s => \"%s\"<br />", $parameters->getName(), 
$parameters);
            }
        }
}


However when the XML string is coming from the database it does not work. The 
Field and table have a collation of "utf8_unicode_ci"

$soap_request_string = trim(str_replace(array("\n"), '', 
$record['SoapRequestEnvelope']));
$xml = new SimpleXMLElement($soap_request_string, NULL, false, 
'http://www.w3.org/2003/05/soap-envelope');
print_r($xml);


The above code is supposed to print out the following (for me to proceed 
further):

SimpleXMLElement Object
(
    [Body] => SimpleXMLElement Object
        (
        )
)


but only returns:
SimpleXMLElement Object
(
)


The XL string from the database looks exactly like this (after replacing new 
lines):

<?xml version="1.0" encoding="UTF-8"?><env:Envelope 
xmlns:env="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:ns1="urn:Gateway_Proxy" xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:enc="http://www.w3.org/2003/05/soap-encoding";><env:Body><ns1:make_proxy_payment
 
env:encodingStyle="http://www.w3.org/2003/05/soap-encoding";><payment_id>5ce30dcc-7df7-04e8</payment_id><payment_amount>10</payment_amount><callback_query_string>&amp;payment_id=5ce30dcc-7df7-04e8</callback_query_string><transaction_note>Order
 from Student Library Fees with Payment Id: 
5ce30dcc-7df7-04e8</transaction_note></ns1:make_proxy_payment></env:Body></env:Envelope>


I can't figure out whats wrong with the code. Any suggestions?

cheers,
Jeffery
-- 
Internet Vision Technologies
Level 1, 520 Dorset Road
Croydon
Victoria - 3136
Australia

Attachment: pgpcTL62cILkx.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
just curious, what database are you using?

-nathan

On 9/27/07, Jeffery Fernandez <[EMAIL PROTECTED]> wrote:
>
> I am having nightmares with this bit off code.
>
> The following code work perfectly fine:
>
> $soap_request_string = <<<XML
> <?xml version="1.0" encoding="UTF-8"?>
> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope";
> xmlns:ns1="urn:Gateway_Proxy" xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:enc="
> http://www.w3.org/2003/05/soap-encoding";>
> <env:Body>
>   <ns1:make_proxy_payment env:encodingStyle="
> http://www.w3.org/2003/05/soap-encoding";>
>     <payment_id>61ecc268-1cd0-f468</payment_id>
>     <payment_amount>15495</payment_amount>
>
>     
> <callback_query_string>&amp;payment_id=61ecc268-1cd0-f468</callback_query_string>
>     <transaction_note>Order from Student Library Fees with Payment Id:
> 61ecc268-1cd0-f468</transaction_note>
>   </ns1:make_proxy_payment>
> </env:Body>
> </env:Envelope>
> XML;
>
> $xml = new SimpleXMLElement($soap_request_string, NULL, false, '
> http://www.w3.org/2003/05/soap-envelope');
> print_r($xml);
> $ns = $xml->getNamespaces(true);
> //print_r($ns);
>
> foreach ($xml->children($ns['env']) as $body)
> {
>     //printf("%s<br />", $body->getName());
>
>         foreach ($body->children($ns['ns1']) as $function)
>         {
>             printf("function %s()<br />", $function->getName());
>
>             foreach ($function->children() as $parameters)
>             {
>                     printf("%s => \"%s\"<br />", $parameters->getName(),
> $parameters);
>             }
>         }
> }
>
>
> However when the XML string is coming from the database it does not work.
> The Field and table have a collation of "utf8_unicode_ci"
>
> $soap_request_string = trim(str_replace(array("\n"), '',
> $record['SoapRequestEnvelope']));
> $xml = new SimpleXMLElement($soap_request_string, NULL, false, '
> http://www.w3.org/2003/05/soap-envelope');
> print_r($xml);
>
>
> The above code is supposed to print out the following (for me to proceed
> further):
>
> SimpleXMLElement Object
> (
>     [Body] => SimpleXMLElement Object
>         (
>         )
> )
>
>
> but only returns:
> SimpleXMLElement Object
> (
> )
>
>
> The XL string from the database looks exactly like this (after replacing
> new lines):
>
> <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="
> http://www.w3.org/2003/05/soap-envelope"; xmlns:ns1="urn:Gateway_Proxy"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"; xmlns:enc="
> http://www.w3.org/2003/05/soap-encoding";><env:Body><ns1:make_proxy_payment
> env:encodingStyle="http://www.w3.org/2003/05/soap-encoding";><payment_id>5ce30dcc-7df7-04e8</payment_id><payment_amount>10</payment_amount><callback_query_string>&amp;payment_id=5ce30dcc-7df7-04e8</callback_query_string><transaction_note>Order
> from Student Library Fees with Payment Id:
> 5ce30dcc-7df7-04e8</transaction_note></ns1:make_proxy_payment></env:Body></env:Envelope>
>
>
> I can't figure out whats wrong with the code. Any suggestions?
>
> cheers,
> Jeffery
> --
> Internet Vision Technologies
> Level 1, 520 Dorset Road
> Croydon
> Victoria - 3136
> Australia
>
>

--- End Message ---
--- Begin Message ---
On Friday 28 September 2007 11:09, Nathan Nobbe wrote:
> just curious, what database are you using?

I am using MySQL Ver 14.12 Distrib 5.0.22

cheers,
Jeffery
>
> -nathan
>
> On 9/27/07, Jeffery Fernandez <[EMAIL PROTECTED]> wrote:
> > I am having nightmares with this bit off code.
> >
> > The following code work perfectly fine:
> >
> > $soap_request_string = <<<XML
> > <?xml version="1.0" encoding="UTF-8"?>
> > <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope";
> > xmlns:ns1="urn:Gateway_Proxy"
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:enc="
> > http://www.w3.org/2003/05/soap-encoding";>
> > <env:Body>
> >   <ns1:make_proxy_payment env:encodingStyle="
> > http://www.w3.org/2003/05/soap-encoding";>
> >     <payment_id>61ecc268-1cd0-f468</payment_id>
> >     <payment_amount>15495</payment_amount>
> >
> >    
> > <callback_query_string>&amp;payment_id=61ecc268-1cd0-f468</callback_query
> >_string> <transaction_note>Order from Student Library Fees with Payment
> > Id: 61ecc268-1cd0-f468</transaction_note>
> >   </ns1:make_proxy_payment>
> > </env:Body>
> > </env:Envelope>
> > XML;
> >
> > $xml = new SimpleXMLElement($soap_request_string, NULL, false, '
> > http://www.w3.org/2003/05/soap-envelope');
> > print_r($xml);
> > $ns = $xml->getNamespaces(true);
> > //print_r($ns);
> >
> > foreach ($xml->children($ns['env']) as $body)
> > {
> >     //printf("%s<br />", $body->getName());
> >
> >         foreach ($body->children($ns['ns1']) as $function)
> >         {
> >             printf("function %s()<br />", $function->getName());
> >
> >             foreach ($function->children() as $parameters)
> >             {
> >                     printf("%s => \"%s\"<br />", $parameters->getName(),
> > $parameters);
> >             }
> >         }
> > }
> >
> >
> > However when the XML string is coming from the database it does not work.
> > The Field and table have a collation of "utf8_unicode_ci"
> >
> > $soap_request_string = trim(str_replace(array("\n"), '',
> > $record['SoapRequestEnvelope']));
> > $xml = new SimpleXMLElement($soap_request_string, NULL, false, '
> > http://www.w3.org/2003/05/soap-envelope');
> > print_r($xml);
> >
> >
> > The above code is supposed to print out the following (for me to proceed
> > further):
> >
> > SimpleXMLElement Object
> > (
> >     [Body] => SimpleXMLElement Object
> >         (
> >         )
> > )
> >
> >
> > but only returns:
> > SimpleXMLElement Object
> > (
> > )
> >
> >
> > The XL string from the database looks exactly like this (after replacing
> > new lines):
> >
> > <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="
> > http://www.w3.org/2003/05/soap-envelope"; xmlns:ns1="urn:Gateway_Proxy"
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance"; xmlns:enc="
> > http://www.w3.org/2003/05/soap-encoding";><env:Body><ns1:make_proxy_paymen
> >t
> > env:encodingStyle="http://www.w3.org/2003/05/soap-encoding";><payment_id>5
> >ce30dcc-7df7-04e8</payment_id><payment_amount>10</payment_amount><callback
> >_query_string>&amp;payment_id=5ce30dcc-7df7-04e8</callback_query_string><t
> >ransaction_note>Order from Student Library Fees with Payment Id:
> > 5ce30dcc-7df7-04e8</transaction_note></ns1:make_proxy_payment></env:Body>
> ></env:Envelope>
> >
> >
> > I can't figure out whats wrong with the code. Any suggestions?
> >
> > cheers,
> > Jeffery
> > --
> > Internet Vision Technologies
> > Level 1, 520 Dorset Road
> > Croydon
> > Victoria - 3136
> > Australia

-- 
Internet Vision Technologies
Level 1, 520 Dorset Road
Croydon
Victoria - 3136
Australia

Attachment: pgpb5MxfOlSgN.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
Hi,
my php is 5.2.4 compiled in apache1.3.37 as module
I have some trouble with trigger_error function
code
<?
trigger_error ('error',E_USER_ERROR);
?>
I get 500 error status (Internal server error) and a record in my error log.
And this
<?
ob_flush();
trigger_error ('error',E_USER_ERROR);
?>
returns 200 and I have no message in my error log.
is it ok ?

Thanks.

--
Alexander A Miroch

--- End Message ---

Reply via email to