Slice's Profile User Rating: -----

Reputation: 247 Stalwart
Active Members
Active Posts:
737 (0.29 per day)
24-November 08
Profile Views:
Last Active:
User is offline Nov 20 2015 07:58 AM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Who Cares
Dream Kudos:

Latest Visitors

Icon   Slice has not set their status

Posts I've Made

  1. In Topic: Another Linux Topic?!

    Posted 11 Nov 2015

    It's a matter of taste. You won't know if you like it until you try it. The method of trying it is pretty much irrelevant.

    Personally I prefer most linux flavours over Windows.

    More importantly, learning something new, no matter what it is, will always give you a little more overall knowledge; which will always make you a more valuable employee to any potential employers.

    And it's free.. absoloutley no financial hinderance by trying it out. That's not a benifit that comes along very often.
  2. In Topic: Inscriptions for the future..

    Posted 1 Sep 2015

    Buried below  | 
    -1.929162     |
    -63.818492    |
  3. In Topic: Signature of the Month (August 2015)

    Posted 18 Aug 2015

    I can't believe I missed the Marvel Super Villains theme. Absoloutley devestated.

    At least I've got 10 days to dust off the ol' photoshop and attempt this one.
  4. In Topic: Fgets EOF on Linux vs Windows

    Posted 12 Apr 2015

    Usually when running import scripts like this, I avoid the browser all-together. If you have access to the command line of the server, just run "php script.php". That way you get a realtime update where you script is up to in the process. Beats the hell out of looking at a white screen that's just loading.

    Regarding your code, as CTphpnwb said, you should remove the mysql_ functions. They are depreciated and will only cause you more trouble down the line.

    You could also make better use of fgetcsv for importing csv files. Here's a quick example (not debugged, so take it as an example only) for both PDO and fgetcsv. Using prepared statements on a loop like this should also increase the speed of the script, as well as it's security.

    Line 1 is only if you want to run it from command line.

    set_time_limit(0); // if it's a large csv file
    echo "running script.php..\n"; // good output tracking for script progress in terminal
    $file = './file.csv';
    $dsn = "mysql:host=localhost;dbname=test";
        $pdo = new PDO($dsn, 'user', 'password');
    }catch(PDOException $e){
        echo "error creating pdo object: " . $e->getMessage() . "\n";
    /* create the prepared statement */
    $query = "INSERT INTO table (col1, col2, col3) VALUES (:col1, :col2, :col3)";
    $dbh = $pdo->prepare($query);
    if (($handle = fopen($file, 'r')) !== FALSE) {
        $row = 0; // i usually count rows so i can echo out how far i'm up to in the script
        echo "file opened and starting import..\n"; // echo out current stage in script
        while (($data = fgetcsv($handle, 1500, ';')) !== FALSE) {
            $array = [];
            /* add data to 'array', to be inserted into your database - $data[0] == col A on csv
             * This is where you are "binding" the data to the placeholders in the above query. 
            $array = [
               'col1' => $data[0],
               'col2' => $data[1],
               'col3' => $data[2]
                try {
                    /* insert row to database */
                    $result = $dbh->execute($array);
                }catch(PDOException $e){
                    echo "row " . $row . " FAILED: " . $e->getMessage() . "\n";
                echo "Successfully imported row " . $row . "\r";
            // inc the row
        echo "\n \n upload complete \n"; // let us know script is finished.

    Again, this is just an example code. If you are running it from terminal, the \n will produce a line break and \r will replace the current line.
  5. In Topic: Watching people code..

    Posted 9 Apr 2015

    I like learning from narrated coding videos, but I'm really picky when it comes to the narrator. If their voice is annoying, or they sound not at all interested, I get bored and just turn it off.

    Got linked to earlier today, before I saw this topic, and one of the live streams was just someone coding whilst playing music. No idea what he was doing or why.

My Information

Member Title:
sudo pacman -S moneyz
26 years old
November 6, 1989
United Kingdom
web design and development

Contact Information

Click here to e-mail me


Showing 50 random friends of 7


Page 1 of 1
  1. Photo

    Slice Icon

    30 Jul 2012 - 09:45
    Do I need to collect my cash reward in person? ;)
  2. Photo

    modi123_1 Icon

    30 Jul 2012 - 09:09
    Oh.. someone got a new award!
Page 1 of 1