Jump to content

kreut

Members
  • Posts

    99
  • Joined

  • Last visited

    Never

Everything posted by kreut

  1. Hello! A user is going to input a date in the form "mm/dd/yyyy". I'd like to convert this to a time stamp so that I can store it via MySql. I've heard about the "strtotime" function in PHP but I'm not sure how it can tell that the user 03/04/2011 represents March,4th 2011 and not, say April,3rd 2011 (European version). Help with the correct syntax for conversion would be greatly appreciated. Thank you, Eric
  2. Thanks for the quick AND easy solution.
  3. Hello, I'm trying to use php to have a user upload a file and then, have my site create a link --- I'm ALMOST there. My last hitch is in creating the link. From the code below, echo "this is the current filename: ". $supplemental_file; echo '<a href=../../supplemental_files/' . $supplemental_file . '">Supplementary Download</a>'; I get: this is the current filename: Complaint.doc But, when I hover over the link, I get: http://localhost:8888/algebra_book/supplemental_files/Complaint.doc%22 Any thoughts on the extra %22 ?? Thanks so much....
  4. Thank you both for your responses. To clarify, then, if I want to see if a particular form is sent in, I would check if that particular submit button "isset"; and if I want to see if a particular form item is not empty, I would then use if (!$variable_of_interest) --- would this be the standard way of checking these two form items?
  5. Hi! Can someone please tell me the logical difference between if (isset($_POST['add_text'])) { blah blah blah and if ($_POST['add_text']) { blah blah blah
  6. OK...I don't want to trouble you more on this. I'll dig into my code: maybe I am actually putting numbers into the other guys. Thanks again....
  7. Hmmmm.....that did the trick! (THANKS....) But, why? I have many other database queries on my site and this is the first time that I need the single quote. Could it be that all of the others are either $_POSTS or $_GETS. It's a bit of a mystery to me Any further clarification would be appreciated.
  8. Hello, I'm having some issues with PHP thinking that the variables that I send it are the actual columns in my database. First, I pull off Quadratic_Functions and introductory_problem from http://localhost:8888/algebra_book/Chapters/Quadratic_Functions/introductory_problem.php using the code below: $chapter_page = $_SERVER['PHP_SELF']; $chapter_page_array = explode('/',$chapter_page); $size =count($chapter_page_array); $chapter = $chapter_page_array[$size-2]; $page = $chapter_page_array[$size-1]; $page_array = explode('.', $page); $page = $page_array[0]; Based on my printing of the variables $chapter and $page I think that it's doing what I want it to do. I then use the following function: $supplemental_id = getSupplementalId($dbRead,$chapter,$page); to check out if the there's a supplemental_id for the Quadratic_Function chapter and introductory_problem page name via: function getSupplementalId($read,$user_id,$chapter,$page) { $sql = "SELECT supplemental_id FROM instructors_supplemental WHERE page_name = $page AND chapter_name='$chapter"; return $read->fetchRow($sql); } If I stick in actual values, as seen below, the thing runs fine. $sql = "SELECT supplemental_id FROM instructors_supplemental WHERE page_name = 'introductory_problem' AND chapter_name='Quadratic_Functions'"; But if I run it in the abstract version, with variables for page and chapter name (the first version), I get Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'introductory_problem' in 'where clause'' in... It's almost as if it thinks that my variables are the names of the columns. Any thoughts would be appreciated....
  9. That'll do it. Thanks so much!
  10. Hello, I was wondering if someone could help me to "get" the webaddress of a current webpage and then pull off pieces of the page. All of my pages look like: http://localhost:8888/algebra_book/Chapters/Quadratic_Functions/introductory_problem.php BUT, the stuff to the left of Quadratic Functions WILL change in the future. So all will look like: *Quadratic_Functions/introductory_problem.php Then, I'd like to pull off a $chapter variable, which in this case is Quadratic_Functions and a $page_name variable which in this case will be introductory_problem. Thanks so much.
  11. Thanks for the helpful info. It points me in the right direction!
  12. Hello! I'm using the Wyzz editor as part of a web application, allowing users to type in using a Wysiwig editor which will then print on the web page what they type. I'm wondering if there's a function in PHP which can tell if the text is "html" or the wysiwig stuff. In other words, if I'm in the text mode and I click on the bold icon, and I type: Hello how are you? ---- then it prints "Hello how are you." but if it's in the html mode, it and I type: <b>Hello how are you?</b> I'd LIKE it to be smart enough to spit out a bold Hello how are you. Instead, it gives me back <b>Hello how are you?</b>. So, might there be a version of the PHP echo which basically says "Hey, if it looks like an HTML tag let's treat it as such?" As you can see by my code below, I'm just using a PHP echo statement right now: <script language="JavaScript" type="text/javascript" src="../../js/wyzz.js"></script> <?php if (isset($_POST['insert'])) {echo $_POST['textfield'];} ?> <form action="" method="post"><textarea name="textfield" id="textfield" rows="10" cols="40"></textarea> <script language="javascript1.2"> make_wyzz('textfield'); </script> <input type="submit" name="insert" id="insert" value="Add Text" /> </form> Thank you for taking the time to read this.
  13. Hello! I'm working with dates in PHP for the first time and I've got a few questions. I'm using strtotime() to successfully convert my user's input (let's call her Sandy) into a specified date that they enter. My questions then are: 1) I'm going to put the strtotime() date into MySql -- are there any issues that one should be aware of (I seem to recall reading that dates can be tricky, depending on which database you use?) 2) The timestamp that I put into MySql will periodically be tested against the local time of users who live in the same timezone as Sandy, though Sandy may not live in my timezone. My question then, is whether there's a "local timestamp" function in PHP that can compare Sandy's entered timestamp, that will reside in my database, to specific users' local timestamps. Thanks so much...
  14. Hello all, I'm collecting date/time information via a form and would like to convert the info into something that I can stick in my MySql database (a timestamp???). I'm collecting the current month (variable name: month-- of the form "mm"), day (variable name: day -- of the form "dd"), year (variable name: year -- of the form "yyyy"), time of day (variable name: time -- of the form "h:00"), and before or after noon (variable name: ampm -- of the form "am" or "pm"). Any suggestions as to how to change this into a quantity that I can store as a value and then use to compare to other date/times would be appreciated. Thanks!
  15. kreut

    Zend Date

    Hello! I'm trying to use Zend_Date (first time) as part of a website that will require users from different timezones to enter a date and time(some date in the future, say June 5th, 2013 10:00am). I'll store this in my MySql database and then later on use it to compare it against the current date for users in those particular timezones. Once the "future date" has passed, my program will take some action. A little help would be appreciated. Right now, I have the incredible start of date_default_timezone_set('America/Los_Angeles'): $Now_date = new Zend_date; $now_date->getTimestamp(); I THINK that the above code sets things up for any timezone. I guess I need help with the format of the "future" date that gets stored in the database and then how to compare it to the $now_date. Any help even getting started would be most appreciated. -Thank you
  16. Hello, I'm using PHP to pull off some info from my database. I wind up with a variable called $question_type. I'd then like to use this variable in a javascript (jquery) function. (I'm going to only show a section of the page with $question_type as my id). My question is can these two languages be combined? In otherwords, if I'd like to create a jquery function Show($question_type) where the Show function is in jquery and the variable is from PHP. I WOULD do this in php, but there's a ton of html for each question_type section so I think that it would be much cleaner using jquery (though a clean php solution would be more than acceptable!) Thanks...
  17. Thank you both! First, for telling me about the html error...and second to PaulRyan for showing me a much "cleaner" approach. Enjoy your days...
  18. Hello, I'm trying to create a sticky form using: <input name="assignment_name" type = "text" id="assignment_name" <?php if ($_POST && $errors) { echo "value =" . htmlentities($_POST['assignment_name'], ENT_COMPAT, 'UTF-8'); } else {echo "value = $assignment_name";} ?> /></text> It works if my assignment name is one word; if it's multiple words, it only produces the first word. Any thoughts would be appreciated. Thank you...
  19. Thanks! Your SQL statement really helped me see what I needed to do...
  20. Yes, I fear that they are from a database query. My original thought (and cleaner?) was to try this: SELECT * FROM questions LEFT JOIN assignments_questions USING (question_id) WHERE ((questions.author_id = $user_id) AND (assignments_questions.question_id = NULL)) But....for the life of my I can't figure out why it's not working (I get nothing out!). IF you happen to see the error of my ways, a database solution would definitely be preferable. However, the code the you sent me is helpful as well.
  21. Sure! The first is from my $questions array will the second is from my $assignments_questions array: [8] => Array ( [question_id] => 11 [author_id] => 3 [section_id] => 0 [text] => What do you think of pizza? [solution] => I love it [incorrect_solution1] => [incorrect_solution2] => [incorrect_solution3] => [solution_order] => [filename] => no_pic.png [question_type] => Free Response [public_access] => Yes ) ) Array ( [0] => Array ( [question_id] => 2 [author_id] => 1 [section_id] => 0 [text] => What's 3 +5? [solution] => 8 [incorrect_solution1] => 1 [incorrect_solution2] => 2 [incorrect_solution3] => 5 [solution_order] => 0231 [filename] => no_pic.png [question_type] => Multiple Choice [public_access] => No [assignment_id] => 1 )
  22. Hello, I have two arrays: $questions, which has 'question_id' as one of its keys and $assignment_questions which is a subset of $questions, pulled off my database. Using php, I'd like to construct a 3rd array which takes my $questions array and removes from it any question that has a question_id which can be found in both $questions and $assignment_questions, in addition to the other values associated with a particular question_id. For example, $questions has: question_id, solution, author (and other keys). Is there any way to check if a particular key matches and then zap out all of the corresponding fields (solution, author, etc.)? Thanks!
  23. Thank you for the quick response... In my questions table I have (you can create a new question without yet putting it to an assignment): question_id (index) user_id (the user_id is the person who wrote it) In my assignments table I have all of the assignments for a given course: course_id (index) assignment_id ---once you create a course, you can create an assignment (with or without questions). Once you add the first question to an assignment, it will appear on the assignments_questions table In my assignments_questions, you can create a new assignment : assignment_id (index) question_id (once an assignment is created, questions can be added to it) If a question hasn't been assigned, it doesn't yet exist in the assignments_questions table. Please let me know if there's anything else that I can clear up...
×
×
  • 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.