troubleshooting Question

strtok (php tokenizer)

Avatar of prowebinteractive
prowebinteractive asked on
6 Comments1 Solution411 ViewsLast Modified:
from a text area I am entering emails seperating by a line break


etc etc.
the code below is inserting a space at the end of the email how could I stop that ?
what I have so far is:

            //echo "bulk email database entry";
            $token = strtok($_POST['contents'], "\n -");
                echo $token . ";<br />";
                $selectQuery = "SELECT email FROM emailTable WHERE email = '" . $token . "'";
                $result = mysql_query($selectQuery)
                    or die ("Couldn't Insert New Email.");
                          $tokenRows = mysql_num_rows($result);
                echo $tokenRows;
                if($tokenRows == 0)
                     $insertQuery = "INSERT INTO emailTable (name, email)
                        VALUES('ENTERED BY ADMINISTRATOR', '" . $token . "')";
                        $insertResult = mysql_query($insertQuery)
                            or die ("Couldn't Insert New Email.");      

                          $token = strtok("\n -");
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros