What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP help? // Never thought I'd ask. =p

PHP help? // Never thought I'd ask. =p
Author: Message:
brian
Senior Member
****

Avatar

Posts: 819
Reputation: 43
– / Male / –
Joined: Sep 2004
O.P. PHP help? // Never thought I'd ask. =p
Anyways, I'm maybe kind of stuck on this crap; what this foreach loops supposed to do is check the DB if $a[2] exists; if it does; then it ignores it, if it doesn't, then it adds it, and it's kind of ignoring them all. :X

code:
if($_REQUEST[act] == 'add')
{
    // check mandatory fields
    if(!$_REQUEST[lBulk]) { echo "No emails imported (No values)."; exit; }

    $tmp = $_REQUEST[lBulk];
    $atmp = split("\r\n", $tmp);

    foreach ($atmp as $asdf) {
        $a = split(",", $asdf);
        $qry = mysql_query("SELECT lEmail FROM ar_lead WHERE lEmail='$a[2]'", $id);
        if(mysql_num_rows($qry)) { $erg = 1; }
        if ($erg == 1) {
                echo "Ignored " . $a[0] . " " . $a[1] . " (" . $a[2] . ")<br>";
        } else {
            $aqry = mysql_query("INSERT INTO ar_lead(lName, lLast, lEmail, lDateEntry, lDateOut, lMOut) VALUES('$a[0]', '$a[1]', '$a[2]', current_date, current_date, '-1')", $id);
            // start mail system
            $ms = new MailSystem($aConfig);

            if($ms->setLead(mysql_insert_id($id)) && $ms->setMsg(0)) {
                $ms->mailLead();
                echo "Imported " . $a[0] . " " . $a[1] . " (" . $a[2] . ") Successfully<br>";
            }
        }
    }
    echo "<br><b>Finished Importing Successfully!</b>";
}
?>
10-07-2005 11:56 PM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: PHP help? // Never thought I'd ask. =p
WOW that code really hurts:|. Here's my version:

code:
<?php
if($_REQUEST['act'] == 'add')
{
   // check mandatory fields
   if(empty($_REQUEST['lBulk'])) {
      echo "No emails imported (No values).";
      exit;
   }
   
   $tmp = $_REQUEST['lBulk'];
   $atmp = split("\r\n", $tmp);
   
   foreach ($atmp as $asdf) {
      $a = split(",", $asdf);
      $qry = mysql_query("SELECT lEmail FROM ar_lead WHERE lEmail='" . $a[2] . "'", $id);
      if(mysql_num_rows($qry) < 1) {
         $erg = true;
      }
      if ($erg) {
         echo "Ignored " . $a[0] . " " . $a[1] . " (" . $a[2] . ")<br>";
      }
      else {
         $aqry = mysql_query("INSERT INTO ar_lead(lName, lLast, lEmail, lDateEntry, lDateOut, lMOut) VALUES('" . $a[0] . "', '" . $a[1] . "', '" . $a[2] . "', current_date, current_date, '-1')", $id);
         // start mail system
         $ms = new MailSystem($aConfig);
         
         if($ms->setLead(mysql_insert_id($id)) && $ms->setMsg(0)) {
            $ms->mailLead();
            echo "Imported " . $a[0] . " " . $a[1] . " (" . $a[2] . ") Successfully<br>";
         }
      }
   }
   echo "<br><b>Finished Importing Successfully!</b>";
}
?>

Change $_REQUEST to either $_GET or $_POST, choose the one that you're using. Don't use $_REQUEST!

This code should work....

This post was edited on 10-08-2005 at 07:26 AM by J-Thread.
10-08-2005 07:26 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On