multiple shorten url's issue
<p>i have a code to shorten multiple links but that code ( with an Optional Suffix ) the code is work from the second link only:</p>

<pre><code>$url_to_shorten = $_POST[links];
$ownshuff       = $_POST[shuff];   
$theurls = explode("\n",$url_to_shorten);  
foreach($theurls as $urlmulti){  
shortcreate($urlmulti,$shuffss,$ownshuff);
}
</code></pre>

<p>here is an example :</p>

<p>my links are </p>

<pre><code>http://www.123.com
http://www.1234.com
http://www.1235.com
</code></pre>

<p>and my Suffix is : ( Hello_Man ).</p>

<p>with the above code it prints</p>

<pre><code>http://www.mysite.com/IUo
http://www.mysite.com/kOl-Hello_Man
http://www.mysite.com/Rww-Hello_Man
</code></pre>

<p>and it not print the Suffix for the first link.</p>

<p>the shortcreate function is :</p>

<pre><code>function shortcreate($url_long, $Suffix, $ownshuf){
    global $db;
    $chars = $Suffix;
    while (!shortisUnique($chars)) {
        if ($ownshuf != "") {
            $chars = shortgenerate_chars() . "-" . $ownshuf;
        }
        else {
            $chars = shortgenerate_chars();
        }
    }
    $url = $url_long;
    $url = trim($url);
    $url = mysql_real_escape_string($url);
    if (!shortisThere($url)) {
        $q = "INSERT INTO `shorturls` (url, unique_chars) VALUES ('" . $url . "', '" . $chars . "')";
        //echo $q;
        $r = $db-&gt;query($q);
        if (mysql_affected_rows()):
            $q       = "SELECT * FROM `shorturls` WHERE `url`='" . $url . "'";
            $r       = $db-&gt;query($q);
            $row     = $db-&gt;fetch($r);
            $the_url = SITE_URL . "" . $row[2];

            echo "$the_url\n";

        else:
            $the_url = NULL;
            return false;
        endif;
    }
    else {
        $q       = "SELECT * FROM `shorturls` WHERE `url` = '" . $url . "'";
        $r       = mysql_query($q);
        $row     = mysql_fetch_row($r);
        $the_url = SITE_URL . "" . $row[2];

        echo "$the_url\n";

    }
}
</code></pre>

<p>i need that code to work for all the links. any help</p>

<p>regards</p>
