Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. No, @ does 1 thing only.. omit errors.. Personally I don't use it, (unless its personal code and I'm being lazy)
  2. int (integer) is a whole number (no decimal points) ie 10 or 20 you want a float (floating point) ie 12.345 or 45.789 EDIT: MySQL numeric type overview
  3. you need to post some serialized data from your system directly after the input, then review anything you do that data (ie stripslashes) with that said, I find it bad practice to use serialize to store data in a database, I would normally create 2 more tables, one for the comments and one to link the comments to the user.
  4. Would need to see more code ie the form and the PHP where you set $text,
  5. 1. Welcome to PHPFreaks 2. please use code tags (#) 3. See comment <?php function confirm_query($result_set){ if (!$result_set) { die("Database query failed: " . mysql_error()); } } function get_all_subjects() { $query = "SELECT * FROM first_table ORDER BY position ASC" //<-- MISSING ; $subject_set = mysql_query($query, $connection); confirm_query($subject_set); return $subject_set; } function get_pages_for_subject($subject_id) { $query1 = "SELECT * FROM tablepages WHERE subject_id = {$subjects_id} ORDER BY position ASC"; $page_set = mysql_query($query1, $connection); confirm_query($page_set); return $page_set; } ?> 4. TIP: always check the lines above and below the error line
  6. In addition to salathe post, the RegEx is also is missing " "(space) ;(semi-colon) and -(hyphen), (and maybe a capture) Assuming the prefix is "> then you probably want this if (preg_match('/">([a-zA-Z0-9.:;,$\s-]*)<b>\.\.\./', $pointer->description,$result)) { echo $result[1]; //OR 0 }
  7. You could try adding a UTF-8 header to the file.. that will atleast make Excel prompt you for the correct format try adding fwrite($pfw_handle, "\xEF\xBB\xBF", 3); inside your if ($pfw_is_first_row) loop
  8. Oh i thought you wanted binary output, Here's two options, both should give the same results (untested) for ($n=0; $n < strlen($buf); $n++) { printf("%02s\r\n", dechex(ord($buf[$n]))); //printf("%02X\r\n", ord($buf[$n])); }
  9. Okay not been awake for long but shouldn't $checksum &= 0xff; be $checksum .= 0xff; and for ($n=0; $n < strlen($buf); $n++) { printf("%02X\r\n", $buf[$n]); } be for ($n=0; $n < strlen($buf); $n++) { printf("%02b\r\n", ord($buf[$n])); }
  10. endforeach; isn't needed, as all foreach'es already have opening { and a closing }
  11. But that block ends foreach($sets as $set) { $dbx= mysql_connect("localhost", "root", ""); //include before any database implematation if (!$dbx) { die('Could not connect: ' . mysql_error()); } mysql_SELECT_db("craigslist", $dbx); mysql_Query("INSERT INTO addresses (sale_items) VALUES ('$set')"); mysql_close($dbx); echo "Link = " . $set['link'] .", E-mail = " . $set['email'] . "<br/>"; }//<----------HERE--------
  12. What's block does the endforeach; at the end relate to ? to help you i have formatted the code (to make it more visible) <?php $links = fetch_links("http://southcoast.craigslist.org/sss/"); $sets = array(); foreach($links as $link) { $sets[] = fetch_email($link); } foreach($sets as $set) { $dbx= mysql_connect("localhost", "root", ""); //include before any database implematation if (!$dbx) { die('Could not connect: ' . mysql_error()); } mysql_SELECT_db("craigslist", $dbx); mysql_Query("INSERT INTO addresses (sale_items) VALUES ('$set')"); mysql_close($dbx); echo "Link = " . $set['link'] .", E-mail = " . $set['email'] . "<br/>"; } function fetch_links($page_url) { $pattern = '#<a href="(/[a-z]{3}/\d{10}\.html)">#'; $page = file_get_contents($page_url); preg_match_all($pattern, $page, $matches); return $matches[1]; } function fetch_email($page_link) { $pattern = '#(sale-[a-z0-9]+-\d+@craigslist\.org)#'; $page = file_get_contents("http://southcoast.craigslist.org" . $page_link); preg_match($pattern, $page, $out); return array('link'=>$page_link, 'email'=>$out[1]); } endforeach; ?>
  13. So like this [sOLVED by "MadTechie, Daniel0, RedArrow, Mchl, zanus, Crayon Violent, PugJr"]
  14. Meah,, no biggie, can you upload to an FTP/Host or something Or shorten it.. whatever is easiest
  15. http://www.parse-error-unexpected-t-string.com/
  16. How large is large ? can I see a copy (zipped or something)
  17. the problem is here mysql_Query("INSERT INTO addresses (sale_items) VALUES ('$set');
  18. Why not instead of deleting the line,, just don't write it to the new cleaned up file ie (untested) <?php $file=fopen($filename,"r"); $newFile = fopen('newfile.txt', 'w'); while(!feof($file)){ $line = fgets($file); $temparray = explode(" ",$line); $hadrequired = false; foreach($temparray as $result){ if($result == $required){ fwrite($newFile, $line); } } } fclose($newFile); fclose($file); ?>
  19. I don't see the point myself, personally if I solved 2 million topic's I would probably 2 million and 1 PM's asking for help (note that's against the rules), also it creates the problem where someone will post 200+ lines of code as a solution and miss a ; on a line, and the thread creator will say "it didn't work" and someone will point out the ; and probably get the credit for it.. and the 200+ line post won't feel very good about it! Your probably better off using a karma system.. But didn't we try that ?
  20. re-read, try this <?php $replaceall = array("female"=>"girl","male"=>"boy"); if (isset($_FILES['file'])) { $file = file_get_contents($_FILES['file']['tmp_name']); $submit = $_POST['submit']; if($file == "") echo "Error"; else { if($submit == "Submit" ) { if (($temp = zip_open($file))) { while ($entry = zip_read($temp)){ $file = zip_entry_name($entry); if(strtolower(substr($file, strrpos($file, '.')+1)) == "php"){ if (zip_entry_open($temp, $entry)) { $file2 = zip_entry_read($entry,zip_entry_filesize($entry)); foreach($replaceall as $find => $replace){ if(strpos($file2, $find) !== false){ echo str_replace($find,$replace,$file2); exit(); } } } } } zip_close($temp); } } } }
  21. What's the problem?
  22. You mean like match all ? do you have an example?
  23. ~Coughs @ cags~ * not + or articles/news/(\d+)[^\d]*$
  24. But that becomes part of the fun okay not always, however debugging is a very important skill to learn.. so maybe they are forcing it on you of course any problems you can always post for help I'm happy to help those who wish to learn.
×
×
  • 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.