Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = 'root';//database user variable
- $password = "MontanaNet4**";//database user password variable
- //load sm list file:
- $array = array(); // this is the array for the data from siteList.txt will be stored.
- $handle = fopen("nodeList.txt", "r") or die("epic fail");
- while(($row = fgetcsv($handle, 1000, ",")) !== FALSE) {
- $array[$row[0]] = $row[0];
- }
- fclose($handle);
- //display ammount of sites loaded in the array
- echo "there is ". count($array) . " nodes loaded" . "<br>";
- sort($array);
- foreach($array as $key => $NodeName){
- try {
- $conn = new PDO("mysql:host=$servername;dbname=adatabase", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $sql = "INSERT INTO `node`(,`NodeName`) VALUES (, :NodeName);";
- //INSERT INTO `nodecounts`(`NodeID`,`aCount`,`DateLogged`) VALUES (:NodeId, :aCount, :DateLogged);
- //";
- // prepare sql and bind parameters
- $stmt = $conn->prepare($sql);
- //$stmt->bindParam(':ID', $id);
- $stmt->bindParam(':NodeName', $NodeName);
- //$stmt->bindParam(':NodeID', $NodeID);
- //$stmt->bindParam(':aCount', $aCount);
- //$stmt->bindParam(':DateLogged', $DateLogged);
- $stmt->execute();
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- }//end foreach
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement