Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
239 views
in Q2A Core by

<?php

error_reporting(E_ALL);

ini_set("display_errors", 1);

include 'qa-include/qa-db-users.php';

// Set path to CSV file
$csvFile = 'users1.csv';

$csv = readCSV($csvFile);
echo '<pre>';
print_r($csv);
echo '</pre>';

foreach ($csv as $data) {
    qa_db_user_create($data[2], $data[3], $data[1], 0, '1320615024');
}

function readCSV($csvFile){
    $file_handle = fopen($csvFile, 'r');
    while (!feof($file_handle) ) {
        $line_of_text[] = fgetcsv($file_handle, 1024);
    }
    fclose($file_handle);
    return $line_of_text;
}

 

?>

I used like this on root directory but it redirects me to my homepage. Where I can use this exactly.

related to an answer for: Add users via php script - explain please!

1 Answer

+1 vote
by

Make sure to include the base file before doing anything with q2a from an outside script .

require_once /path/to/q2a/qa-include/qa-base.php 

This article explains it well .

 

...