Jump to content

Cerberus_26

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Cerberus_26's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok so apparently when my script is executed, somehow it copies itself and appends it to the end of the file therefore creating multiple instances of the same function throwing the error. I didn't notice it before because dreamweaver didn't reload the script after I had run it on the server. I can prevent this from happening, but now I get a blank html page with "Empty document 1" as a result of the php script and nothing is inserted into my database.
  2. Here is some of the code, the script parses through multiple xml files and adds the fields into a database. [code] <?php function better_odbc_num_rows($con,$sql) {    $result = odbc_exec($con,$sql);    $count=0;    while($temp = odbc_fetch_into($result, &$counter)){        $count++;    }    return $count; } function start_tag($parser, $name, $attribs) {    global $current;    global $attributes;    global $guid;       $current = $name;    if ($current == "TAG1")            $guid = $attribs["ID"];       if ($current == "PERSON")            $attributes = $attribs["TYPE"]; } function end_tag($parser, $name) {        global $variables;       if ($name == "TAG1")    {            $odbc = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . str_replace("/", "\\", $_SERVER["DOCUMENT_ROOT"]) . "database.mdb", "", "") or die('Could Not Connect to ODBC Database!');                     $query = "SELECT * FROM Table1 WHERE ID = '$guid'";         $rs = odbc_exec($odbc, $query);                          $count = better_odbc_num_rows($odbc, $query);         if ($count != 1)         {             $query = "INSERT INTO QUERY";             //$temp = $guid;                          $rs = odbc_exec($odbc, $query);             if(!$rs)             {                 echo "<script language=\"Javascript\">alert(\"There was an error inserting into the database, please try again\")</script>";                 exit();             }                      }         else             echo "Duplicate Record Skipped...'$guid'<br />";                      odbc_close($odbc);                       }    } ....... $dir = "path to folder with xml files";                  // open directory and parse file list if (is_dir($dir)) {     if ($dh = opendir($dir))     {         // iterate over file list         // print filenames         while (($filename = readdir($dh)) !== false)         {             if (! ($xmlparser = xml_parser_create()) )             {                    die ("Cannot create parser");             }                          xml_set_element_handler($xmlparser, "start_tag", "end_tag");             xml_set_character_data_handler($xmlparser, "tag_contents");                          //echo $dir."/".$filename;             if (($filename != ".") && ($filename != "..") && (substr($filename,strlen($filename-3),strlen($filename)) != "doc"))             {                 if (!($fp = fopen($dir."/".$filename, "r"))) { die("cannot open ".$filename); }                 while ($data = fread($fp, 4096))                 {                    $data=eregi_replace(">"."[[:space:]]+"."<","><",$data);                    if (!xml_parse($xmlparser, $data, feof($fp)))                    {                       $reason = xml_error_string(xml_get_error_code($xmlparser));                       $reason .= " ".xml_get_current_line_number($xmlparser);                       die($reason);                    }                 }                 fclose($fp);             }                          if (!(file_exists("path to processed xml files".substr($filename,0,15).".xml")) || !(file_exists("path to processed word docs".substr($filename,0,15).".doc")))             {                 if (($filename != ".") && ($filename !=".."))                 {                     if (substr($filename,strlen($filename-3),strlen($filename)) == "xml")                     {                         rename($dir."/".$filename, "path to processed xml".substr($filename,0,15).".xml") or die("Could not move .xml file");                         $filecount++;                     }                     if (substr($filename,strlen($filename-3),strlen($filename)) == "doc")                     {                         rename($dir."/".$filename, "path to processed word docs".substr($filename,0,15).".doc") or die("Could not move .doc file");                     }                 }             }             else if (($filename != ".") && ($filename !=".."))             {                 unlink($dir."/".$filename);             }                              xml_parser_free($xmlparser);         } // close directory     closedir($dh);     } [/code] I can include more if needed. The function tag_contents Due to the sensitive nature of the material I've had to strip out alot of info such as variable names and queries, but the script did work when I used it on a small number of xml files. It didn't break until I attempted to use it on a much larger number of xml files. [!--quoteo(post=349153:date=Feb 24 2006, 04:14 PM:name=Caesar)--][div class=\'quotetop\']QUOTE(Caesar @ Feb 24 2006, 04:14 PM) [snapback]349153[/snapback][/div][div class=\'quotemain\'][!--quotec--] Please provide some example code that we can look through. [/quote]
  3. I have a peculiar error message popping up that I don't know the answer to. Fatal error: Cannot redeclare better_odbc_num_rows() (previously declared in add_info.php:2) in add_info.php on line 460 Now I understand why this error would be popping up if I had in fact declared the function twice, but I only declared it once. Also although I did declare the function in line 2, there is no line 460 in my code. It only goes to line 447. Also if I comment out this function then the error message pops up again with the next function in the file. Any help would be greatly appreciated in solving this issue.
×
×
  • 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.