Jump to content

tapius1

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tapius1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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(); } } ?>
  6. I figured out the problem! this issue was caused by the odbc_num_rows() function. on the DB2 iSeries driver it didn't function. Always out put -1, so a solution was write a new get_num_rows() function to manually loop the rows. Google actually heh. but it's worth bringing up for anyone else who has had this issue and didn't notice where it the value was always incorrect.
  7. tapius1

    ODBC_NUM_ROWS

    so i finnally found the source of a lot of frustration: $count = odbc_num_rows($rs) .,, always returns -1 on my CentOS / DB2 box but on windows it returns the actual row count, could someone help me modify my code so that it gets the actual row count? <?php //Establish connection to database $ctrl_num = $_POST['ctrl_num']; $ssn_num = $_POST['ssn_num']; $host = "acq"; $conn = odbc_connect ("DB2CONN","michaele", "********"); $query = "Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num"; //Execute query $result = odbc_exec($conn, $query) ; $firstname = odbc_result($result, 'fname'); $count = odbc_num_rows($result); if ($count==1){ print 'success! - logged in'; //if successful print("<td>$firstname has logged in. Welcome to the payment center</td>\n"); }else { //failed login echo "<br>Incorrect Control Number OR Social Security Number Found</br>"; echo "<br>Tried to execute the following query:Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num </br>"; echo "<left><br><input type='button' value='Retry' onClick='history.go(-1)'></left>"; } ?> Thanks, your help is very much appriciated
  8. I work on a windowsXP with ODBC running with a DSN to a DB2 server (AS/400) everything connects fine with my php code in windows and when i query the server to see if a user name and password exist, it returns me with a success or fail and retrieves the user's first name if successful. The same code is supposed to run on a CentOS(RED HAT) machine with the same ODBC extensions (running Zend Server) and iSeries Access Driver for DB2 (on the AS/400). I'm able to get php code to run and connect, query, and return results. However for some reason passing (the correct values) variables always leads to a failed login on the CentOS Machine, despite successful runs of other php scripts. I think the problem lies somewhere in getting the result back.. ive added a bunch of extra echo statements to help me figure what is going on here. the echos state the query and show it to be correct, so why don't i see results? Here is the code for logincheck.php : <?php //Establish connection to database $ctrl_num = $_POST['ctrl_num']; $ssn_num = $_POST['ssn_num']; $host = "acq"; $conn = odbc_connect ("DB2CONN","michaele", "********"); $query = "Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num"; //Execute query $result = odbc_exec($conn, $query) ; $firstname = odbc_result($result, 'fname'); $count = odbc_num_rows($result); if ($count==1){ print 'success! - logged in'; //if successful print("<td>$firstname has logged in. Welcome to the payment center</td>\n"); }else { //failed login echo "<br>Incorrect Control Number OR Social Security Number Found</br>"; echo "<br>Tried to execute the following query:Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num </br>"; echo "<left><br><input type='button' value='Retry' onClick='history.go(-1)'></left>"; } ?> the code for the html login.html I'm not including because it is trivial, its a form with 2 textboxes one is a password box, and a submit button.. anyway some help or possible answer as to why this only works from the windows machine, when they are both using the same code and both make use of ODBC and the DSN ---would greatly appreciate any help thanks
  9. I work on a windowsXP with ODBC running with a DSN to a DB2 server (AS/400) everything connects fine with my php code in windows and when i query the server to see if a user name and password exist, it returns me with a success or fail and retrieves the user's first name if successful. The same code is supposed to run on a CentOS(RED HAT) machine with the same ODBC extensions (running Zend Server) and iSeries Access Driver for DB2 (on the AS/400). I'm able to get php code to run and connect, query, and return results. However for some reason passing (the correct values) variables always leads to a failed login on the CentOS Machine, despite successful runs of other php scripts. I think the problem lies somewhere in getting the result back.. ive added a bunch of extra echo statements to help me figure what is going on here. the echos state the query and show it to be correct, so why don't i see results? Here is the code for logincheck.php : <?php //Establish connection to database $ctrl_num = $_POST['ctrl_num']; $ssn_num = $_POST['ssn_num']; $host = "acq"; $conn = odbc_connect ("DB2CONN","michaele", "********"); $query = "Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num"; //Execute query $result = odbc_exec($conn, $query) ; $firstname = odbc_result($result, 'fname'); $count = odbc_num_rows($result); if ($count==1){ print 'success! - logged in'; //if successful print("<td>$firstname has logged in. Welcome to the payment center</td>\n"); }else { //failed login echo "<br>Incorrect Control Number OR Social Security Number Found</br>"; echo "<br>Tried to execute the following query:Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num </br>"; echo "<left><br><input type='button' value='Retry' onClick='history.go(-1)'></left>"; } ?> the code for the html login.html I'm not including because it is trivial, its a form with 2 textboxes one is a password box, and a submit button.. anyway some help or possible answer as to why this only works from the windows machine, when they are both using the same code and both make use of ODBC and the DSN ---would greatly appreciate any help thanks
×
×
  • 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.