Jump to content

tapius1

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by tapius1

  1. I have a HUGE issues, im reading in a .txt file which contains foreign letters like, " ö " however, when i use fread, $fileOfRecords = fread($handle, filesize($filename)); and insert into the MSSQL Database, (The database is setup to handle encoding types with such character sets) When reviewing the text in the tables, such characters like ö turn into "ö" making the text in the tables garbage. My question is - how can i make sure that when I read these files and do my table inserts, that the correct character is being inserted. I know for a fact that the Database can handle these characters as Ive just done a replace of ö for ö, and ö stayed in the tables, so it is a matter of my php script. Any help would be greatly appreciated. Thanks
  2. make sure you close all your } brackets..? didn't try to run it but thats ususally the case for that kind of parse error.
  3. I have no idea what the problem is with preg_replace and strings smaller than 3 characters. I'm writing to do a pattern search of abreviations(array) and replacements (array)... tried word boundries, which seems not to work at all. (it is VITAL that im able to match the whole word) here is a quick example which I cannot understand maybe someone could explain to me: 1. why repitions of certain abrevs do not get replaced. 2. why '/\bs.\b/' wont get matched (where there is a space before the b. - hense the word boundry) here is a snippet of code could someone please explain why this happens: <?php $string='de d. s. pres. div. de de d. s.'; //DEFINE PATTERN $patterns = array(); $patterns[0] = '/ s. /'; $patterns[1] = '/ b. /'; $patterns[2] = '/ pres./'; $patterns[3] = '/ Ind./'; $patterns[4] = '/ Mar./'; $patterns[5] = '/ Agt./'; $patterns[6] = '/ Agy./'; $patterns[7] = '/ Indpls./'; $patterns[8] = '/ Chgo./'; $patterns[9] = '/ Corp./'; $patterns[10] = '/ U./'; $patterns[11] = '/ Fin./'; $patterns[12] = '/ ls./'; $patterns[13] = '/ Pres. /'; $patterns[14] = '/ Internat. /'; $patterns[15] = '/ m. /'; $patterns[16] = '/ N.Y.C./'; $patterns[17] = '/ div. /'; $patterns[18] = '/ de /'; $patterns[19] = '/ d. /'; //DEFINE PATTERN REPLACE $replacements = array(); $replacements[0] = ' son of '; $replacements[1] = ' born in '; $replacements[2] = ' president'; $replacements[3] = ' Indiana '; $replacements[4] = ' March '; $replacements[5] = ' Agent '; $replacements[6] = ' Agency '; $replacements[7] = ' Indianapolis '; $replacements[8] = ' Chicago'; $replacements[9] = ' Corporation '; $replacements[10] = ' U '; $replacements[11] = ' Financial '; $replacements[12] = ' Island'; $replacements[13] = ' President '; $replacements[14] = ' International '; $replacements[15] = ' married to '; $replacements[16] = ' New York City '; $replacements[17] = ' divorced'; $replacements[18] = ' de '; $replacements[19] = ' daughter of '; echo '------ Original ---------<br>'.$string.'<br>'; $data = preg_replace($patterns, $replacements, $string); echo '<br>------ Abbreviation Replace ---------<br>'.$data.'<br>'; ?> OUTPUT: ------ Original --------- de d. s. pres. div. de de d. s. ------ Abbreviation Replace --------- de daughter of son of president divorcedde daughter of d. s. any help is appriciated thanks.
  4. I need some help figuring out what's wrong with my query .....//create new db object that connects to the db $db = new DB2(); if(!$db->connect("DB2CONN", "user","*******")) { print "Error\n"; header("location:ERROR.htm"); } //insert statement to repleace account information with updated information, make sure all fields are filled in, //if possible use _GET and put in the values into the boxes before the user makes any changes $sql .="INSERT INTO KCWEB (ADDR1, ADDR2, CITY, STATE, ZIP, PHONE1, PHONE2, SSN_NUM) VALUES ($address1, $address2, $city, $state, $zip, $phone1, $phone2, $ssn_num) WHERE CTRL_NUM = $ctrl_num"; $db->query($sql); echo "Account Information Updated"; ?> it returns : Error: [unixODBC][iBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token , was not valid. Valid tokens: ( + - ? : DAY RRN CASE CAST CHAR DATE DAYS HASH HOUR LEFT NULL. SQL: INSERT INTO KCWEB (ADDR1, ADDR2, CITY, STATE, ZIP, PHONE1, PHONE2, SSN_NUM) VALUES (, , , , , , , 3333) WHERE CTRL_NUM = 3333333333 any help would be great thanks
  5. I need help with some code, im connecting to two databases on different machines and would like to run a query in which i fetch values from one db table and insert them into another using a primary key to identify what goes where. The code runs but the query doesn't every insert the values. Maybe someone could help me out. I'm moving a TON of data, 30,000 records per day, for a total for 3 months.. im trying to just accomplish 1 day at a time.. also phpED stopped query execution after 300 seconds, i wanted to know if this is a limit in php or just my IDE. anyway heres my code, tell me if theres something wrong with my insertion statement <?php //connect to VOICE RECORDING DATABASE $conn = odbc_connect("dsn1","user","pass"); mysql_selectdb("dsn1"); if ($conn) { echo "Connection 1 succeeded.<br />"; //connect to second database $conn2 = odbc_connect("dsn2","root","pass"); //mysql_select_db("dsn2"); if ($conn2) { echo "Connection 2 succeeded.<br />"; //initiate SQL query to second database connection .....date mmddyyyy $query2 = "SELECT * FROM rec_playint WHERE call_date = '07092009'"; //query to first database connection $query = "SELECT * FROM mysql.dsn1"; //return result sets numresults, and numresults2 for each of the queries $numresults = odbc_exec($conn, $query); $numresults2 = odbc_exec($conn2, $query2); //echo the results in a while loop // while($row = odbc_fetch_array($numresults2)) //{ // echo "{$row['call_date']}<br />" . // "{$row['call_time']}<br />" . // "{$row['tsr']}<br><br />"; // //echo the result for the other database // $row2 = odbc_fetch_array($numresults); // echo "{$row2['NobleCallID']}<br><br />"; //} while($row = odbc_fetch_array($numresults2)) { //while fetching arrays in connection 2 (dsn2 - NOBLE) insert into the $row2 Voice Recording Table $query = "INSERT INTO mysql.dsn1 (RecDate, RecTime, AgentID) VALUES ({$row['call_date']},{$row['call_time']}, {$row['tsr']}) WHERE NobleCallID = {$row['file_num']} "; echo "{$row['call_date']} " . "{$row['call_time']} " . "{$row['tsr']}" . "{$row['file_num']}"; } echo "finished"; odbc_close($conn); odbc_close($conn2); echo "both connections have been closed"; } else { echo "Connection failed.<br />"; echo odbc_errormsg(); } } ?>
×
×
  • 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.