remmingtonshowdown Posted March 25, 2009 Share Posted March 25, 2009 Hey all, I have been working on this code to allow the upload of a csv file, reading of the file, creation of an array (with addition of other data) from the csv and then some other CMS stuff with that array... It successfully accepts the upload from the form and saves it but the array isn't ever created... I've been staring at it too long and can't see the forest for the trees. Perhaps a fresh set of eyes can spot something that I'm missing... I'm new with php so I'm sure that I've made a couple of glaring mistakes...but so goes the learning process right... Thanks in advance... -Julian <? require_once("modules/pagesetter/common.php"); require_once("modules/pagesetter/common-edit.php"); function pagesetter_results_edit() { // Check access if (!pnSecAuthAction(0, 'pagesetter::', '::', ACCESS_ADMIN)) return pagesetterErrorPage(__FILE__, __LINE__, _PGNOAUTH); if (!pnModAPILoad('pagesetter', 'admin')) return array( 'result' => false, 'messages' => array('error' => 'Unable to load Pagesetter admin API') ); if (!pnModAPILoad('pagesetter', 'user')) return array( 'result' => false, 'messages' => array('error' => 'Unable to load Pagesetter user API') ); if (!pnModAPILoad('pagesetter', 'edit')) return array( 'result' => false, 'messages' => array('error' => 'Unable to load Pagesetter edit API') ); //csv uploading $target = "files/"; $target = $target . basename( $_FILES['results']['name']) ; $raceValue = $_POST['raceValue']; $tid = $_POST['tid']; $pid = $_POST['pid']; $cupRace = $_POST['cupRace']; $userid = $_POST['userid']; $uscf = $_POST['uscf']; $ins = 0; $ok = 1; move_uploaded_file($_FILES['results']['tmp_name'], $target); $csvfile = $target; $message = $csvfile; $handle = fopen($csvfile, "r"); $data = fgetcsv($handle, 1000, ","); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $row++; for ($c=0; $c < $num; $c++) { } $pubData = array ( 'core_author' => 'Admin',//username 'core_creatorID' => 2,//userid 'core_creator' => 'Admin',//username 'core_approvalState' => 'approved',//id of state, according to your workflow 'core_topic' => -1,//topic id, -1 for all topic 'core_showInList' => 1, 'core_showInMenu' => 1, 'core_online' => 1, 'core_revision' => 0, 'core_language' => 'x_all',//lang code or 'x_all' for all languages 'core_publishDate' => '2006-09-06 17:26:29',//publish date if shown format, use eg strftime("%Y-%m-%d %H:%M:%S", time() 'core_expireDate' => '',//date format the same as above 'organization' => $data[0],//all the USCF fields here! 'year' => $data[1], 'eventPermit' => $data[2], 'raceDate' => $data[3], 'discipline' => $data[4], 'category' => $data[5], 'gender' => $data[6], 'class' => $data[7], 'age' => $data[8], 'license' => $data[9], 'lastName' => $data[10], 'firstName' => $data[11], 'bib' => $data[12], 'teamName' => $data[13], 'time' => $data[14], 'place' => $data[15]); $ok = pnModAPIFunc( 'pagesetter', 'edit', 'createPub', array('tid' => 2, 'pubData' => $pubData) ); if (!$ok) return array( 'result' => false, 'messages' => array('error' => "Unable to create Pagesetter publication of type ID '$tid'. " . pagesetterErrorAPIGet()) ); } //ugly..use DbUtil:: $databasehost = "localhost"; $databasename = "binaryov_ica"; $databaseusername ="binaryov_showdow"; $databasepassword = "sesame"; $con = @mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error()); @mysql_select_db($databasename) or die(mysql_error()); $sql = "UPDATE zk_pagesetter_pubdata1 SET pg_field69 = 1 WHERE pg_pid = $pid"; mysql_query($sql) or die(mysql_error()); pnSessionSetVar('statusmsg', "Race Results Uploaded to the ICA website only."); //SOAP process to upload the csv to USA Cycling. if ($uscf == 1) { require_once("nusoap.php"); $wsdl = "http://www.usacycling.org/xml/submit.php?wsdl"; $client = new soapclient($wsdl, 'wsdl'); $client->debug_flag = true; //load the results file $file = $target; $fd = fopen($file, "r"); $results = fread($fd, filesize($file)); $param = array('username' => 'showdown', 'password' => 'sesame', 'results' => $results); $ret = $client->call('SubmitResults', $param); $err = $client->getError(); pnSessionSetVar('statusmsg', "Race Results Uploaded to the ICA website and USACycling.org."); //echo "SubmitResults web service returned: $ret\n"; //echo "Err = $err\n"; //echo $client->getDebug(); } pnRedirect(pnModURL('pagesetter', 'user', 'viewPub',array('tid' => $tid, 'pid' => $pid))); return true; } ?> Link to comment https://forums.phpfreaks.com/topic/151047-fresh-set-of-eyes-needed/ Share on other sites More sharing options...
Yesideez Posted March 25, 2009 Share Posted March 25, 2009 Best you use long tags <?php instead of short <? Makes for better future compatibility and to highlight code in different colors on here. Link to comment https://forums.phpfreaks.com/topic/151047-fresh-set-of-eyes-needed/#findComment-793536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.