I dont know php but I have playing with a script it was oringinally phpmydirectory
I had someone install a module to be able to upload csv files into the data base this is the script he wrote I needed to make changes because it was written to upload the dadt to on state I need the data to upload to all 50 states I add this if statement
if ( $def_states_allow == "YES" )
{
$state = $_POST["state"];
}
now when I do a upload it shows in the module interface the states but it is not in the database or of cousre on the site itself
if some can help me I would be greatful
below is the full script I delete db password
<?php
include("./defaults.php");
session_start();
$incomingline="$def_admin_header";
// Showing header
include ("header.inc");
?>
<br><table width="70%" border="0" cellpadding="0" cellspacing="0"><tr>
<td width="100%" align=left valign=top>
<center><font face=tahoma size=2>Import CVS FILE INTO MYSQL DB</font><br><br></center><br>
<?php
$category0 = $POST[category][0];
$category1 = $POST[category][1];
$category2 = $_POST[category][2];
//var_dump($category);
$category = $category0.":".$category1.":".$category2;
echo $category;
$db_users="pmd_users";
echo $db_users;
$target_path = "upload/";
$target_path = $target_path.basename( $_FILES['arquivo']['name']);
if(move_uploaded_file($FILES['arquivo']['tmp_name'], $target_path)) {
echo "The file ". basename( $FILES['arquivo']['name']).
" has been uploaded<br><br><br>";
} else{
echo "There was an error uploading the file, please try again!";
return;
}
$fp= fopen ($target_path, "r");
$lidos = 0;
$gravados=0;
while (!feof($fp))
{
$in = fgets($fp, 240);
if ($in)
{
//$total_caracteres += strlen(rtrim($in))+1;
// pula o primeiro " e pega tudo ate o proximo "
$proximo = strpos($in,'"',1);
$companyname = addslashes(substr($in,1,$proximo-1));
echo $companyname."<br>";
$inicio = $proximo+3;
$proximo = strpos($in,'"',$inicio);
$address=addslashes(substr($in,$inicio,$proximo-$inicio));
echo $address."<br>";
$inicio = $proximo+3;
$proximo = strpos($in,'"',$inicio);
$city=addslashes(substr($in,$inicio,$proximo-$inicio));
echo $city."<br>";
$inicio = $proximo+3;
$proximo = strpos($in,'"',$inicio);
$state=substr($in,$inicio,$proximo-$inicio);
echo $state."<br>";
$inicio = $proximo+3;
$proximo = strpos($in,'"',$inicio);
$zip=substr($in,$inicio,$proximo-$inicio);
echo $zip."<br>";
$inicio = $proximo+3;
$proximo = strpos($in,'"',$inicio);
$country=substr($in,$inicio,$proximo-$inicio);
echo $country."<br>";
$inicio = $proximo+3;
$proximo = strpos($in,'"',$inicio);
$telephone=substr($in,$inicio,$proximo-$inicio);
echo $telephone."<br><br><br>";
//gravar
$firmname = $companyname;
$business = substr ( $_POST["business"], 0, $def_descr_size );
$phone = $telephone;
$index_category = 1;
for ($index = 0; $index < count ( $_POST[category] ); $index++)
{
if ($_POST[category][$index] != "")
{
$category_index[$index_category] = $_POST[category][$index];$index_category++;
//echo $category_index[$index_category];/*
// Adding new company to counters
if ((($def_onlypaid == "YES") and ($_POST[listing] != "D")) or (($def_onlypaid != "YES")))
{
$new_cat = explode ("#", $_POST[category][$index]);
if ($new_cat[0] != $prev_cat) $db->query ("UPDATE $db_category SET fcounter = fcounter+1 where selector=$new_cat[0]") or die ("mySQL error!");
if (($new_cat[1] != "") and ($new_cat[1] != "0") and ($new_cat[1] != $prev_subcat))
$db->query ("UPDATE $db_subcategory SET fcounter = fcounter+1 where catsel=$new_cat[0] and catsubsel=$new_cat[1]") or die ("mySQL error!");
if (($new_cat[1] != "") and ($new_cat[1] != "0") and ($new_cat[2] != "") and ($new_cat[2] != "0"))
$db->query ("UPDATE $db_subsubcategory SET fcounter = fcounter+1 where catsel=$new_cat[0] and catsubsel=$new_cat[1] and catsubsubsel=$new_cat[2]") or die ("mySQL error!");
$prev_cat=$new_cat[0];
$prev_subcat=$new_cat[1];
}
}
}
$category = join(":", $category_index);
$ip = $_SERVER["REMOTE_ADDR"];
$date_update = date ( "Y-m-d" );
$date = date ( "Y-m-d" );
$location = "1";
if ( $def_states_allow == "YES" )
{
$state = $_POST["state"];
}
$pass = md5 ( " " );
if ($firmname > " ")
{
$db->query ( "INSERT INTO $db_users (firmstate, flag, category, login, firmname, location, state, city, address, zip, phone, pass, ip, date, date_update) VALUES ('on', 'D', '$category', 'danobron', '$firmname', '$location', '$state', '$city', '$address', '$zip', '$phone', '$pass', '$ip', '$date', '$date_update')") or die (mysql_error());
//$db->query ( "INSERT INTO $db_users (firmstate, flag, comment, category, login, firmname, business, location, state, city, address, zip, phone, fax, mobile, icq, manager, mail, www, pass, prices, images, ip, date, date_upgrade, counter, banner_show, banner_click, price_show, reserved_1, reserved_2, reserved_3) VALUES ("on", '$flag', '$comment', '$category', '$_POST[login]', "$firmname", '$business', '$location', '$state', '$postedcity', "$address", '$zip', '$phone', '$fax', '$mobile', '$icq', '$manager', '$mail', '$www', '$pass', '$products', '$images', '$ip', '$date', '$date_upgrade', 1, 0, 0, 0, '$reserved_1', '$reserved_2', '$reserved_3')" ) or die (mysql_error());
$date = date("Y-m-d");
$time_hour = date("H");
$time_min = date("i");
$time_sec = date("s");
$date_day = date("d");
$date_month = date("m");
$date_year = date("Y");
$idin=mysql_insert_id();
$log="$time_hour:$time_min:$time_sec $date_year/$date_month/$date_day - [$_SESSION[admin_login], $ip] - $def_admin_log_newadded $firmname (id: $idin)";
$db->query ("INSERT INTO $db_log (log) VALUES ('$log')") or die ("mySQL error!");
echo "<br>$def_reg_ok<br><br>";
// fim gravar
$lidos +=1;
$gravados +=1;
}
}
}
echo "<br><br>Records: $lidos";
echo "</table></tr>";
include("footer.inc");
?>