Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and work.

aviboots(AT)netvision.net.il

Instant Grammar Checker - Correct all grammar errors and enhance your writing
BlueHost Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

Website Domains Names & Hosting | Domain.com

Instant Grammar Checker - Correct all grammar errors and enhance your writing

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

DreamHost Web Hosting


Liquid Web Cloud VPS Hosting

Disclosure We are a professional Programming & Software Q&A website, that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

13,235 questions

18,020 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
...