Jump to content

PERL TO PHP


xcguyxc

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....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.