PHP - Problem Loading A File Into Simplehtmldom
I am a new simplehtmldom user. It is working and the php api loads, and I can parse
when I lod data from a string. But if I attemp yo load data from a file like this... Code: [Select] $html->file_get_html("C:\eaahmpg\eatc7402\www\stations\Sydney\code\table_data.txt"); I receive the following error. Fatal error: Call to undefined method simple_html_dom::file_get_html() in... Hmmm. The function IS defined in the api. I'm not sure where I'M going wrong here. eac7402 Similar TutorialsThe html file i'm scraping from has 11 boxevent div classes and I want to loop through them and grab the results and team name for each. Am I doing it the right way? Also how can I loop through all float-right result and team classes grabbing the data. <div class="boxevent"> <div class="row"> <span class="float-right result">4</span> <span class="team" title="Pittsburgh Power ">PIT</span> </div> <div class="row"> <span class="float-right result">12</span> <span class="team" title="Orlando Predators ">ORL</span> </div> </div> <div class="boxevent"> <div class="row"> <span class="float-right result">24</span> <span class="team" title="Atlanta ">ATL</span> </div> <div class="row"> <span class="float-right result">6</span> <span class="team" title="Miami ">MIA</span> </div> </div> **php** <?php include 'includes/simple_html_dom.php'; $html = new simple_html_dom(); $html = file_get_html('http://score...', false, $context); $score0 = $html->find('span[class=float-right result]', 0); $score1 = $html->find('span[class=float-right result]', 0); $team0 = $html->find('span[class=team]', 0); $team1 = $html->find('span[class=team]', 0); /* out */ echo '<pre>'; print_r($score0); print_r($score1); print_r($team0); print_r($team1); echo '</pre>'; $html->clear(); unset($html); ?> I am running php on one computer at work and want other users on other computers to access the index page by sharing it.after mapping the page, I see no data on the other machine. Does php, as pache need to beer installed on other computers footer it too work properly Hello fellow developers, Let me start by saying I'm still a PHP noob so please don't go too hard on me if I my code reflects this noobishness... So I'm trying to build a (very) simple RSS reader using jQuery and PHP. When the user clicks on an option from a dropdown, an AJAX call is made and passes the url selected from the list to a PHP script. The PHP script then loads the appropriate xml file from an 'xmlcache' folder. Everything is working just fine for files named as such: somefilename_1231231231.xml The problem is that I need it to be able to load files which have been urlencoded such as: http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548 In case you're wondering, the numbers at the end are a timestamp which will determine if the reader will load a cached copy of the desired xml file (if it's less than an hour old) or if it needs to get a fresh version (this part of the code is not written yet). Here is a look at my script thus far: <?php $url = "./xmlcache/" . urlencode($_REQUEST['url']); //access url from AJAX call echo $url; //outputs -> "./xmlcache/http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548.xml", which is the same as the file's name $curTime = time(); $urlParts = explode('_', $url); $urlTime = intval($urlParts[1]); $diff = $curTime - $urlTime; $urlAge = 60 * 60; //60sec * 60min = 3600sec or 1 hour if(file_exists($url)){ if($diff > $urlAge){ //the > will be switched to < to make logical sense once testing is done. $xml = simplexml_load_file($url); //ROOT TAG foreach($xml as $key0 => $value){ echo "$key0: $value"; foreach($value->attributes() as $attributeskey0 => $attributesvalue1){ echo "$attributeskey0: $attributesvalue1"; } echo "<br />"; //1 LEVEL BELOW ROOT TAG foreach($value as $key => $value2){ echo "$key: $value2"; foreach($value2->attributes() as $attributeskey => $attributesvalue2){ echo "$attributeskey = $attributesvalue2"; } echo '<br />'; //2 LEVELS BELOW ROOT TAG foreach($value2 as $key2 => $value3){ echo "$key2: $value3"; foreach($value3->attributes() as $attributeskey2 => $attributesvalue3){ echo "$attributeskey2 = $attributesvalue3"; } echo '<br />'; //3 LEVELS BELOW ROOT TAG foreach($value3 as $key3 => $value4){ echo "$key3: $value4"; foreach($value4->attributes() as $attributeskey3 => $attributesvalue4){ echo "$attributeskey3 = $attributesvalue4"; } echo '<br />'; //4 LEVELS BELOW ROOT TAG foreach($value4 as $key4 => $value5){ echo "$key4: $value5"; foreach($value5->attributes() as $attributeskey4 => $attributesvalue5){ echo "$attributeskey4 = $attributesvalue5"; } echo '<br />'; //5 LEVELS BELOW ROOT TAG foreach($value5 as $key5 => $value6){ echo "$key5: $value6"; foreach($value6->attributes() as $attributeskey5 => $attributesvalue6){ echo "$attributeskey5 = $attributesvalue6"; } echo '<br />'; } } } } echo '<br />'; } echo '<br />'; } }else{ //need to create the XML file from scratch, do a curl function, or read from a text file echo "need a new version"; //@unlink("$url); } }else{ echo "That file does not exist.<br/>"; } ?> The error message I'm getting is this: Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "./xmlcache/http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548.xml" in C:\wamp\www\reader\loadfeed.php on line 13 Warning: Invalid argument supplied for foreach() in C:\wamp\www\reader\loadfeed.php on line 16 The second error is obviously thrown because the file doesn't get loaded. I appreciate any help you gurus have to offer, and if you have any suggestions for the best way to load a fresh version that will be handled by the first else statement, I'm all ears. Thanks guys! Hi, I have uploaded a website for someone but they are having problems viewing it and are telling me that nothing comes up. Not sure if its a dns problem. The domain was registered 2 days ago. Can a couple of you please check and tell me if this site loads up, it should show an ecommerce website : http://www.cassellmotors.com Many thanks, Scott Code: [Select] <?php $ACCEPT_FILE['home'] = 'home.html'; $ACCEPT_FILE['general'] = 'general.html'; $ACCEPT_FILE['attorneys'] = 'attorneys.html'; $ACCEPT_FILE['contact'] = 'contact.html'; $ACCEPT_FILE['login'] = 'login.html'; $pagename = $ACCEPT_FILE[$id]; if (!isset($pagename)) $pagename = "home.html"; // default file include( $pagename ); ?> the url looks like: www.yoursite.com/index.php?id=general Ever since i think like php 5 came out i am unnable to load pages it just defaults to the home.html no matter what variable is defined. any ideas or help would be appreciated. Its almost like its not defining the pagename variable until the bottom where $pagename = "home.html". ive been looking at it and reading the manuals for hours and figured its time to make a post. thanks. hello dear Freaks
i am currently musing bout the portover of a python bs4 parser to php - working with the simplehtmldom-parser / pr the DOM-selectors... (see below). The project: for a list of meta-data of wordpress-plugins: - approx 50 plugins are of interest! but the challenge is: i want to fetch meta-data of all the existing plugins. What i subsequently want to filter out after the fetch is - those plugins that have the newest timestamp - that are updated (most) recently. It is all aobut acutality... https://wordpress.org/plugins/participants-database ....and so on and so forth.
https://wordpress.org/plugins/wp-job-manager we have the following set of meta-data for each wordpress-plugin: Version: 1.9.5.12 installations: 10,000+ WordPress Version: 5.0 or higher Tested up to: 5.4 PHP Version: 5.6 or higher Tags 3 Tags:databasemembersign-up formvolunteer Last updated: 19 hours ago
the project consits of two parts: the looping-part: (which seems to be pretty straightforward). the parser-part: where i have some issues - see below. I'm trying to loop through an array of URLs and scrape the data below from a list of wordpress-plugins. See my loop below- as a base i think it is good starting point to work from the following target-url:
plugins wordpress.org/plugins/browse/popular with 99 pages of content: cf ...
the Output of text_nodes: ['Version: 1.9.5.12', 'Active installations: 10,000+', 'Tested up to: 5.6 '] but if we want to fetch the data of all the wordpress-plugins and subesquently sort them to show the -let us say - latest 50 updated plugins. This would be a interesting task:
first of all we need to fetch the urls then we fetch the information and have to sort out the newest- the newest timestamp. Ie the plugin that updated most recently List the 50 newest items - that are the 50 plugins that are updated recently ..
we have the following set see here the Soup_ soup = BeautifulSoup(r.content, 'html.parser') target = [item.get_text(strip=True, separator=" ") for item in soup.find( "h3", class_="screen-reader-text").find_next("ul").findAll("li")[:8]] head = [soup.find("h1", class_="plugin-title").text] new = [x for x in target if x.startswith( ("V", "Las", "Ac", "W", "T", "P"))] return head + new with ThreadPoolExecutor(max_workers=50) as executor1: futures1 = [executor1.submit(parser, url) for url in allin] for future in futures1: print(future.result())
see the formal output Quote
background: https://stackoverflow.com/questions/61106309/fetching-multiple-urls-with-beautifulsoup-gathering-meta-data-in-wp-plugins Well - i guess that we c an do this with the simple DOM Parser - here the seclector reference. https://stackoverflow.com/questions/1390568/how-can-i-match-on-an-attribute-that-contains-a-certain-string
look forward to any hint and help.
have a great day Edited May 3, 2020 by dil_berthello i have problems refreshing this: <?php header("Refresh: 2;"); $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = '02071987'; $dbname = 'ProvoleasDB'; mysql_connect($dbhost,$dbuser,$dbpass) or die ("I could not connect!"); mysql_select_db($dbname) or die (mysql_error()); header("Content-type: text/xml"); echo '<?xml version=\'1.0\' encoding=\'UTF-8\'?>'; echo ' <rss version=\'2.0\'> '; echo ' <channel> <title></title> <description></description> <link></link>'; $data = mysql_query('SELECT * FROM UploadItem ORDER BY IID DESC LIMIT 10'); while($row = mysql_fetch_array($data)) { echo ' <item> <title>'.$row['FileName'].'</title> <link>localhost/items.php?iid='.$row['IID'].'</link> <description>'.$row['IID'].'</description> <guid>http://localhost/items.php?iid='.$row['IID'].'</guid> </item>'; } echo ' </channel> </rss>'; ?> <html> <head> </head> <body> </body> </html> could you help me?? Hello erveryone. I am new in programming and i have the following problem i cant figure out! i want to make a search into my database. i have prepared my html-js-php files but it seems i have a php problem. When i search and i type whatever letter then i get those results only.. name: brand: price //my php file Code: [Select] <?php require_once('../Connections/Mysitedb.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_Recordset1 = "-1"; if (isset($_GET['productname'])) { $colname_Recordset1 = $_GET['productname']; } mysql_select_db($database_Mysitedb, $Mysitedb); $query_Recordset1 = sprintf("SELECT manufacturer, productname, price FROM products WHERE productname = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $Mysitedb) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php do { ?> <form id="form1" name="form1" method="post" action=""> <table width="353"> <tr> <td width="59">name:</td> <td width="282"><?php echo $row_Recordset1['productname']; ?></td> </tr> <tr> <td>brand:</td> <td><?php echo $row_Recordset1['manufacturer']; ?></td> </tr> <tr> <td>price</td> <td><?php echo $row_Recordset1['price']; ?></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </body> </html> <?php mysql_free_result($Recordset1); ?> Hi everybody, I have recently change to a new server, and have some problem with a script for uploading files on my new server. Script is an old which I have updated with new php command, <? not accepted in new server. Scripts shall upload picture to folder in server and write information to database From form script I am saving my upload Code: [Select] <input type="hidden" name="Mode" value="EditMapProperty" /> <input type="hidden" name="Old_Map" value="<?php echo $Property->Get_Map();?>" /> In my php script I do elseif($Mode=="EditMapProperty"): $Map_name = $HTTP_POST_FILES['Map']['name']; $Property=new Property($PropertyID); $ReferenceNo=$Property->Get_ReferenceNo(); if($Map!=""): $DeleteMap=$Dir_MapProperty_Admin."".$Property->Get_Map(); @unlink($DeleteMap); endif; if($Map_name==""): $Map=$Old_Map; else: copy($HTTP_POST_FILES['Map']['tmp_name'], $Dir_MapProperty_Admin."".$ReferenceNo."-".$Map_name); $Map=$ReferenceNo."-".$Map_name; endif; $Property->EditMap($Map); //Update database information echo "<meta http-equiv=\"refresh\" content=\"0;URL=$Redirect2?p=property_details&PropertyID=$PropertyID\">"; () Can any help if there are any PHP problem in this coding. Kind Regards Tom Hi All, I have a code to upload a file to the server. Somehow the files don't get uploaded, although the record is add to the database. I have no clue why it doesn't work. The settings of the folder where the docs goto is set to 777. Code: [Select] <?php $uploaddir = "documents/"; $path = $uploaddir.$document; //This function reads the extension of the file. $allowedExtensions = array("doc", "pdf", "xls"); function isAllowedExtension($fileName) { global $allowedExtensions; return in_array(end(explode(".", $fileName)), $allowedExtensions); } if($document != ""){ //AS LONG AS A FILE WAS SELECTED... //compare the size with the maxim size we defined and print error if bigger $fsize=filesize($_FILES['document']['tmp_name']); if (($fsize/1024) > $poidsMax*1024) { $msgToUser = '<br /><br /><font color="#FF0000">You exceeded the filesize limit. Document did not get posted.</font>'; include_once 'msgToUser.php'; $errors=1; } if(isAllowedExtension($HTTP_POST_FILES['document']['tmp_name'])) { if(copy($HTTP_POST_FILES['document']['tmp_name'], $path)){ //IF IT HAS BEEN COPIED... //GET FILE NAME $theFileName = $HTTP_POST_FILES['document']['name']; //GET FILE SIZE $theFileSize = $HTTP_POST_FILES['document']['size']; if ($theFileSize>999999){ //IF GREATER THAN 999KB, DISPLAY AS MB $theDiv = $theFileSize / 1000000; $theFileSize = round($theDiv, 1)." MB"; //round($WhatToRound, $DecimalPlaces) } else { //OTHERWISE DISPLAY AS KB $theDiv = $theFileSize / 1000; $theFileSize = round($theDiv, 1)." KB"; //round($WhatToRound, $DecimalPlaces) } } else { $msgToUser = '<br /><br /><font color="#FF0000">Ooops something went wrong.</font><p><a href="../index.php">Go Back</a></p>'; include_once 'msgToUser.php'; $errors=1; } } } $name = strip_tags($name, ''); $message = strip_tags($message, ''); $sql = mysql_query("INSERT INTO bulletin_board (posting_date, member_id, title, subject, picture, document) VALUES(now(),'$logOptions_id', '$name','$message', '$image_name', '$theFileName')") or die (mysql_error()); Marco I am having trouble getting my upload file to work... Form HTML: Code: [Select] <form action="" method="POST"> <input type="file" name="file" /> <input type='"submit" name="upload" value="Upload" /> </form> PHP: Code: [Select] if($_POST["upload_avatar"]){ $upload_path = "images/users/"; $file = $_FILES["file"]["name"]; $extension_types = array("gif","jpg","jpeg","png"); if($file){ $filename = stripslashes($_FILES["file"]["name"]); $extension = getExtension($filename); $extension = strtolower($extension); $size = filesize($_FILES["file"]["tmp_name"]); if(in_array($extension, $extension_types)){ if($size <= $max_file_size){ $file_search = glob($upload_path . strtolower($username) . '*'); array_map("unlink", $file_search); $file_name = $upload_path . strtolower($username) . "." . $extension; $copied = copy($_FILES["file"]["tmp_name"], $file_name); if (!$copied){ $r_error = "Upload has failed"; } } else{$r_error = "File too big";} } else{$r_error = "Unknown file extension";} } else{$r_error = "No file chosen";} } Every time, it gives me the "No File Chosen" error. It doesn't seem to be actually uploading the file... I hope this isn't just some stupid thing I am looking over, can someone help me? How do I write a bit of code to check if a file is NOT readable...and if (and only if) it is NOT readable (doesn't exist) , wget the file. Here's what I tried...but it loops forever and ever...even if the file does exist. Code: [Select] $filename = "file.mp3"; while(!is_readable($filename)) { $url = "domain.com" . ".mp3"; echo system('wget '.escapeshellcmd($url)); echo system('sleep 30'); } ?> I Googled...and couldn't find the correct syntax for IS NOT READABLE. Thanks! Hi, I have few files which i need to display in correct format and also save in db to use. My problem is here is my code: $file = "C:\\file.txt"; $data = file_get_contents($file); $data = '<pre>'; $data .= mb_convert_encoding($file, 'UTF-8', 'ISO-8859-1'); $data .= '</pre>'; echo $data; but when i echo $data i get weird characters . here is result http://paste2.org/p/1361878 Thanks for any help. I have 4 websites http://www.mercurymagazines.com/pr1/101/101395 http://www.mercurymagazines.com/pr1/169/16000 http://www.mercurymagazines.com/pr1/101/101396 http://www.mercurymagazines.com/pr1/169/16001 I am trying to write a program that will open each webpage one at a time, look for a unique word such as 'FREE' and if it is found the write the URL to a file, if not then no output and the next webpage is opened. I know this word exists only on one of the pages above (http://www.mercurymagazines.com/pr1/101/101396). When http://www.mercurymagazines.com/pr1/101/101396 appears last in the list located in source.txt the programs WORKS. When http://www.mercurymagazines.com/pr1/101/101396 appears in any other position such as first, or second, the program does NOT work. My head is sore from banging against my desk. Any assistance would be appreciated. <?php $file_source = fopen("source.txt", "r"); $file_target = fopen("targets.txt", "w"); while (!feof($file_source) ) { $url = fgets($file_source); echo '<br>'.$url; $raw_text = file_get_contents($url); mb_regex_encoding( "utf-8" ); $words = mb_split( ' +', $raw_text ); foreach ($words as $uniques) { echo $uniques; if ($uniques == 'FREE') { fwrite($file_target, $url); } } } ?> I forked a project from M. Schwartz in Adafruit about wifi controlled robot, and he uses local web server to access it. Now I wanted to the host online the server files. My only problem is this part of his php file
<?php // Load JSON state $string = file_get_contents("robot_state.json"); $json_a= json_decode($string,true); // Handle GET request $json_a['speed'] = $_GET["speed"]; $json_a['direction_left'] = $_GET["directionLeft"]; $json_a['direction_right'] = $_GET["directionRight"]; $json_a['reverse'] = $_GET["reverse"]; // Save JSON file $fp = fopen('robot_state.json', 'w'); fwrite($fp, json_encode($json_a)); fclose($fp); // Create a TCP/IP socket & connect to the server $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $result = socket_connect($socket, "192.168.1.6", "8888"); // Request $in = "HEAD / HTTP/1.1\r\n"; $in .= "Content-Type: text/html\r\n"; $in .= $json_a['speed'] . "," . $json_a['direction_left'] . "," . $json_a['direction_right'] . ",". $json_a['reverse'] . ",\r\n\r\n"; $out = ''; // Send request socket_write($socket, $in, strlen($in)); // Read answer while ($out = socket_read($socket, 4096)) { echo $out; } // Close socket socket_close($socket); ?>notice Line 19: socket_connect($socket, "192.168.1.6", "8888"); This is the part where it communicates to the wifi shield of the arduino. I know this simply wouldn't work now since this is only a private address and the files are now hosted in the internet. Can you guys teach me how to implement because I know this part of code will be quite different. Edited by PassingLurker, 17 October 2014 - 12:21 PM. Hello,
I have the following upload script that actually worked until I tried to add file type specifications. I can't figure out what I did wrong. I have been piecing things together so there is no telling what is wrong. Help me please?
<?php $fileName = $_FILES["file1"]["name"]; // The file name $fileTmpLoc = $_FILES["file1"]["tmp_name"]; // File in the PHP tmp folder $fileType = $_FILES["file1"]["type"]; // The type of file it is $fileSize = $_FILES["file1"]["size"]; // File size in bytes $fileErrorMsg = $_FILES["file1"]["error"]; // 0 for false... and 1 for true if (!$fileTmpLoc) { // if file not chosen echo "ERROR: Please browse for a file before clicking the upload button."; exit(); } if ($fileType=="image/png" || $fileType=="image/gif" || $fileType=="image/jpg") // checking file type echo "ERROR: Only file types .png, .gif or .jpg may be uploaded"; exit(); } if(move_uploaded_file($fileTmpLoc, "image_uploads/$fileName")){ echo "$fileName upload is complete"; } else { echo "move_uploaded_file function failed"; } ?>Thanks. Hi, I am using php to generate an xml file of the following structure Code: [Select] <?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: Code: [Select] 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: Code: [Select] 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. Hello Im trying to upload mp3s from a form. In the form I have the MAX_FILE_SIZE set at 90000000 (so big to make sure it wasn't my maths). I have checked with phpinfo() and the max upload is set at 8mb. The mp3s will be between 3-4mb in size. I have uploaded small mp3's successfully (440k) so i know the script is working fine, however when i try to upload one at around 3mb it fails, even tried different file sizes in the same ball park size. I suspect the server is blocking them. Any ideas on a fix? Thank you. No script posted as i say its all working. Hi, I am trying to insert the contents of a csv file into a table, this is my code: public function InsertCSVFileToDB(){ $has_title_row = true; $not_done = array(); if(is_uploaded_file($_FILES['csvfile']['tmp_name'])){ $filename = basename($_FILES['csvfile']['name']); if(substr($filename, -3) == 'csv'){ $tmpfile = $_FILES['csvfile']['tmp_name']; if (($fh = fopen($tmpfile, "r")) !== FALSE) { $i = 0; while (($items = fgetcsv($fh, 10000, ",")) !== FALSE) { if($has_title_row === true && $i == 0){ // skip the first row if there is a tile row in CSV file $i++; continue; } $sql = "INSERT INTO ConfPaper SET CPRid = ".$items[0].", Pid = ".$items[1].", CPtitle = '".mysql_real_escape_string($items[2])."', CPabstract = '".mysql_real_escape_string($items[3])."', CPspage = ".mysql_real_escape_string($items[4]).", CPepage = ".mysql_real_escape_string($items[5]).", CPlastesited = now()"; if(!mysql_query($sql)){ $not_done[] = $items; } $i++; } } // if there are any not done records found: if(!empty($not_done)){ echo "<strong>There are some records could not be inserted</strong><br />"; print_r($not_done); } } else{ die('Invalid file format uploaded. Please upload CSV.'); } } else{ die('Please upload a CSV file.'); } } This is the csv file: http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/ConfPaper.csv But i keep getting this: Quote Array ( => Array ( => 9 [1] => 1 [2] => CSV1 [3] => 4 [4] => 4 [5] => 01625 584412 ) [1] => Array ( => 9 [1] => 1 [2] => CSV2 [3] => 14 [4] => 24 [5] => 01625 584412 ) ) Any ideas what the problem might be? Hope someone can help.. Thanks |