1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Better way to batch than this?

Discussion in 'PHP' started by lektrikpuke, Nov 24, 2008.

  1. #1
    Hi y'all,

    First, forgive my amateur ways in PHP. Second, I know SQL only by proxy (MySQL). Any way, working on a project for my boss, and didn't realize I didn't have a SQL server (I thought I did because I can do queries via PHP and they work, but I now figure it's because I set up ODBC in XP's Admin - so not a full blown SQL server), so I couldn't get what I wanted done via a command prompt.

    Any way, fell back on PHP (how wonderful it truly is) and decided to write a text file with SQL queries that would be read and run by PHP. Surprise, it works! Figured I'd post it here, though, so you guys could tell me how to make less offensive to an O.S.

    Thank for any help. =)


    if (!$conn)
    {exit("Connection Failed: " . $conn);}

    $content = file('change.txt');
    $numLines = count($content);
    for ($i = 0; $i < $numLines; $i++) {
    $line = trim($content[$i]);

    change.txt contents:
    UPDATE Inventory SET LocalSKU='01234' WHERE LocalSKU='01234-b'
    UPDATE Inventory SET LocalSKU='01235' WHERE LocalSKU='01235-b'
    lektrikpuke, Nov 24, 2008 IP