0

Am getting: Parse error: syntax error, unexpected T_DNUMBER

$post_xml = "<?xml version="1.0" encoding="utf-8"?><PesapalDirectOrderInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Amount="".$order_total."" Description="".$transaction_details."" Code="".$code."" Type="".$type."" PaymentMethod="".$payment_method."" Reference="".$reference."" FirstName="".$first_name."" LastName="".$last_name."" Email="".$email."" PhoneNumber="".$phonenumber."" UserName="".$username."" xmlns="http://www.pesapal.com" />";

$post_xml = htmlentities($post_xml);

If I use single quotes the error dissappears but it does not function the way i would like it to.

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by mosesmn
0

How about posting the code within code tags the next time to make it easier to understand.

You have double quotes embedded in your string. How is the poor PHP interpreter supposed to make sense of this since you can't nest strings within strings? You can change the embedded quotes to single quotes as long as there are no variables between the single quotes. The more general purpose solution is to escape all of the nested quotes so they will not be treated as the end of the whole string. Thus (as an example):

$post_xml = "... version=\"1.0\" encoding=\"utf-8\" ... ";

will work. This may not be your only problem but it will fix the problem with the quotes.

Edited by chrishea: n/a

0
$post_xml = '<?xml version="1.0" encoding="utf-8"?><PesapalDirectOrderInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Amount="'.$order_total.'" Description="'.$transaction_details.'" Code="'.$code.'...

etc

works
or you can backslash double quotes as chris states. The backslash has the advantage that you don't need to concatenate the variables:

$post_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><PesapalDirectOrderInfo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Amount=\"$order_total\" Description=\"$transaction_details\" Code=\"$code\"...
0

Thanks alot guys, The script finally worked through your help, I will be glad to help where I can

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.