Jump to content

davidannis

Members
  • Posts

    627
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by davidannis

  1. I am wondering if there is an easier / better way to keep my development and test databases in synch.

     

    When I develop, I may add tables or fields to existing tables. When I upload from the development server to the test server I can check and make sure that I include all of the programs that I have edited by using the filesystems last modified date. However, I keep track of new and changed tables in MYSQL manually. Is there an easy way, that I am just missing, to see last modified dates for tables within a db? Is there some other strategy I should be using. I hate missing a table and having the test server give errors on code I debugged once on the development server.

  2. Putting it like that it sounds like a near impossible task...specially with languages ever growing...but that you for your example...any solutions and where one would go from here?...just use Google translate?

    Google, Microsoft, and a number of other companies offer translation APIs if you want to integrate to your own application. Just google "translation API" and you'll get a list. If you just want something as an end user, just use Google translate.

  3. your last posted code doesn't have any mail() statement in it, so, there's no way it can send an email. i recommend reviewing your code to make sure it is doing what you expect.

     

     

    @davidannis, a header() redirect has no problem using url's with parameters. if you had a case where it didn't work, i can list more than six reasons why. and afaik, the lack of a space isn't a problem (just tested.)

    The problem is not that a header has a problem supporting parameters but that the OP tried to set the value of $s by sending the program from contact.php to contact.php?s=1 and then adding $s=$_GET['s']. Since he did that he lost all of the other parameters. If he added all the other parameters to the header he could have set $s that way but it is a horribly inefficient way to set a value because (among other issues) it requires a round trip from server to browser.

     

    I believe that I have had a problem with spacing in a header, the manual page shows a space, and a quick Google shows others who share the concern though it seems to work in most cases if the space is omitted. The spec says that there is supposed to be at least one space before the value http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

  4. My favourite example of this is:

     

    Time flies like an arrow

    Fruit flies like a banana

    I couldn't remember the quote when I first posted here, but this is my favorite complex English sentence with one word used multiple times:

     

    The faith she had had had had no effect on her chances of entering heaven.

    Apparently you can have 11 hads: https://en.wikipedia.org/wiki/James_while_John_had_had_had_had_had_had_had_had_had_had_had_a_better_effect_on_the_teacher

  5. the problem with Google translate I.find it's pretty crap...due to some of the times words don't translate correctly.

    Yes, but that is state of the art, what a group of really good engineers achieved with a ton of computers, huge databases of language samples, and constant feedback from users offering better translation. It is not likely that as an individual you'll do as well.

  6. It is complicated. Very complicated. Try translate.google.com.

     

    You can't just replace words. Word order changes. Words can mean different things in different contexts. "I read the book last week" and "I read books every day" both have read in them but the tense is different. Root the seedling, root for your team, and the root cause would need 3 different translations of root. Idioms are also a challenge. "You are the apple of my eye." I'm trying to teach Japanese via the web now and grammar is the hardest part. You can look at my beta site http://japaneselearningsite.com. Not a lot there yet, but it is coming.

  7. You need a space after Location: on this line

     header	("Location:contact.php?s=2");
    

    and a die(); after you print the header because you don't want the rest of the script to execute.

     

    Wait, if you go back to your own script with these headers you lose all of your data. instead of doing this just set a variable $myvariable=1 or $myvariable=2 then use that variable instead of $_GET['s']

  8. I guess that having been here over a year, with over 500 posts I should have done this long ago. I've never really been a great coder but I really enjoy application design and project management. The code I write is not elegant, but it gets the job done. My programming experience and career is detailed in my profile so I won't rehash it here but I wanted to add a few personal details: I write as a sideline and hobby -- mainly business valuation software but I do projects for fun, my own use, or as a volunteer for non-profits. I have a wife and three wonderful boys. I'm interested in education and like kids so I coach chess, math, and organize a science fair. I am also interested in language and require that each of my children learn a foreign language (They chose Japanese, Greek, and Chinese). Lately in my spare time I have been working on a website to teach Japanese. I just put the first two modules in Beta (originally it was going to be one module but mission creep has 7 more on the to do list).

     

    Finally, I'd like to thank all of the people who have helped me as I've learned here. I'm not done yet and hope to give back as much help as I've received.

  9. Welcome to phpfreaks. If you are looking to volunteer as a way to practice coding you might try putting a post in the freelancers sections offering to do small projects for non-profits. I got some interesting projects to work on that way.

  10. I have also tried entering the data by JSON like {'page':0, ;'name': Zack} which works however I don't know how and if this can be made dynamic with the GET or POST data.

     

    You have an example of the data being dynamic in your original script.

    $("#results").load("fetch_data.php", {'page':(page_num-1)}, function(){
    
    		});
    

    page_num is a variable. Not sure what you are trying to pass but that may help.

  11. Just a guess but looks like you are sending POST data.

    $page_number = filter_var($_POST["page"],
    

    Add it here and look in $_POST

    $("#results").load("fetch_data.php", {'page':(page_num-1)}, function(){
    
    		});
    
  12. I have 5 tables that I changed on my development server (laptop) that I'd like to upload to my test server. I can export just those tables from PhpMyAdmin but on import it drops all of the other tables first. Short of editing the SQL before I upload it (finding the drop and deleting it) is there an easy way to uncheck a box and change that behavior that I am just not seeing?

  13. One last suggestion - when any field gives an error condition set a flag $error_flag=true. Then at the end you can do this:

    if (!$error_flag){
    //write to database, say thank you, go to next step...
    }else{
    //redisplay the page with error messages.
    }
    

    The way that you have the page set up now you will need to check to see if every fields error message is blank and then remember to add each field to the if when you add new fiedls to the form.

     

    Also, note that with your current code you will get a lot of red *s because they display even if the page has no errors.

  14. First thing that I see is that you are assigning the country code to the variable you used for Name and the same variable for both errors. Do the other errors display?

     } else {
    $name = test_input($_POST["country"]);
    

    Also, you are using UTF8 to allow accented characters (I assume from the country codes and then not allowing them with the preg match that you use to validate the name.

     

    Still looking

  15. $query="UPDATE balances SET balance = balance - $amount WHERE user-id='$from_id'";
    $result= mysqli_query($link,$query);
    if (!$result){
    //error handling here
    }
    $query="UPDATE balances SET balance = balance + $amount WHERE user-id='$to_id'";$result= mysqli_query($link,$query);
    $result= mysqli_query($link,$query);
    if (!$result){
    //error handling here
    }
    $query="INSERT INTO transactions ('from_id', 'to_id', 'amount) VALUES ('$from_id', '$to_id', $amount)"; 
    $result= mysqli_query($link,$query);
    if (!$result){
    //error handling here
    }
    
    

    You'll need to add timestamps, etc. I'm assuming you're using MySQL. You need a lot more specifications to make this meaningful. Might want to check that they have the money in their account first unless you offer unlimited overdrafts.

  16. I think that this works:

    UPDATE leitner_vcard_boxes SET box = ( box +1 ) ,
    last_reboxed_date = CURDATE( ) WHERE box <7 AND (
    last_reboxed_date < DATE_SUB( CURDATE( ) , INTERVAL 7 DAY ) AND (
    right_count / ( right_count + wrong_count )
    ) <= '25'
    ) OR (
    last_reboxed_date < DATE_SUB( CURDATE( ) , INTERVAL 14 DAY ) AND (
    right_count / ( right_count + wrong_count )
    ) <= '50'
    ) OR (
    last_reboxed_date < DATE_SUB( CURDATE( ) , INTERVAL 28 DAY ) AND (
    right_count / ( right_count + wrong_count )
    ) <= '75'
    ) OR (
    last_reboxed_date < DATE_SUB( CURDATE( ) , INTERVAL 40 DAY ) AND (
    right_count / ( right_count + wrong_count )
    ) <= '90'
    )
    

    and I should be able to assemble the query in PHP.

     

    Edit: Looks like you already showed me that in post #4. I skipped straight to 5. Thanks for your patience and assistance.

  17. That is what I was hoping for, a single query that I can execute so I'm not looping through mysql queries but something is still wrong, when I execute the query you provided in PHPMyAdmin I get

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASE' at line 19
    

    If I echo $query from the php code and paste it in I get a similar error.

  18. Earlier I posted about how to best deal with a calculated field in MySQL and was advised not to store the value in the database. So, I took my calculated value out of the tables. I can select based on the calculated value

    SELECT ... right_count, wrong_count, right_count + wrong_count AS Total_Count, 
    right_count / (right_count + wrong_count) AS Right_Percent
    ...
    

    but now I want to UPDATE based on Right_Percent. The old code was:

    UPDATE leitner_vcard_boxes 
    SET box=box+1 last_reboxed_date='$today' where box<7 
    AND last_reboxed_date<'$cutoff_date' and right_percent<='$score'
    

    The only way I can think of updating is something like:

    UPDATE leitner_vcard_boxes SET box=box+1 last_reboxed_date='$today' 
    WHERE box<7 and last_reboxed_date<'$cutoff_date' 
    AND Right_Percent IN (SELECT right_count, wrong_count, right_count / (right_count + wrong_count) AS Right_Percent 
    FROM leitner_vcard_boxes WHERE Right_Percent,='$score');
    

    Will using a subquery even work? Is there a better way?

     

    To further complicate things, I loop through 5 score/cutoff date pairs (so that a lower score gets reboxed faster than a higher score). I imagine it would be more efficient to try to combine it all into a single query.

         $cutoff_scores=array(25=>7,50=>14,75=>28,90=>40);
        foreach ($cutoff_scores as $score => $rebox_interval){
            $today=date('Y-m-d');
            $interval=$rebox_interval.' days';
            $cutoff_date=date_sub($today, date_interval_create_from_date_string($interval));
            $query="UPDATE leitner_vcard_boxes SET box=box+1 last_reboxed_date='$today' where box<7 and last_reboxed_date<'$cutoff_date' and right_percent<='$score'";
            $result=  mysqli_query($link, $interval);
        }
    
×
×
  • 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.