Jump to content


Staff Alumni
  • Posts

  • Joined

  • Last visited


Everything posted by Koobi

  1. try working backwards then. check the results of $z like this: <?php echo '<pre>' . print_r($z, true) . '</pre>'; ?> and if $z does contain what you expect, then go backwards and do the same for $page, etc until you see something that we might find useful to solve this problem and post it here. also, you had this earlier: <?php $$z['Short'] = $z['Long']; ?> but now you have this: <?php $z['Short'] = $z['Long']; ?> just pointing it out because your code would have failed earlier anyway.
  2. usually, an SQL string manipulation would work faster than a PHP string manipulation so you might want to give roopurts method out. but since it's a CONCAT function, you might want to take a benchmark and compare the two results.
  3. a session is...a session the moment you end that session by either leaving the site or a page (depending on how you have set it up), that session data is lost forever...unless you store it as a cookie or in the db. this is not PHP's fault, it's because HTTP is a stateless protocol. we wouldn't even need sessions for most things if HTTP wasn't stateless.
  4. i'm sorry, i just realized i've made a mistake. since the code i posted is adding a decimal number, you will get WLK2 what you could do is use str_pad() <?php $old_code = 'WLK0001'; $added_num = substr($old_code, -4) + 1; $new_code = substr($old_code, 0, 3) . str_pad($added_num, 4, '0', STR_PAD_LEFT); echo $new_code; ?> but this is also not tested so try it out and let me know.
  5. are you certain that the last 4 digits will always be numeric? if so, you can try this: <?php $old_code = 'WLK0001'; $new_code = substr($old_code, 0, 3) . (substr($old_code, -4) + 1); echo $new_code; ?> it might be better for you to throw in a is_numeric() or, better yet, ctype_digit() function in there too.
  6. yeah i agree on the FTP username issue. but other than that, i think they are pretty good. I've used them a couple of times via some clients. i hear that they got the best domain registration award last year.
  7. cookies would work but they can be spoofed and as roopurt18 mentions, you can turn cookies off as well. if your users log in, your best bet would be to have a little column in this users table which contains the number of visits he's had to this page. increase the count in this table row for that customer on each visit and keep track via that table. if your users don't login, then i guess cookies would work best for you. but i think someone else might be able to answer this part better, hopefully as i'm not 100% sure of the best method for such a thing when the user is not logged in.
  8. as Wildbug said, error messages would be very useful. that is the reason they exist, so that we can use them to debug the problem. one thing that could be causing the problem is that your upload limit maybe smaller than the size of the file you are trying to upload. but i'll wait for your reply with the exact errors before i elaborate.
  9. i believe include and require (and their variants) use the filesystem to include the file so when you pass _GET variables, it will probably search the file system for a file with that name, your code probably is looking for a file named 'comments.php?id=1' but only 'comments.php' exists. you'd typically use include or require if you want to include the raw PHP code to be processed on the page. you could try this: <?php $_GET['id'] = 1; include ("../iandotcom/comments/comments.php"); ?> that might work for you if your code looks for a _GET['id'] to process whatever it is you are processing.
  10. searching the manual helps CLXXXVII. Zip File Functions or if you're more comfortable with google, type this in your google search bar: ZipArchive site:php.net it will then search for ZipArchive on www.php.net you'll need to enable the zip extension to use this feature.
  11. strip_tags() will strip out anything within HTML tags (unless you use the optional parameter to define a set of tags you want to allow) but you can also use str_replace() to do what you need most efficiently.
  12. i make this mistake a lot too which is probably why i caught this out <?php if($y=$z) { echo $z['Long'];} ?> in the above, you are trying to assign $z to $yz and an assignation will always work...unless you are trying to assign a value to a previously defined constant and therefore, your if condition will ALWAYS be true. you have to use either '==' or '===' depending on your needs. what happens in between the if conditions brackets is that the code in there is evaluated (think var_dump()) and the if condition itself receives the boolean result of what is in the brackets. so, you assigning $z to $y will always return a true to IF since that is a perfectly legal thing to do in PHP. btw, you can correct your code by making it like this: <?php if($y == $z) { echo $z['Long'];} ?>
  13. oh one other thing that i like about Zend Studio is that it will add the PHPDoc tags for you with the required parameters. You just have to fill in the details.
  14. that's very vague i'm not sure what you mean by 'settings'
  15. i'm not sure about windows, but on Linux, you can have as many php.ini files as you want and place them in a directory and your phpinfo() would show that directory as the location of php.ini for example, one of our clients servers at work has the following path to php.ini: /etc/php.d/ and the folder '/etc/php.d/' contains many .ini files pertaining to a specific extension of PHP. the most effective way to determine if your PHP settings are working as they should would be to make a change in your current php.ini and restart the web server and have a look at phpinfo() again to determine if the changes you made are reflected in it.
  16. i think he means he's running a PHP as a CGI. grivix, if you're not sure how to answer us, please create a file (let's call it phpinfo.php, for example) and place the following code within it, access it via the browser and post it here as an attachment or however you want: <?php phpinfo(); ?>
  17. i downloaded the tool ages ago via this thread but i only tried it out recently. great tool. makes life so much easier!
  18. well it looks like Zend Core 2.0 was a buggy release. i contacted their tech support because it kept giving me errors that i know didn't exist on the system because i set it up myself and the tech guy logged in via SSH and after about two days told me that there seems to be a problem with Zend Core 2.0 that other customers had been experiencing as well and that they are releasing Zend Core 2.1 today (apr 22, 2007) so i'll give that a go tomorrow and hope for the best!
  19. what do you mean by 'Linux project'? is it to do with the OS only and not necessarily PHP? why don't you use the linux diff command? if you have to use PHP, then you can still use exec() wifh diff and grab the output and format it to display what you need.
  20. i agree. i've done the practice test for PHP 4 and it's not hard...but some of the questions were...unexpected and unnecessary. anyway i thought i'd stay till i learnt PHP 5 since that was coming out at the time. i've finally found some time to learn the new things about php 5 over the last few weeks.
  21. nice, congrats i'll be taking the exam soon. before august for sure. how was it? and what material did you use to learn from, if you don't mind me asking.
  22. thanks Glyde. i thought that exceptions was meant for this sort of thing. what is it really meant for anyway? that would work fine, thanks. but do you think it's best practice to throw the exception inside my validation class or within the procedural code, like this: class My_Validation { function __construct () { } public function valid_numeric ($val) { if (ctype_digit($val)) { return TRUE; } else { return FALSE; } } public function valid_alphanumeric ($val) { if (ctype_alnum($val)) { return TRUE; } else { return FALSE; } } function __destruct () { } } $validation = new My_Validation; try { if ($validation->valid_numeric('4f') === FALSE) { throw new Exception('Not a valid digit', SOME_ERROR_CODE_CONSTANT); } if ($validation->valid_alphanumeric('5.r') === FALSE) { throw new Exception('Not a valid alphanumeric', SOME_OTHER_ERROR_CODE_CONSTANT); } } catch (Exception $error) { echo '<pre>' . print_r($error, true) . '</pre>'; }
  23. 7zip has an amazing compression ratio. almost 50% better than .zip, i think. PHP's zip library supports the .zip compression format and zlib in PHP supports the .gz compression format...but as gluck suggested, you might have to use PHP's exec() to run a system call to handle the 7zip format. make sure exec() hasn't been disabled in php.ini and note that if your PHP is on safe_mode, you might have to overcome some issues. Just look up 'safe_mode in php.ini' in the manual.
  24. Koobi

    Uses of linux

    just as it's been mentioned here, you can totally customize Linux which you can't do in Windows because you don't have access to the Windows source code whereas in Linux, you can even alter the OS by recompiling the kernel. in linux, you can add your own Desktop environment (GNOME, KDE, XFCE, Orchestra, etc) but you can't do this in Windows...not easily anyway. total control, even upto the point where you can dictate the way your hardware interacts with your software...although this is not a good thing all the time, i learnt that :/ you know what, there are too many things to mention. this might turn out better if you asked us if task X can be done in linux, chances are, it can be done in Linux
  25. here's an example: <?php class My_Validation { function __construct () { } public function valid_numeric ($val) { if (ctype_digit($val)) { return TRUE; } else { throw new Exception('Not a valid digit', SOME_ERROR_CODE_CONSTANT); return FALSE; } } public function valid_alphanumeric ($val) { if (ctype_alnum($val)) { return TRUE; } else { throw new Exception('Not a valid alphanumeric', SOME_OTHER_ERROR_CODE_CONSTANT); return FALSE; } } function __destruct () { } } $validation = new My_Validation; try { $validation->valid_numeric('4f'); $validation->valid_alphanumeric('5.r'); } catch (Exception $error) { echo '<pre>' . print_r($error, true) . '</pre>'; } ?> The problem is, $error only contains the first exception thrown by My_Validation::valid_numeric. I want both throws to be caught there so that I can display them.
  • 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.