Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. The key operation there is #3. If #3 succeeds, then you've got your new key and no-one else can have it. So you may be able to get away without transactions. From what I understand of ODBC (ref: http://msdn2.microsoft.com/en-us/library/aa198023(SQL.80).aspx ), you must switch autocommit off to start a transaction. Then, when your work is finished, you call the odbc_commit() function. So. odbc_autocommit($conn, false); # do your stuff odbc_commit($conn); But this is all pure speculation, I am by no means an odbc expert. Test it first!
  2. No curl should be fine. You can connect to the database directly from the php script called from cron. Much like the example in your original post. I can't give you a detailed example as I'm not too sure about your database setup. But it really is as simple as your example there. Just connect to the database and do the update.
  3. Is the "Mysql Said:" showing you the output of mysql_error()? I don't see it in your code.
  4. I suggest the following simpler code: <?php $pup = ""; $adult = ""; $trained = ""; $stud = ""; $rescue = ""; foreach($_POST['chkActivities'] AS $activity) { switch ($activity) { case 'Doberman Puppies': $pup = "checked"; break; case 'Adult Dobermans': $adult = "checked"; break; case 'Trained Dobermans': $trained = "checked"; break; case 'Stud Service': $stud = "checked"; break; case 'Doberman Rescue': $rescue = "checked"; break; } } if (isset($_POST['chkActivities'])) {foreach($_POST['chkActivities'] AS $activity) echo $activity . '<br />';} ?> <form name='form1' id='form1' enctype='multipart/form-data' action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "post" > <input type='checkbox' name='chkActivities[]' value='Doberman Puppies' <?php echo $pup; ?> /><label>Doberman Puppies</label><br /> <input type='checkbox' name='chkActivities[]' value='Adult Dobermans' <?php echo $adult; ?> /><label>Adult Dobermans</label><br /> <input type='checkbox' name='chkActivities[]' value='Trained Dobermans' <?php echo $trained; ?> /><label>Trained Dobermans</label><br /> <input type='checkbox' name='chkActivities[]' value='Stud Service' <?php echo $stud; ?> /><label>Stud Service</label><br /> <input type='checkbox' name='chkActivities[]' value='Doberman Rescue' <?php echo $rescue; ?> /><label>Doberman Rescue</label><br /> <input type='submit' name='submit' value='Next ->' /> </form> <p>print_r($_POST['chkActivities']) produces this:</p> <?php print_r($_POST['chkActivities']) ?> I do not know where the error was, but the code above works for me.
  5. Here are some examples: http://en.wikipedia.org/wiki/Crontab#Examples In your case, something like: 0,10,20,30,40,50 * * * * /home/users/uwannadonkey/add_energy.php That will run at 0, 10,20,30,40 and 50 minutes past each hour, every hour
  6. Why is your query 3,716 Kbytes?
  7. Does it work without using odbc_commit()? If yes, then you don't need to worry about it
  8. btherl

    Possible?

    Hmm.. Do you want all these form submissions to go back to your script, even though it's using a different name? I still don't get what you are trying to do.
  9. Sounds great! Checking the db is the best solution.
  10. btherl

    Possible?

    You want to generate new scripts based on form input? It's certainly possible, but I can't imagine any situation in which that would be the best option. Is there any problem with deciding which code to run based on a form variables, like so: if ($_REQUEST['form_name'] === 'jan report') { # Do jan reports stuff } elseif ($_REQUESt['form_name'] === 'yearly report') { # Do yearly report stuff }
  11. Please explain in more detail what "It doesn't work" means. As halofreek said, unset() does NOT work across refreshes (the exception being session variables). If you explain what you want to do, then we can suggest an alternative.
  12. In your latest code, you have just this: $pup; $adult; $trained; $stud; $rescue; Which is different from what you posted in your original post: $pup = ''; $adult = ''; $trained = ''; $stud = ''; $rescue = ''; The code in your original post is correct. However, it must come before you include your form. Is your form "breeder-form.php" ? If so, you must set the values of $pup and so on before you include that form. In case this is what's confusing you, it doesn't matter that the function popActivities() is defined after $pup is defined. What matter is that $pup is defined before popActivities() is called, which is where your form is included.
  13. A big part of document retrieval is indexing. And a key advantage MySQL has over files is that it has built in indexing capabilities, even for full text searching. For that reason alone, I would choose MySQL, even if you can squeeze a bit more speed out of using plain files (and there's no guarantees that you can).
  14. That warning means your query ($querie) is empty. Check its value before passing it to verificaSelects()
  15. Can you please post your full code? I can't see anything wrong with what you've posted, so I suspect the problem is in how you put the parts together. PS, the HTML for a checked checkbox is just "checked", not "checked='checked'". So your code can be simplified to: $pup = "checked";
  16. The ampersands demonstrate how to use references when passing arguments as arrays. If you don't use references, you don't need to worry about them Just use the "bob" line for all your variables. If you do want references, the "bill" line in the example demonstrates that you must take a reference in two places for it to be effective. If you remove either one, then you will not get a reference back to the original variable.
  17. You can do this: function foo($args) { $bob = $args['bob']; $bill = &$args['bill']; } foo(array( 'bob' => 'hello', 'bill' => &$bubbles, )); Named arguments make life sooo much easier
  18. Try this: <?php $name = $_POST['rsname']; $url = "http://hiscore.runescape.com/index_lite.ws?player=$name" ; $fp = @fopen ($url, 'r') or die ('<font color="red"><center>ERROR</font><br/><font color="white">cannot access highscores</center></font>'); while ($read = fgetcsv ($fp, 1024)) { print_r($read); } fclose($fp); ?> Note that the second argument to fgetcsv() only became optional in PHP5.
  19. The url you are trying to access gives 404 not found for me.
  20. Hmm, I'm a little confused by what you are saying. But I'm pretty sure that sessions will help. Try the following: <?php session_start(); print "Old value was " . $_SESSION['var'] . "<br>"; $_SESSION['var'] = $_GET['var']; print "New value is " . $_SESSION['var']; ?> <form action="" method=get> <input name=var type=text value="<?php echo $_SESSION['var']; ?>"> <input name=Submit type=Submit value=Submit> </form> When you use session_start(), all variables inside $_SESSION are remembered until the user closes the browser (at least with default configurations)
  21. Agreed, it is difficult to find things like that in the documentation. You can test if the variables are arrays as part of your validation.
  22. The script is trying to open templates/main.html, but it isn't allowed to. Is this a script you installed or a script you wrote?
  23. Sounds like a good idea Go for it!
  24. A side note here - if an object is in scope (which includes all objects at the top level), then it will not be garbage collected automatically. It must be unset if you want to recover memory for use later in the current request. But if it's gone out of scope (for example, it was created inside a function and no references escaped to outside the function) then it will be GC'd automatically. All data is freed at the end of the request. Sessions are serialized and stored on disk for the next request to find. I can't answer your question about echoing within a destructor, sorry. But I expect it would be possible, for debugging purposes.
×
×
  • 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.