POG1 Posted May 27, 2008 Posted May 27, 2008 for the mail send function in my mailbox i want to use the string replace function and for the 2 arrays to select from a database and I'm stuck as for how to do it. This is what i have now. $a=mysql_query("SELECT `from` FROM `replace`"); $from=mysql_fetch_array($a); $b=mysql_query("SELECT `to` FROM `replace`"); $to=mysql_fetch_array($b); $newmail = str_replace($from, $to, $msg); Quote
Spudinski Posted May 31, 2008 Posted May 31, 2008 Re: Need a Tip Using one query is much simplier, try it this way... $sql_txt = 'SELECT `from`, `to` FROM `replace` WHERE `id` = \'' . $id . '\''; $sql = mysql_query($sql_txt); while($results = mysql_fetch_assoc($sql)) { $message = str_replace($results['from'], $results['to'], $message); // .. do whatever .. } But is your end goal to change a text from only one message, or how do you want this script to work? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.