ID LIST: http://pastebin.com/LRs0S0xC
[Imagine the spaces being | and no NPC ID: at the top]
Code attempt 2 [2 Attempts, similar code, both failed]
Code:
<?php
include "config.php";
ERROR_REPORTING(E_ALL);
$data = fopen("c:/xampp/htdocs/rs/site/npcid.txt", 'r');
$information = fread($data, filesize("c:/xampp/htdocs/rs/site/npcid.txt"));
$array = explode(" \r\n ", $information);
print_r($array);
$count = count($array);
echo $count;
for($i=0; $i==$count; $i++) {
echo $i;
$data = explode('|', $array[$i]);
mysql_query("INSERT INTO `site_npcids` ( id, npc) VALUES ('{$data[0]}', '{$data[1]}')")
or die('failed somewhere');
}
?>
Attempt 1
Code:
<?php
mysql_pconnect("localhost","root","------");
mysql_select_db("-------");
ERROR_REPORTING(E_ALL);
$data = fopen("c:/xampp/htdocs/rs/site/npcid.txt", 'r');
$information = fread($data, filesize("c:/xampp/htdocs/rs/site/npcid.txt"));
$closeit = fclose($data);
//list($id, $npc) = print_r(explode('|', $information, 2));
print_r(explode('|', $information, 2));
echo "ID: $array[0]<br />"; // foo
echo "NPC: $array[1]<br />"; // *
//$count = round(count($array) / 2);
//echo $count;
//for($i=0; $i==$count; $i=$i+2) {
// mysql_query("INSERT INTO `site_npcids` ( id, npc) VALUES ('{$array[$i]}', '{$array[$i //+ //1]}')") or die('failed somewhere');
//}
?>
Exert of the page result
Array ( [0] => 0|Hans 1|Man 2|Man 3|Man 4|Woman 5|Woman 6|Woman 7|Farmer 8|Thief 9|Guard 10|Schoolgirl 11|Tramp 12|Barbarian 13|Wizard 14|Druid 15|Warrior woman 16|Man 17|Schoolgirl 18|Al-Kharid warrior 19|White Knight 20|Paladin 21|Hero 22|Forester 23|Knight of Ardougne 24|Man 25|Woman 26|Knight of Ardougne 27
Nothing posted to the database, nor formatted correctly since the npcid.txt is formatted ID|NAME
Any assistance?
Bookmarks