Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Liquid Web Managed Dedicated Server: RAID 1 SSD with 16GB of RAM minimum! 24/7 On-Site Heroic Support! Industry-Leading SLA!

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Liquid Web Cloud VPS Hosting

8,361 questions

11,615 answers

573 users

How to generate 1 letter URLs and INSERT INTO MySQL with PDO in PHP

1 Answer

0 votes
function generate_urls()
{
    $s = "abcdefghijklmnopqrstuvwxyz";
    $len = strlen($s);

    for ($i = 0; $i < $len; $i++)
    {
        $ws_name = $s[$i].".com";
        write_url($ws_name);
    }    
    for ($i = 0; $i < $len; $i++)
    {
        $ws_name = $s[$i].".net";
        write_url($ws_name);
    }
}
function write_url($url)
{
    global $con;
    try 
    {
        $inserted = $con->prepare("INSERT INTO urls (url) 
        VALUES(:url) ON DUPLICATE KEY UPDATE url = url;");

        $inserted->execute(array(
            "url" => $url
        ));
    }
    catch (PDOException $e) 
    {
        die($e->getMessage()));
    }
}

 




answered Nov 2, 2016 by avibootz
...