Jump to content

Archived

This topic is now archived and is closed to further replies.

xcguyxc

PERL TO PHP

Recommended Posts

Hey guys! I just need some minor help converting what i was doing in PERL to PHP.

***NOTE: The perl was setup as a db read not a MS SQL i have already taken care of this. We

just Upgraded.

THE UNION ALL PART AND THE DATAHASH ARE WERE I AM LOST!!!!


***** PERL CODE ****
[code]
#!/perl/bin/perl.exe

use Win32::ODBC;
print "Content-type:text/html\n\n";

read(STDIN, $line, $ENV{'CONTENT_LENGTH'});

$anyorder="no";
$anyship="no";

@values = split(/&/, $line);
foreach $i (@values) {
($name, $value) = split(/=/, $i);
$value =~ tr/+/ /;
$value  =~ tr/[a-z]/[A-Z]/;

$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
  }
print "<html><head><title>Database</title></head>";
print "<body>\n";
print "<h2>These are the results</h2>\n";

$DSN="AccountMate";
if (!($db=new Win32::ODBC($DSN))) {
print "ERROR CONNECTING";
}
$po=$FORM{'P.O.'};

$db->Sql("SELECT * FROM dbo.soship where dbo.soship.ccustno = '" . $FORM{'P.O.'} . "' UNION

ALL SELECT * FROM Soshiph where ccustno = '" . $FORM{'P.O.'} . "'");

while ($db->FetchRow()){
my(%data) = $db->DataHash();

$ship=$data{'dship'};
$pon=$data{'cshipno'};

if (($ship > 2005) && ($pon > 1000074112)){

print "<b>Customer No. = </b> $data{ccustno}<br>
<b>Sales Order # =</b> $data{'csono'}<br>
<b>Purchase Order # =</b> $data{'cpono'}<br>
<b>Company = </b> $data{'cscompany'}<br>
<b>Zip = </b> $data{'cszip'}<br>
<b>Ship Date =</b> $data{'dship'}<p>";}

if ($data{'csono'}=~m/\d/)
{$anyorder="yes";}

if ($data{'dship'}=~m/\d/)
{$anyship="yes";}

}

if ($anyorder eq "yes")
{
print"<p><font color='#0000FF'>Please check your PO's </font></p>";
}
else
{print "<p><font color='#FF0000'>If you dont see your PO please check back in 24

hours.</font></p>";}

if ($anyship eq "yes")
{
print"<p><font color='#FF0000'>Your order has  shipped</font></p>";
}
else
{print "<p><font color='#FF0000'>Your order has not yet shipped</font></p>";}

$db->Close();
print "</body></html>\n";

[/code]





I need to try to get it to work the same as the perl would on UNION ALL and the PRINT

DATA....

Share this post


Link to post
Share on other sites

×

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.