jschofield Posted January 25, 2007 Share Posted January 25, 2007 Hello Fellow php scripters,I have a problem getting my SQL query to work while opening an ODBC connection. The error I get is 'could not decrypt file'...SQL state S1000. Below is my code. Anyone know why its not working? The file I am using is named sj011907.xls. The sheet that is in excel is named 011907. The importlibrary.inc.php script is just a standard logging script. Thanks for all your help. Johnnie<?php$inputfile = "C:/SMDIM/Data/sj011907.xls";$outputfile = "C:/SMDIM/Data/All_Student_Data.csv";$logfilename = "C:/SMDIM/Logs/All_Student_Log.txt";include'C:/SMDIM/Translators/importlibrary.inc.php';//The query$query = "SELECT * FROM [011907$]";//The excel driver we need$connection = odbc_connect('Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;Dbq='.$inputfile.';','','');$count = 0;//Execute the queryif(!$dbexec = odbc_exec($connection, $query)) { wlogdie("Failed to execute the query"); }else{ wlog("Successfully executed the query");}//open the fileif(!$outfilefp = fopen($outputfile, "w")) { wlogdie("Failed to open $outputfile"); }else{ wlog("Opened $outputfile for writing"); }//read through the file and strip any extra characters from phone numbers//add English language codes to the end of each linewhile (odbc_fetch_into($dbexec, $row)) {$temp = array($row[3],$row[4],$row[9],$row[10],$row[] = "English");$count++; writeLine($outfilefp, $row);}if($count !== '0') { wlog("finished the import with a total of $count records");}else{ wlog("Failed to import data");}?> Link to comment https://forums.phpfreaks.com/topic/35730-sql-query-and-odbc-connection-using-php-script/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.