Hi guys,
I'm working towards sending an XML request to a URL using cURL in PHP.
First I just wanted to make sure my request is sending the right data so here is a snippet from my code. I will add the curl statements in later once I know i'm sending the right data.
here is my code so far:
$format = 'Y-m-j G:i:s';
$date = date ( $format );
$d = date ( $format, strtotime ( '-90 days' ) );
$sql = mysql_query("SELECT * FROM recurringPayments WHERE lastpmt <= '$d'");
$num_rows = mysql_num_rows($sql);
echo $num_rows . " results found";
echo "<table style=\"border:1px solid green;\">
<tr bgcolor=\"#bdd73b\">
<th>ID</th>
<th>Company Name</th>
<th>Annual Subscription</th>
<th>Package</th>
<th>Cost</th>
<th>Payer Ref</th>
<th>Payment Ref</th>
<th>Last Payment Date</th>
</tr>";
while ($row = mysql_fetch_array($sql))
{
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['compName'] . "</td>";
echo "<td>" . $row['annualSub'] . "</td>";
echo "<td>" . $row['package'] . "</td>";
echo "<td>" . $row['cost'] . "</td>";
echo "<td>" . $row['payerref'] . "</td>";
echo "<td>" . $row['pmtref'] . "</td>";
echo "<td>" . $row['lastpmt'] . "</td>";
}
echo "</table>";
while ($row = mysql_fetch_array($sql))
{
$xml_data ='<request type="receipt-in" timestamp="20030520151742">'.
'<merchantid>test</merchantid>'.
'<account>internet</account>'.
'<orderid>transaction01</orderid>'.
'<amount currency="EUR">'.$row['cost'].'</amount>'.
'<payerref>'.$row['payerref'].'</payerref>'.
'<paymentmethod>'.$row['pmtref'].'</paymentmethod>'.
'<autosettle flag="1" />'.
'<md5hash />'.
'<sha1hash>c81377ac77b6c0a8ca4152e00cc173d01c3d98eb</sha1hash'.
'</request>';
}
echo $xml_data;
When I try to echo $xml_data, I get the following error message:
Notice: Undefined variable: xml_data in C:\wamp\www\Internal\paymentDue.php on line 63
It was my logic that I would be able to output the XML as I output the table, however I could be (probably am) wrong. Any guidance is appreciated.
Thanks.
PS:
I also just realise while I'm posting this, that if I use the while loop in the current context, $xml_data will be overwritten each time it loops. Any help with this would be great too.