nomanoma Posted August 22, 2009 Share Posted August 22, 2009 hi: i run advertising sites that send email ads to its members. i want to add a code to make a footer ads appear in these emails. footer ads are composed of 2 lines, title and a link. the member chooses the title and places the link and it's saved in my database. i need to show those ads (one in each email randomly). here's the script for sending the email ads: <?php include "../header.php"; include "../config.php"; include "../style.php"; //pick a random number and make sure it is not allready in the database.... do { $random = rand(10000, 1000000); $query = "select * from links where number=".$random; $result = mysql_query ($query) or die ("Query failed"); $numrows = @ mysql_num_rows($result); } while (numrows == 1); //get the next ad to send out.... $query3 = "select * from solos where approved=1 and sent=0 limit 1"; $result3 = mysql_query ($query3) or die ("Query failed"); $numrows2 = @ mysql_num_rows($result3); if ($numrows2 == 0) { echo "<p>No soloads to send.</p>"; exit; } //end if ($numrows == 0) $line3 = mysql_fetch_array($result3); $subject = $line3["subject"]; $adbody = $line3["adbody"]; $id = $line3["id"]; //update the links table with the new random number. $query2 = "insert into links set number=".$random.", adid=".$id; $result2 = mysql_query ($query2) or die ("Query failed"); //set the 'sent' in the database to 1 $query5 = "update solos set sent=1 where id=".$id; $result5 = mysql_query ($query5) or die ("Query failed"); //set the 'datesent' $query6 = "update solos set datesent='".time()."' where id=".$id; $result6 = mysql_query ($query6) or die ("Query failed 6"); $query1 = "SELECT * FROM pages WHERE name='Solo footer ad'"; $result1 = mysql_query ($query1); $line1 = mysql_fetch_array($result1); $htmlcode = $line1["htmlcode"]; if($htmlcode) $htmlcode = "<br>$htmlcode<br><br>"; //get all members details.... $query4 = "select * from members where status=1 and verified=1 and vacation=0"; $result4 = mysql_query ($query4) or die ("Query failed"); while ($line4 = mysql_fetch_array($result4)) { $email = $line4["subscribed_email"]; $memtypeq = $line4["memtype"]; $useridq = $line4["userid"]; $nameq = $line4["name"]; $passwordq = $line4["pword"]; //now we've got all we need, so blast the ad out! $Subject = "(Solo) ".$subject; $Message = $adbody; $Message .= "<br><br>--------------------------------------------------------------<br><br>"; if ($memtypeq == "JV Member") { $Message .= "Click the link to receive ".$jvclickearn." credits<br><br>"; } elseif($memtypeq=="SUPER JV") { $Message .= "Click the link to receive ".$superjvclickearn." credits<br><br>"; } else { $Message .= "Click the link to receive ".$proclickearn." credits<br><br>"; } $Message .= "<br><br>"; $Message .= "<br><br>"; $Message .= "<a href=\"".$domain."/clicks.php?userid=".$useridq."&seed=".$random."&id=".$id."\">".$domain."/clicks.php?userid=".$useridq."&seed=".$random."&id=".$id."</a>"; $Message .= ".<br><br>"; $Message .= "--------------------------------------------------------------<br>$htmlcode<br>"; $Message .= "This is a solo ad advertisement from a member of ".$sitename.". You are receiving this because you are a member of '$sitename'.<br>"; $Message .= "You can opt out of receiving emails only by deleting your account, click here to delete your account.<br><br><a href=\"$domain/delete.php?userid=$useridq&code=".md5($passwordq)."\">$domain/delete.php?userid=$useridq&code=".md5($passwordq)."</a>.<br><br>"; $Message .= "$adminname, $sitename, $adminaddress<br>"; $headers = "From: $sitename<$adminemail>\n"; $headers .= "Reply-To: <$adminemail>\n"; $headers .= "X-Sender: <$adminemail>\n"; $headers .= "X-Mailer: PHP4\n"; $headers .= "X-Priority: 3\n"; $headers .= "Return-Path: <$adminemail>\nContent-type: text/html; charset=iso-8859-1\n"; $nameq = trim($nameq); $firstnameq = substr($nameq , 0, strpos($nameq, " ")); $Message = str_replace("~userid~",$useridq,$Message); $Message = str_replace("~fname~",$firstnameq,$Message); $Subject = str_replace("~userid~",$useridq,$Subject); $Subject = str_replace("~fname~",$firstnameq,$Subject); @mail($email, $Subject, wordwrap(stripslashes($Message)),$headers, "-f$adminemail"); $counter=$counter+1; } // end while ($line4 = mysql_fetch_array($result)) echo "<p><b><center>email successfully posted to ".$counter." members.</p></b></center>"; mysql_close($dblink); include "../footer.php"; ?> i want to insert the new code inside that script but all i get is errors. here's what i tried: $navquery = "SELECT * FROM footerads WHERE added=1 AND approved=1 ORDER BY rand()"; $navresult = mysql_query ($navquery) or die ("Query failed"); while ($line = mysql_fetch_array($navresult)) { $id = $line["id"]; $subject = $line["subject"]; $adbody = $line["adbody"]; $url = $line["url"]; if($id) $id = "<br>$id<br><br>"; if($url) $url = "<br>$url<br><br>"; if($subject) $subject = "<br>$subject<br><br>"; if($adbody) $adbody = "<br>$adbody<br><br>"; and in the end of the script where the execution is: $Message .= "Member Footer ads. Buy One Now<br><br>"; $Message .= "<br>$id<br><br>"; $Message .= "<br>$subject<br><br>"; $Message .= "<br>$adbody<br><br>"; $Message .= "<br>$url<br><br>"; $Message .= "--------------------------------------------------------------"; i appreciate your help. thank you Link to comment https://forums.phpfreaks.com/topic/171417-solved-need-to-place-new-code-in-a-script-written-by-someone-else/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.