Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. I often do this: // Printer type $ret = snmp2_get($printers[$x]['name'], $community, $standard_printer_variables['type'], $timeout, $retry); if ($ret === FALSE) { // Do nothing }else{ $printers[$x]['type'] = $ret; } While it is possible to assign the variable at the same time as doing the comparison, I find it leads to messy code. The two step approach is much clearer. I also changed your "==" to "===" .. while in most cases it makes no difference, there's a few cases that it does (eg, 0 == false will succeed, but 0 === false will fail). It's a good practice to use === when checking for a return value of false.
  2. That's simple for someone experienced with unix .. for someone inexperienced, they will have to deal firstly with their crontab entries being misformatted, then with their scripts not doing what they are supposed to, then with their disks filling up because the "retain last 48" didn't work properly, etc etc And after all that, you realize that instead of databases 1 through 5, you've actually got 5 backups of database 1 Sometimes it's nice just to pay someone else to have their product do the backups for you. As long as its a decent product. In our case we prefer to do it manually anyway, as we have several databases in the 100-500GB range, and the backups impact the performance of other jobs we are running on those databases. We also have to think hard about where we store all those backups and how many we need to keep, given the space they take up.
  3. Can you try this: <? echo "<a href=\"page2.php?" . htmlspecialchars(SID). "\">click here</a>"; The "." separates the echoed strings and the call to htmlspecialchars(). Otherwise php will not understand the call.
  4. There's some examples here: <p> To continue, <a href="nextpage.php?<?php echo htmlspecialchars(SID); ?>">click here</a>. </p>
  5. Have you tried a length greater than the entire html result? I would try 1024*1024 (1MB).
  6. Usually you should not need to add anything to the url. Do the scripts work if you don't add anything?
  7. Yes it is possible. Look for "php compiler" in google, and you will find a few solutions. If your requirement is protecting source code, you can also look at Zend Guard.
  8. Given how long it's taken for web hosts to switch to php 5, I don't think there's any danger of register_globals going missing anytime soon And no I am not endorsing register_globals by that statement. $_POST['submit'] is better (or $_GET['submit'] if you're using a get form, but you should be using a post form if possible)
  9. For that to work you will need to have register_globals on, and you will need to have your submit button named "submit", all lowercase. And the form must have been submitted by clicking that submit button, not via a javascript submit() call.
  10. Vista and XP have significant differences. I'm surprised it worked on vista but not XP .. usually it would be the other way round. That makes me think that perhaps the WAMP is configured for vista? You might try installing a second WAMP while using the XP system, and get that one working. Then users can run either the XP or Vista one from the USB drive, depending on what OS they have.
  11. It's actually not a 404, it's a 405. Here are the HTTP response headers: HTTP/1.x 405 Method not allowed Server: Microsoft-IIS/5.0 Date: Fri, 20 Jun 2008 04:56:29 GMT Allow: OPTIONS, TRACE, GET, HEAD Content-Length: 3923 Content-Type: text/html Connection: Keep-Alive It is saying that posting is not allowed to your webserver. So you will need to enable posting. I don't know how that is done in IIS unfortunately, but I'm sure you can work it out! Or ask someone who does now.
  12. I don't understand what you are trying to do. Are you trying to migrate some php scripts from an x86 vista system to an x86 XP system and finding that they do not work?
  13. We use the command line tool pg_dump to do backups of our postgres databases. I can produce a text file with sql statements to reconstruct the database (useful if you want to edit it before restore), or a non-portable binary format. We're running it on linux. We use the text option, as it's much more flexible. A backup is done like this: pg_dump -hdbserver dbname | gzip > dbname_backup.gz And a restore is like this (After creating a suitable database) gzip -dc dbname_backup.gz | pgsql -hdbserver dbname The backup consists of sql statements, and pgsql executes each of those statements in sequence to restore the database. If you use mysql, you'll find a lot more software with support for it. That is the clincher for many people when choosing between them. We chose postgres because we need high performance and reliability, and we believe postgres to be good for those (That statement carefully crafter to avoid flaming from mysql lovers ) Mysql vs postgres is something of a religious war btw.
  14. You might want to try http://us2.php.net/manual/en/intro.ftp.php Then you can have more control over the ftp connection, and might be able to find what's going wrong.
  15. Those are one and the same Here the php memcache documentation links to the danga.com site. The missing functions were ones related to the state of the connection to the PG server. Eg, if you want to ask things like "Am I currently in a transaction?" or "Is the server ready to accept a command?" you might have to find other ways to do that. I believe there are new functions in PHP 5 that do some of this, like pg_transaction_status(). But these are not essential functions. All the essential functions are there.
  16. We use standard postgresql at my workplace, and I have no experience with the others. The only thing I have found missing from the php postgres interface is an "in transaction" checker. So we use our own wrappers that track transactions (also allowing simulation of nested transactions using savepoints). Here's the two biggest disadvantages of postgres from my viewpoint - No hints. If the query optimizer picks a bad plan, you have to resort to trickery to force it to use the right one. This caused me serious trouble a year or two back, but none since. - Only primitive collation order support. Collation order is set when you create a database, and cannot be altered. You can however create custom orders (I have never done this myself). Whatever database you use, I highly recommend a memcache caching layer if you have a lot of repeated read-only queries. It can make a world of difference.
  17. First you should check the return values of all your functions, especially the fwrite(). From the manul: "fwrite() returns the number of bytes written, or FALSE on error." As for the issue of not being able to see the uploaded file, if the server people need your file then you can expect their co-operation. If they can't tell your program if the file is uploaded or not, then you can at least ask them to have someone on standby to help you with debugging by telling you if it's there yet. If they don't really need your file, then you can't do that unfortunately. Another thing to try would be to test that your code works with another ftp server.
  18. You're missing only one thing: function getInfo(){ $url = rtrim($_SERVER['REQUEST_URI'], '/'); $urlParts = explode('/', $url); $lastPart = end($urlParts); return $lastPart; }
  19. Can you create a log file in order to find the exact line where the error is occurring? I assume you have display_errors set on already. Have you tried running the code for a single db result only, rather than for all in one script run?
  20. Not really a language question, but I think this is the most appropriate forum I have an image of a corrupted cd which contains some valuable audio data. I would like to extract that audio data into some easily readable format such as wav. Can anyone give me some advice on this? The CD is variously considered as "empty" or containing a single open session of only a few seconds of audio. In reality it has been burnt with nearly 45 minutes of audio which I have extracted as raw sectors.
  21. For fopen(), you use the return value of fopen() rather than the name of the file for subsequent operations like reading, writing, closing: <?php $text = $_REQUEST["rp"]; $text = htmlspecialchars($text, ENT_QUOTES); $temp_fp = fopen("temp.txt","w+") or die("Can't open temp.txt"); fwrite($temp_fp, $text); rewind($temp_fp); $tde_fp = fopen("tde.txt", "a+") or die("Can't open tde.txt"); fwrite($tde_fp, "<p class='p0'>"); while(! feof($temp_fp)) {fwrite($tde_fp, fgets($temp_fp)."<br />");} fwrite($tde_fp, "</p>"); fclose($temp_fp); fclose($tde_fp); ?>
  22. corbin covered the specifics quite well And renlok covered a mid-level view. From an overall viewpoint, the code appears incomplete. Is there more code within the for loop that you left out? If not, then I think it is unfinished code. After assigning the random values to $commander, $race and $jm, I would expect more code to use those values. But that code is missing.
  23. What application receives the emails?
  24. You could cache the data as an array after fetching from the database. That eliminates the database access, though not the generation of the list. But for what you're doing I think a str_replace() would work just fine. Another option is you can cache an array of lines of html. Then to set option #2453, you just edit line 2452 of the array (1 less because arrays usually start at 0).
  25. The first thing to do is to check your method calls for errors, especially the call to bind_result(). If that fails then you would expect $usertype to be empty. The other thing I would check is that the data is not empty in the database itself.
×
×
  • 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.