Jump to content

emexinc

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

emexinc's Achievements

Member

Member (2/5)

0

Reputation

  1. ...apparently i am overloading something, but no warning is indicating that, i have now added session values to my code and am importing 50 rows at a time, no problems, sort of annoying having to reload the same page (automatically of course) so many times to get my over 1500 rows into my database...nonetheless thank you for your help in resolving this issue...darwin
  2. ...thank you for your response...my page is displaying everything up until the where the php begins the for loops to retrieve and insert information into the database... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="../index.css"> </head> <body style="background: #cccccc url('../images/hatch.gif'); text-align:center; margin:0px; padding: 0px;"> <center> <div style="width:830px; margin:0px; padding-top:15px; background:url('../images/o1.png');"> <!--HEADER--> <div style="width: 750px; height: 55px; padding-top:25px; border:1px solid #000; background:#201d19 url('../images/header.jpg');"> <a style="display:block; float:left; text-align:left; z-index:300; width:550px; height:30px; background:transparent; font-size:32px; padding-left:23px; font-family: Georgia; color: #fff;" href="http://www.distinctivewooddesigns.com">distinctive wood designs inc.</a> </div> <!--CONTENT--> <div class="h">Update <img src="../images/mark.gif" style="position:relative; top:1px; left:40px;"></img> <img src="../images/mark.gif" style="position:relative; top:1px; left:60px;"></img> <img src="../images/mark.gif" style="position:relative; top:1px; left:80px;"></img> </div> <div class="m" style="width:730px; height:auto; padding:10px 0px 10px 20px; z-index:0;"> 1583<br> ...in regards to how i know what it is currently doing, i am 'manually' looking at the database to see what information has been inserted...as well, i have inserted an echo statement for $acount which is correct, 1583...in regards to echo mysql_error(), i do believe it is in there, unless have put it in the wrong spot...thank you for your help...
  3. ...as you mentioned, i am now escaping special characters, as well i have modified some parts to help with filtering and such...as of right now it imports up to 62 rows, which is still quite short of the 1583 that i need...there are no error warnings of any kind being displayed...once again, from clicking on my link to when the half loaded page appears only takes about 15 seconds... ...my current code... <?php set_time_limit (0); $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; error_reporting(E_ALL); ini_set("display_errors", 1); $connection = mysql_connect($db_server, $dbuname, $db_password); mysql_select_db($db_name); $sql = "TRUNCATE TABLE `alldata`"; mysql_query($sql); # file import information $fh = fopen($myFile, 'r'); $data = fread($fh, filesize($myFile)); $fh2 = fopen($myFile2, 'r'); $theData = fread($fh2, filesize($myFile2)); # pages $Chunks = str_replace('"', '', "$data"); $Chunks = explode("\r\n", $data); $acount = count($Chunks); # prices $wordChunks = str_replace('"', '', "$theData"); $wordChunks = explode("\r\n", $theData); $bcount = count($wordChunks); # upper/lower case function filter for items from price file function letter_case($matches) { return strtoupper($matches[1]).strtolower($matches[2].$matches[3]); } # import info for each species - should be replaced with a function call for($i = 0; $i < $acount; $i++){ list($page,$item_number_1,$size,$info,$pricing,$pine,$poplar,$red_oak,$white_oak,$alder,$fir,$hemlock,$maple,$cherry,$hickory,$mahogany,$lyptus,$brazillian_cherry,$beech,$maple_with_leaf,$mdf,$birch,$walnut) = split('[,]', $Chunks[$i]); $species = "pine";$letter = "kp";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "poplar";$letter = "p";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "red_oak";$letter = "o";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "white_oak";$letter = "wo";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "alder";$letter = "a";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "fir";$letter = "f";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "hemlock";$letter = "he";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "maple";$letter = "m";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "cherry";$letter = "c";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "hickory";$letter = "hi";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "mahogany";$letter = "ma";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "lyptus";$letter = "ly";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "brazillian_cherry";$letter = "br";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "beech";$letter = "be";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "maple_with_leaf";$letter = "ml";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "mdf";$letter = "mdf";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "birch";$letter = "bi";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; $species = "walnut";$letter = "w";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++)if(strlen($wordChunks[$s]) > 1){{list($n, $p) = explode(",", $wordChunks[$s]);$n = htmlentities($n, ENT_QUOTES);$p = htmlentities($p, ENT_QUOTES);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){$s = $bcount;${$species} = $p;}}}}; mysql_query("INSERT INTO alldata (page,item_number_1,size,info,pricing,pine,poplar,red_oak,white_oak,alder,fir,hemlock, maple,cherry,hickory,mahogany,lyptus,brazillian_cherry,beech,maple_with_leaf,mdf,birch,walnut) VALUES('$page','$item_number_1', '$size','$info','$pricing','$pine','$poplar','$red_oak','$white_oak','$alder','$fir','$hemlock','$maple','$cherry','$hickory', '$mahogany','$lyptus','$brazillian_cherry','$beech','$maple_with_leaf','$mdf','$birch','$walnut')") or die('Error, query failed: '.mysql_error()); } mysql_query("DELETE FROM alldata LIMIT 1"); fclose($fh); fclose($fh2); echo "Importing all information complete<br>"; $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "<br>This page was created in ".round($totaltime, 2)." seconds"; ?> ...thanks again for your help...darwin
  4. ...if i limit the number of rows to 29 or less, then information from the two files that i have is loaded properly into the mysql table, but anything above that seems to cause the script to stop and the .php file loads up until that point...i don't have a blank page, but when i check my mysql table, it only has 29 rows... ...this is my script... <?php error_reporting(E_ALL); ini_set("display_errors", 1); $connection = mysql_connect($db_server, $dbuname, $db_password); mysql_select_db($db_name); $sql = "TRUNCATE TABLE `alldata`"; mysql_query($sql); $fh = fopen($myFile, 'r'); $data = fread($fh, filesize($myFile)); $fh2 = fopen($myFile2, 'r'); $theData = fread($fh2, filesize($myFile2)); $Chunks = str_replace('"', '', "$data"); $Chunks = explode("\r\n", $data); $acount = count($Chunks); $wordChunks = str_replace('"', '', "$theData"); $wordChunks = explode("\r\n", $theData); $bcount = count($wordChunks); function letter_case($matches) { return strtoupper($matches[1]).strtolower($matches[2].$matches[3]); } for($i = 0; $i < $acount; $i++){ list($page,$item_number_1,$size,$info,$pricing,$pine,$poplar,$red_oak,$white_oak,$alder,$fir,$hemlock,$maple,$cherry,$hickory,$mahogany,$lyptus,$brazillian_cherry,$beech,$maple_with_leaf,$mdf,$birch,$walnut) = split('[,]', $Chunks[$i]); $species = "pine";$letter = "kp";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "poplar";$letter = "p";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "red_oak";$letter = "o";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "white_oak";$letter = "wo";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "alder";$letter = "a";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "fir";$letter = "f";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "hemlock";$letter = "he";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "maple";$letter = "m";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "cherry";$letter = "c";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "hickory";$letter = "hi";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "mahogany";$letter = "ma";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "lyptus";$letter = "ly";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "brazillian_cherry";$letter = "br";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "beech";$letter = "be";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "maple_with_leaf";$letter = "ml";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "mdf";$letter = "mdf";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "birch";$letter = "bi";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; $species = "walnut";$letter = "w";if(${$species} == "y"){for($s = 0; $s < $bcount; $s++){list($n, $p) = split('[,]', $wordChunks[$s]);$check = preg_replace_callback('#([a-z]*)(.*)([a-z])#i', 'letter_case', $n);if($check == $item_number_1.$letter){${$species} = $p;$s == $bcount;}}}; mysql_query("INSERT INTO alldata (page,item_number_1,size,info,pricing,pine,poplar,red_oak,white_oak,alder,fir,hemlock, maple,cherry,hickory,mahogany,lyptus,brazillian_cherry,beech,maple_with_leaf,mdf,birch,walnut) VALUES('$page','$item_number_1', '$size','$info','$pricing','$pine','$poplar','$red_oak','$white_oak','$alder','$fir','$hemlock','$maple','$cherry','$hickory', '$mahogany','$lyptus','$brazillian_cherry','$beech','$maple_with_leaf','$mdf','$birch','$walnut')") or die('Error, query failed: '.mysql_error()); } mysql_query("DELETE FROM alldata LIMIT 1"); fclose($fh); fclose($fh2); echo "Importing all the information is complete.<br>"; ?> ...within my .CSV files, there is nothing there to cause the script to stop...and it's not a matter of dealing with a timeout, it takes no longer than 11 seconds and the half loaded page appears... ...as a side note, i know i should create a function for that one section of repeatedness, but i have yet to get anything working properly for that, anyways that is not my main concern...
  5. ...could your response be any more general?...I would of rather had you ignore my question...and the last time i checked, preg_replace is a php function...thanks a lot ram4nd...
  6. ...I'm trying to split up a string, and if there is any letters before numbers, then those letters need to be capitalized, and if there are any letters after the last number, then those need to be lower cased... ...such as the below... STRING Output m303m M303m 303M 303m m303-1m M303-1m m12x3m M12x3m ...the letters of course will be different all the time, as well as the fact that there may or may not be letters at the start of ending of the string...this is what i have so far, but it's not working with all the test strings... $test = "m303-3m"; preg_match("/^(\w+\d)(\D+)$/i",$test,$m); $a = strtoupper($m[1]); $b = strtolower($m[2]); echo $a.$b; ...thanks for your help...darwin
  7. ...i don't quite understand your explanation...i don't have any double $ in my coding...
  8. ...somebody please kick me in the right direction... function price_insert($species, $letter){ $spe = ${$species}; if($spe == "y"){for($s = 0; $s < $bcount; $s++) {list($n, $p) = split('[,]', $wordChunks[$s]); if($n == $item_number_1.$letter){$spe = $p;$s == $bcount;}}} } price_insert("poplar", "p"); ...I am trying to get the function to end up working as if everything was like it is below... if($poplar == "y"){for($s = 0; $s < $bcount; $s++) {list($n, $p) = split('[,]', $wordChunks[$s]); if($n == $item_number_1."p"){$poplar = $p;$s == $bcount;}}} ...i've looked into creating variables from text, but somehow i'm not getting it to work...thanks again for your help...darwin
  9. ...the code seems to have an issue with this line... if($n == $item_number_1."p"){$poplar = $p;} ...if that line is taken out then everything runs fine, but information from the second file is not compared to information from the first file...
  10. ...actually poplar is the correct spelling for a species of wood...
  11. ...the above statement returns int(1583)
  12. ...i am trying to import a .txt file into a mysql database and at the same time if a condition is met, then have some information changed with information from a second .txt file... ...here is my coding thus far... $fh = fopen($myFile, 'r'); $data = fread($fh, filesize($myFile)); $fh2 = fopen($myFile2, 'r'); $theData = fread($fh2, filesize($myFile2)); $wordChunks = strtolower($wordChunks); $wordChunks = str_replace('"', '', "$wordChunks"); $wordChunks = explode("\r\n", $data); $Chunks = strtolower($Chunks); $Chunks = str_replace('"', '', "$Chunks"); $Chunks = explode("\r\n", $data); for($i = 0; $i < count($Chunks); $i++){ list($page,$item_number_1,$size,$info,$pricing,$pine,$poplar) = split('[,]', $Chunks[$i]); if($poplar == 'y'){ for($s = 0; $s < count($wordChunks); $s++){ list($n, $p) = split('[,]', $wordChunks[$s]); if($n == $item_number_1."p"){$poplar = $p;} } } mysql_query("INSERT INTO database (page,item_number_1,size,info,pricing,pine,poplar) VALUES('$page','$item_number_1', '$size','$info','$pricing','$pine','$poplar')") or die('Error, query failed: '.mysql_error()); } fclose($fh); fclose($fh2); ...thanks for the help...darwin
  13. ...it does not display any errors...i found another post where i link that page to a new one where it then can do an error check (i wish i could explain it better) and the only repeated item that i comes up with is "Undefined Offset: " with various numbers all from the same line of code in my file. list($page,$item_number_1,$size,$info,$pricing,$pine,$poplar,$red_oak,$white_oak,$alder,$fir,$hemlock,$maple,$cherry,$hickory,$mahogany,$lyptus,$brazillian_cherry,$beech,$maple_with_leaf,$mdf,$birch,$walnut) = split('[,]', $Chunks[$i]); ...from splitting this line of code among different lines, it seems the last part is causing this... ) = split('[,]', $Chunks[$i]); ...i don't know where to go from here...thanks for all the help...darwin
  14. ...i've tried your fix and that didn't change anything...do you have any other ideas? How can the page be displayed even though it's obviously running into an error and not displaying a simple echo statement at the end?...thanks again for your help...
  15. I have placed a FOR LOOP in a FOR LOOP, I am not getting any error messages, but my echo statement at the end is not being displayed, as well as the fact that the data for the most part is being inserted, but when the first file is checked against the second something is not working, because under the poplar column i still have 'y' where it should of switched it with a price...thanks for the help...darwin $Chunks = strtolower($Chunks); $Chunks = str_replace('"', '', "$Chunks"); $Chunks = explode("\r\n", $data); for($i = 0; $i < count($Chunks); $i++){ list($page,$item_number_1,$size,$info,$pricing,$pine,$poplar,$red_oak,$white_oak,$alder,$fir,$hemlock,$maple,$cherry,$hickory,$mahogany,$lyptus,$brazillian_cherry,$beech,$maple_with_leaf,$mdf,$birch,$walnut) = split('[,]', $Chunks[$i]); if($poplar == 'y'){ $theData = str_replace('"', '', "$theData"); $wordChunks = explode("\r\n", $theData); for($s = 0; $s < count($wordChunks); $s++){ list($item_number_2, $price) = split('[,]', $wordChunks[$s]); if($item_number_1 == $item_number_2){$poplar = $price;}; }; }; mysql_query("INSERT INTO alldata (page,item_number_1,size,info,pricing,pine,poplar,red_oak,white_oak,alder,fir,hemlock,maple,cherry,hickory,mahogany,lyptus,brazillian_cherry,beech,maple_with_leaf,mdf,birch,walnut) VALUES('$page','$item_number_1','$size','$info','$pricing','$pine','$poplar','$red_oak','$white_oak','$alder','$fir','$hemlock','$maple','$cherry','$hickory','$mahogany','$lyptus','$brazillian_cherry','$beech','$maple_with_leaf','$mdf','$birch','$walnut')") or die('Error, query failed: '.mysql_error()); }; echo "Importing all information complete";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.