
tanveer
Members-
Posts
50 -
Joined
-
Last visited
Never
Everything posted by tanveer
-
Error showing confirmation after generating an XML file
tanveer replied to tanveer's topic in PHP Coding Help
hi thanks.. Yes thats the reason I was trying to know .. at line 80 is that function to show the message that XML file created successfully. Before that I am also closing the file handler but it's thinking it as a continuation of creating that xml file. Thats the problem actually. -
Error showing confirmation after generating an XML file
tanveer replied to tanveer's topic in PHP Coding Help
Anyone has any idea why this is happening ? It's giving error if I want to show any message after creating the file. class SocialNetXML extends SystemConfig { public $sqlQuery = ""; public $resultID = ""; public function setQuery($query){ $dbConnect = new DBConnect(); $dbConnect->Connection("localhost", "dbname", "user", ""); $resultID = mysql_query($query) or die("Data not found."); return $resultID; } public function generateXML($empIDList, $relationList){ header("Content-type: text/xml"); $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $xml_output .= "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\">\n"; $xml_output .= "<graph edgedefault=\"directed\">\n"; $xml_output .= "<key id=\"name\" for=\"node\" attr.name=\"sender\" attr.type=\"string\"/>\n"; for($x = 1 ; $x <= mysql_num_rows($empIDList) ; $x++){ $row = mysql_fetch_assoc($empIDList); $xml_output .= "\t<node id=\"$x\">\n"; $xml_output .= "\t\t<data key=\"name\">" . $row['emp_addr'] . "</data>\n"; $xml_output .= "\t</node>\n"; } for($x = 1 ; $x <= mysql_num_rows($relationList) ; $x++){ $row = mysql_fetch_array($relationList); $xml_output .= "\t<edge source=\"" . $row[0] . "\" target=\"" . $row[1] . "\"></edge>\n"; } $xml_output .= "</graph>\n"; $xml_output .= "</graphml>\n"; return $xml_output; } public function createXMLFile ($xml_output){ print $xml_output; $file_handle = fopen('/tmp/authorNetwork.xml','w'); fwrite($file_handle,$xml_output); fclose($file_handle); } public function confirmationMsg(){ print "<h1> XML File Has Been Successfully Created </h1> <br /> <h2> XML File Location: /tmp </h2> "; } } $enxml = new SocialNetworkXML; // Finding the Author's who sent mail. //$empIDList = $enxml->setQuery ("SELECT emp_name FROM emplist WHERE emp_name IS NOT NULL"); $empIDList = $enxml->setQuery (" SELECT emp_addr FROM emplist "); // Finding the Author's recipients whom they sent mail to generate the XML $relationList = $enxml->setQuery ("SELECT emp_id, receiver_id FROM message, rcptinfo WHERE message.mail_id = rcptinfo.mail_id"); $xml_output = $enxml->generateXML($empIDList, $relationList ); $enxml->createXMLFile($xml_output); $enxml->confirmationMsg(); ?> -
Error showing confirmation after generating an XML file
tanveer replied to tanveer's topic in PHP Coding Help
This page contains the following errors: error on line 80 at column 1: Extra content at the end of the document Below is a rendering of the page up to the first error. -
Hi, I am creating an XML file from the mysql database and it's creating fine. But after creating it and writing it to a file I just want to show the output as "File creation is successful" that sort of message. But it gives me error if I call the function to show that message. Below is the code: public function generateXML($resultID){ header("Content-type: text/xml"); $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $xml_output .= "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\">\n"; $xml_output .= "<graph edgedefault=\"directed\">\n"; $xml_output .= "<key id=\"name\" for=\"node\" attr.name=\"sender\" attr.type=\"string\"/>\n"; for($x = 1 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<node id=\"$x\">\n"; $xml_output .= "\t\t<data key=\"name\">" . $row['sender'] . "</data>\n"; $xml_output .= "\t</node>\n"; } $xml_output .= "</graph>\n"; $xml_output .= "</graphml>\n"; return $xml_output; } public function createXMLFile ($xml_output){ // print $xml_output; $file_handle = fopen('/tmp/socialNetwork.xml','w'); fwrite($file_handle,$xml_output); fclose($file_handle); } // It gives an error if I call this function for showing the file creation status. public function showMessage (){ echo "<H1> File Successfully Created </H1>"; } } $snxml = new SocialNetworkXML; $holdResult = $snxml->setQuery("select distinct sender from message1"); $xml_output = $snxml->generateXML($holdResult); $snxml->createXMLFile($xml_output); $snxml->showMessage(); ?>
-
Found it ... in Email I forgot to sanitize the variable .. Now after removing spaces from email it's working as there was a space in front an email .. Thanks all.
-
Thanks for the reply. I changed to while loop but still same. public function tblRcptInfo($rtype, $hValue ){ /* * Fetch Last mail_id Value from `message` table */ $mail_id = PopulateTables::findLastMailId(); $headerValue = explode(",", $hValue); $i = 0 ; while ($i < count($headerValue)){ $receiverID = PopulateTables::getReceiverID($headerValue[$i]); PopulateTables::populateRcptInfo( $rtype, $receiverID, $mail_id ); $i ++; } } public function getReceiverID ($rEmail){ $dbConnect = new DBConnect(); $dbConnect->Connection("localhost", "dbname", "uname", ""); $findIdQuery = "SELECT emp_id FROM emplist WHERE emp_addr='$rEmail'"; $resultQuery = mysql_query($findIdQuery) or die ("Error: Select Query Failed for emp_list Table "); echo "QUery:".$findIdQuery; $countRows = mysql_num_rows($resultQuery); $rID = mysql_fetch_array($resultQuery); return $rID[0]; } public function populateRcptInfo ( $rtype, $receiverID, $mail_id ){ $dbConnect = new DBConnect(); $dbConnect->Connection("localhost", "dbname", "uname", ""); $insertQuery= "INSERT INTO rcptinfo (reply_type, receiver_id, mail_id) VALUES ('$rtype', $receiverID, $mail_id )"; echo $insertQuery; mysql_query($insertQuery) or die("Error: Insert Query Failed for `RcptInfo` Table"); } here is the output of query where it's showing in 2nd time it's not getting the result ... QUery:SELECT emp_id FROM emplist WHERE emp_addr='[email protected]' INSERT INTO rcptinfo (reply_type, receiver_id, mail_id) VALUES ('TO', 2, 1 ) QUery:SELECT emp_id FROM emplist WHERE emp_addr=' [email protected]' INSERT INTO rcptinfo (reply_type, receiver_id, mail_id) VALUES ('TO', , 1 ) Error: Insert Query Failed for `RcptInfo` Table
-
Hi, I am facing a weird problem.. table `getReceiverID` was supposed to return all the empid values by running the query which it's not doing. It works only for the first time and after that the output of mysql_num_rows() gets zero. But it shouldn't be.. I am stuck .. What I am doing wrong ? Thank you. public function tblRcptInfo($rtype, $hValue ){ /* * Fetch Last mail_id Value from `message` table */ $mail_id = PopulateTables::findLastMailId(); $headerValue = explode(",", $hValue); foreach ($headerValue as $value){ $receiverID = PopulateTables::getReceiverID($value); } } public function getReceiverID ($rEmail){ $dbConnect = new DBConnect(); $dbConnect->Connection("localhost", "dbanme", "uname", ""); $findIdQuery = "SELECT emp_id FROM emplist WHERE emp_addr='$rEmail'"; $resultQuery = mysql_query($findIdQuery) or die ("Error: Select Query Failed for emp_list Table "); $countRows = mysql_num_rows($resultQuery); echo "rows ret:".$countRows; $rID = mysql_fetch_array($resultQuery); return $rID[0]; }
-
Hi, I wanted to know is there any class or functions which will parse the mail body and find all the features like how many sentences, how many stop words, how many paragraphs, how many punctuation chars, etc. I haven't find anything good in my searching so far. I have parsed the whole body of email and separated the headers and body in variables. Now I want to perform these operations in only in the body. Thank you in advance.
-
Thanks, it solved as u said the problem was on Quoting.
-
Hi, I am using php to generate an xml file of the following structure <?xml version="1.0" encoding="UTF-8"?> <!-- An excerpt of an egocentric social network --> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"> <graph edgedefault="directed"> <!-- data schema --> <key id="name" for="node" attr.name="name" attr.type="string"/> <key id="gender" for="node" attr.name="gender" attr.type="string"/> <!-- nodes --> <node id="1"> <data key="name">Jeff</data> <data key="gender">M</data> </node> <node id="2"> <data key="name">Ed</data> <data key="gender">M</data> </node> <node id="3"> <data key="name">Christiaan</data> <data key="gender">M</data> </node> <node id="4"> <data key="name">Emily</data> <data key="gender">F</data> </node> <node id="5"> <data key="name">Adam</data> <data key="gender">M</data> </node> <!-- emily's friends --> <edge source="1" target="2"></edge> <!-- adam's friends --> <edge source="2" target="3"></edge> <!-- cynthia's friends --> <edge source="3" target="4"></edge> <!-- joylette's friends --> <edge source="4" target="5"></edge> <!-- amanda's friends --> <edge source="5" target="1"></edge> <edge source="5" target="2"></edge> <edge source="5" target="3"></edge> <edge source="5" target="4"></edge> </graph> </graphml> and below is my code: public function createXML($resultID){ header("Content-type: text/xml"); $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $xml_output .= "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\">\n"; $xml_output .= "<graph edgedefault=\"directed\">\n"; $xml_output .= "<key id=\"name\" for=\"node\" attr.name=\"sender\" attr.type=\"string\"/>\n"; for($x = 1 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<node id=$x>\n"; $xml_output .= "\t\t<data key=\"name\">" . $row['sender'] . "</data>\n"; $xml_output .= "\t</node>\n"; } $xml_output .= "</graph>\n"; $xml_output .= "</graphml>"; echo $xml_output; } } $snxml = new SocialNetworkXML; $holdResult = $snxml->setQuery("select sender from message1"); $snxml->createXML($holdResult); But in browser its giving me this message: XML Parsing Error: not well-formed Location: http://localhost/........./SocialNetXML.class.php Line Number 5, Column 11: <node id=1> -----------------^ What am I doing wrong here ? thanks in advance.
-
thanks .. I missed that one right..
-
Hi, After a long time I start php again to do some stuff and using OOP concept for the first time and getting this below error PHP Fatal error: Class 'SystemConfig' not found in /home/tanveer/Workspace/EmailTest/webapp/classes/MailParser.class.php on line 12, referer: http://localhost/EmailTest/public_html/index.php My project directory structure is as follows: \webapp: |- classes |- MailParser.class.php |-DatabaseConnect.class.php |-SystemConfig.class.php \public_html: |-header.php |-footer.php |-gencsv.php |-stat.php \css |-style.css \images index.php And the php code file that I am trying to make work is as follows: class MailParser extends SystemConfig { /* Reads the files passed line-by-line * @param $fileName */ public function readFiles($fileName){ $fileHandler = fopen($fileName,'r'); while ($line = fgets($fileHandler)) { echo $line."<br />"; } fclose($fileHandler); } /* Traverse the user specified directory * @param $dirPath */ public function traverseDirectory($dirPath) { echo $dirPath; $sentFolderPath = new SystemConfig(); $sentFolderPath->getSentMailFolder(); $totalDirPath = $dirPath."/".$sentFolderPath; echo $totalDirPath; $io=0; if ($handle = @opendir($dirPath)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $newdir = ""; $filetext = ""; if (!is_file($dirPath."/".$file) or is_dir($dirPath) ) { $io++; $newdir.= $dirPath."/".$file."/"; print $newdir."<br />"; $this->traverseDirectory($newdir); if(is_file($dirPath.$file)) { $text = str_replace('//','/',"".$dirPath.$file."\n"); } } } } closedir($handle); } } } $rmf = new MailParser(); $rmf->traverseDirectory($_POST["dirpath"]); ?>