-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
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.
-
Would need to see more code ie the form and the PHP where you set $text,
-
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
-
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
-
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])); }
-
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])); }
-
[SOLVED] Do You See a Syntax Error in this One Line of Code?
MadTechie replied to Modernvox's topic in PHP Coding Help
endforeach; isn't needed, as all foreach'es already have opening { and a closing } -
[SOLVED] Do You See a Syntax Error in this One Line of Code?
MadTechie replied to Modernvox's topic in PHP Coding Help
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-------- -
[SOLVED] Do You See a Syntax Error in this One Line of Code?
MadTechie replied to Modernvox's topic in PHP Coding Help
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; ?> -
So like this [sOLVED by "MadTechie, Daniel0, RedArrow, Mchl, zanus, Crayon Violent, PugJr"]
-
[SOLVED] Do You See a Syntax Error in this One Line of Code?
MadTechie replied to Modernvox's topic in PHP Coding Help
http://www.parse-error-unexpected-t-string.com/ -
[SOLVED] Do You See a Syntax Error in this One Line of Code?
MadTechie replied to Modernvox's topic in PHP Coding Help
the problem is here mysql_Query("INSERT INTO addresses (sale_items) VALUES ('$set'); -
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); ?>
-
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 ?
-
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); } } } }
-
What's the problem?
-
There MIGHT be a hyphen after this number...help?
MadTechie replied to br3nn4n's topic in Regex Help
~Coughs @ cags~ * not + or articles/news/(\d+)[^\d]*$ -
O'Reilly Tutorial Script Help - poor girl can't figure it out!
MadTechie replied to saireuh's topic in Third Party Scripts
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.