Jump to content

kreut

Members
  • Posts

    99
  • Joined

  • Last visited

    Never

Everything posted by kreut

  1. Hello, I'm trying to sanitize user input and have been banging my head over HTMLpurifier the last several days (some weird encoding issues). So...I decided to try out HTMLawed. Using the following code: require_once('htmLawed/htmLawed.php'); $text ='<script type="text/javascript">This is bad stuff</script><p>hello how are < you?'; $out = htmLawed($text); echo $out; I would think that it would get rid of my javascript. But, in the browser $text looked exactly the same. This is such a newbie question that I'm embarrassed to ask it as the HTMLawed documentation "looked" great. Can someone please explain the error of my ways? Thanks so much, Eric
  2. Hello! I'm using MAMP version 1.9.4 which has PHP 5.3.2 on it. However, I'd like to use version PHP 5.3.6 instead so that I can match my production version PHP. Has anyone installed a new version of PHP with their MAMP? Thank you, Eric
  3. Hello! I'm trying to understand exactly how http requests relate to a php script. 1) What would be considered a large amount? 2) How can I see how many I have for a given page? Thank you, Eric
  4. Hmmm..I'm not sure what you mean by "skip the grants". If it helps, the exact error that I get is: "DROP command denied to user 'root'@'localhost' for table 'examples'" Isn't this saying that as a root user I don't have the access? This doesn't really make sense to be because I thought that the root user was the "superuser". If you could clarify your answer, I'd appreciate it. Thanks! -Eric
  5. Hello! Somehow (as if by magic...) I changed my local testing environment MAMP root permissions so that I could no longer DROP tables. Well, now I'd like to DROP tables, but it won't let me change my root user (permission denied/password needed). Since I'm not asked for a password in the first place I'm not quite sure how to do this, nor what password to use. Any help would be appreciated...I'd hate to have to reinstall it all. Thanks so much, Eric
  6. Thanks so much for your help! This seems way better than using reCaptcha from a customer service point of view. Why doesn't everyone do it this way? -Eric
  7. Thanks for responding to my post. To detect logged in members I'm using the Zend_Auth adapter with hasIdentity() to see if a user is correctly logged in and is of the appropriate user type; this is after they log in using Zend_Auth in conjunction with matching the credentials to my database using Zend_Auth_Adapter_DbTable. And, from what you said on your post, it sounds like the idea of dynamically generating a mathematical question then outputting it as an image could be an alternative to using Captcha ---do I understand you correctly? I feel pretty comfortable with php but have never output text as an image. Might you have a resource that could get me started?
  8. Thanks for the response! But, can they get to things INSIDE my site? In other words, let's say a user has to register --AND PAY-- to use my site. Once in the site, they have a "Send me comments form". Could the spammer spam that if the "Send me comments form" is only accessible to paying users? Thanks again....
  9. Hello, I'm currently using Captcha as a means to prevent Spam on my website for user's comments in a "Contact Us" form. The more I think about it, the more I wonder why the heck I'd use such a difficult to read (annoying?) method as opposed to something like: Create a php script that generates two random numbers between 1 and 10 (x and y). Ask the user "Please prove you're human by telling me the sum of x and y.". If they don't, then the form won't be submitted. Also, I feel like I don't even really understand exactly HOW someone can spam my site: if, for example, there's an email form within my site on a secure page (in other words, after the user logs in), would a spamster be able to get to that? Thank you, Eric
  10. Hello, I began programming several months ago with PHP and am beginning to feel comfortable with the programming aspect (it's the first language I've used). I'm now looking into optimizing my website and have found CloudFlare to (easily) use to cache my javascript/css files. I've now learned that I can use APC to do the same thing with my php files. But, this is uncharted territory, and I feel a bit of a noob. But, you've got to start somewhere! 1. By APC "caching unchanging php files", what does this mean exactly? For example, my understanding would be that if I have a php script that defines functions, that this would be cached since the script won't change. However, in another script that dynamically generates variables, would the script itself sans the changing variables be cached as well? And does "caching" the script mean that 1 user who visits multiple times won't have the script recompiled? Or, once cached, any user who uses that script will use the cached version? Seems a bit like withcraft at this point. 2. This article: http://www.debian-administration.org/articles/574 made it seem "simple" to install --- that is, except for someone who doesn't know how to get to the "input screen". (I do have cPanel and have the option to install Pear packages, but never have done so). If someone could help pull away the curtain of the behind the scenes world of APC, I'd appreciate it! Thank you, Eric
  11. Hello, I'm using: header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"$filename\""); to download a file from my server. After this happens, I'd like to use header("Location:/index.php") to redirect the user. I'm finding that if I add in the redirect, then this is the only thing that it does (in other words it executes the last header). Is there anyway to have two headers which do 2 different things, namely download and then redirect? Thanks so much, Eric
  12. Hello! Thanks to everyone's suggestions, I've almost found my solution. Basically, I took my array and transformed it into a ";" delimeter format. As you can see from the output below, it ALMOST works. I say almost, because the first column on each row is a little "wacky": notice that Name has no quotes around it and the there's a quote at the end of each line as opposed to being part of the next line. The net result is that in excel, all columns look great, but the first column looks like: Name Student, Perfect" Brown, Justina " school, home" school, home" Any additional thoughts on how to fix the first column would be appreciated. Thanks again.... -Eric $fp = fopen('filetest.csv', 'w') or die("can't open file"); //write to a file $output = ''; //start with blank output foreach ($list as $fields) { $new_array =array(); foreach ($fields as $key => $value) { array_push($new_array,$value); } foreach($new_array as $line){ $output .=$line.'|'; /separate each element in the array } $output .="\n"; /start a new line } $output = explode("|",$output); fputcsv($fp, $output,';'); //use the semicolon delimeter Name;"Types of Real Numbers";"Variables and Equations";"The Number Line and Graphs";Functions;"Review of The Language of Algebra";"Quiz #1 ";"Tables, Equations, and Graphs";"The Slope and y-intercept of a line";"Standard Form of a Line";"Linear Inequalities";"Solving Linear Systems of Equations";"Parallel and Perpendicular Lines";"Review of Linear Relationships";"Quiz #2";"Distance From the Origin";"Distance Between Two Points";"Absolute Value Inequalities";Total;" Student, Perfect";100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;100%;" Brown, Justina ";0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;" school, home";0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;" school, home";0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;" "
  13. Still no file..no error...but now I have this output: int(470) int(109) int(126) int(123) int(123) Was this part of error checking? PS I definitely would like the CSV output to keep possibilities open.
  14. Something like this would be great: Name,Types of Real Numbers| Variables and Equations| The Number Line and Graphs| Functions Student, Perfect| 100%|100%|100%| 100% The ultimate goal is to create this file, then download to a users computer so that they can import it into excel for example. -Eric
  15. Thanks for the quick response! I had already tried printing errors, but I fear that there weren't any (though I tried again for good measure). Also, I created a new array of arrays because the original data was of the form: $array[j] ...in other words, I wanted to separate out the data by rows. Maybe this is where the problem is? -Eric
  16. Hello, I'm trying to write a CSV file to my server but I neither get a file nor any error. The code is as follows: $fp = fopen('filetest.csv', 'w') or die("can't open file"); //write to a file foreach ($list as $fields) { $new_array =array(); foreach ($fields as $key => $value) { array_push($new_array,$value); } echo print_r($new_array); fputcsv($fp, $new_array); } I stuck the echo print_r($new_array); in there so that you could see what my array looks like. Below is part of the ouput: Array ( [0] => Name [1] => Types of Real Numbers [2] => Variables and Equations [3] => The Number Line and Graphs [4] => Functions ) 1Array ( [0] => Student, Perfect [1] => 100% [2] => 100% [3] => 100% [4] => 100% ) Any help would be appreciated. Thank you, Eric
  17. Thanks so much to both of you! -Eric
  18. Hello! Is it possible to reverse sort an array by looking at specific values if the array is multi-dimensional? Array ( [0] => Array ( [question_id] => 34 [ratio] => .2 ) [1] => Array ( [question_id] => 45 [ratio] => .7 ) [2] => Array ( [question_id] => 51 [ratio] => 1 ) [3] => Array ( [question_id] => 55 [ratio] => 0.5 ) [4] => Array ( [question_id] => 57 [ratio] => 0 ) ) For example, if I wanted to reverse sort by ratio, the new array of arrays should be: Array ( [0] => Array ( [question_id] => 51 [ratio] => 1 ) [1] => Array ( [question_id] => 45 [ratio] => .7 ) [2] => Array ( [question_id] => 55 [ratio] => 0.5 ) [3] => Array ( [question_id] => 34 [ratio] => .2 ) [4] => Array ( [question_id] => 57 [ratio] => 0 ) ) Thanks! -Eric
  19. Somehow it didn't like "wrong_answers.COUNT(*)"....however, in the interim I solved the problem with a less clean approach. Basically, I used SQL to grab off records which showed me question id's, solutions, and submitted solutions. I then used PHP to run through the array, group by question id, and compute the ratios. It would have been nice to solve this all with SQL (I do think that it was possible!)...but with other fish to fry, I'd like to consider this post close. Thanks to all who responded. -Eric
  20. Thanks for the quick response! I've played around with it a bit, but I fear that my syntax still isn't correct. Basically, I'm looking to count "incorrectly submitted homework answers" from a class at the question level, and then count the number of total submitted answers at the question level. Dividing the two at the question level will give me a summary of results for a particular class. This is what I have so far: SELECT questions.question_id, wrong_answers.COUNT(*) AS number_incorrect, total_submitted.COUNT(*) AS number_submitted, (number_incorrect/number_submitted) AS Ratio //using the counts from below, compute the ratio of wrong answers FROM questions AS wrong_answers INNER JOIN submitted_homework ON questions.question_id = submitted_homework.question_id WHERE ((questions.solution <> submitted_homework.submitted_solution) AND submitted_homework.assignment_id = 15) GROUP by questions.question_id ///get all of the wrongly submitted answers INNER JOIN submitted_homework AS total_submitted WHERE assignment_id =15 //get the total number of submitted questions GROUP by total_submitted.question_id However, I fear, that even line 1 gives by an error. Any additional advice would be appreciated.
  21. Hello! I was wondering if it's possible to do mathematical operations on entire columns using Sql. The idea: SELECT COUNT1 FROM Table A, COUNT2 FROM Table B, return COUNT1/COUNT2 Basically I'd like to create an array of "COUNT1/COUNT2" before going back to the world of PHP. Thank you, Eric
  22. Hello, Using the following code, I'm extracting the $current_solution from my database. However, if the variable has quotes in it, I get gobbledegook. <input type ="radio" name="solution" <?php echo 'value="' . $current_solution . '"' ?> id="solution" <?php if ($row['solution'] == $current_solution) {echo 'checked = "yes"';} ?>/><?php echo$current_solution; ?></label> As an example, if the $current_solution variable is: A right-side up letter u then I get: " id="solution" checked = "yes"/> A right-side up letter "u". I know that it's a quote issue but am not sure how to fix it. I tried adding slashes but I fear that it didn't work. Any thoughts on this would be appreciated! Thanks so much, Eric
  23. kreut

    strtotime

    Thank you for the response. I am actually using the datepicker; my question is how does php know which form I'm using if I do strtotime using php to turn it into a timestamp?
×
×
  • 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.