Jump to content

miseleigh

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Everything posted by miseleigh

  1. I've been trying to use the php_ssh2 module, and have been having trouble getting it to load. Through the live chat here someone linked me to a site that suggests that Apache simply doesn't like this module, and has a workaround for it, but he didn't go into much detail for the workaround. He says that the "php_ssh2 module WILL load from php CLI script", and so his workaround was to call a CLI script from his PHP code that loads the module. I've been trying to do this, but I must not be doing it right, cuz it's not working. This is how I'm doing it: On the webpage: exec('SSH/load_module.bat'); $connection = ssh2_connect($ip[0]); load_module.bat: /php5.0/php.exe -c /php5.0/phpcode/php.ini load_module.php and then load_module.php: <? dl('php_ssh2.dll'); ?> And then I get the error 'Call to undefined function ssh2_connect()'. So I don't really know what I'm doing when it comes to CLI stuff, and executing them from PHP, so any help would be awesome.
  2. If that doesn't work (as it didn't for me) try running Dependency Walker to see if you're missing any files the module depends on. It's turned up a couple for me, so now I get to go find those too... php5ts.dll and dwmapi.dll.
  3. I'm not sure if you've solved this problem yet or not, but I've run into the same issue, so if/when I figure parts out, I'll post here. First thing to do is the two parts you've already done, then also check that the extension directory is in the windows system path. If it's not, add it and reboot. (Or, instead, putting the .dll in the windows/system32 folder often works as a quick hack, but it's not the best solution.) In XP you can get there by Control Panel->System->Advanced->Environment Variables. In your case make sure that c:/php5/exts/ is in the path. If you're not using Windows I don't know where the system path can be edited but I'm sure it's similar.
  4. Actually, I've already read that whole thread (that's where I got the link to the normalizer I pointed to - thanks!) but I don't quite understand how to do it. Would this work? $newfoo = I18N_UnicodeNormalizer::toNFD('foo'); preg_replace('/\p{M}/u','', $newfoo); Is NFD the right one? I found one source that says that one means decompose... Unicode's interesting, but it's a bit confusing for someone who's never had to deal with it before. Thanks for helping.
  5. I'm just wondering if there are any functions or scripts out there to convert non-English characters to their English equivalents (ex: ñ->n, or ä->a, and hopefully æ->ae.) I haven't been able to find much. The best I've found was a quick link to a Unicode normalizer, but it doesn't seem to do what I'm looking for - or at least, if it can, I can't figure out how. This isn't critical or anything, just a question, but if you happen to know the answer... Thanks!
  6. Alright, it's been figured out, in case anyone else has a similar problem: DON'T USE EXCEL FOR YOUR CSV FILES! Somehow Excel messed up the newlines in the file, so it exploded. Recreate your file in notepad or something similar.
  7. Just a little more info: The fgetcsv() output looks like this (one function call, should only return one line): When it should be like this (multiple calls shown): I'm still quite confused. Does anyone know why it might be doing this? What line delimeter does a .csv use & what is fgetcsv expecting? Could it have something to do with the fact that the .csv was created on a PC and the script is running on a Mac? I would really appreciate some help with this one.
  8. I tried this: $line=fgetcsv($fp); print_r($line); The result looks like there's no endline at the end of each line, so fgetcsv is reading the entire file as if it's a single line. The first field of a line is appended onto the last field of the line above it into a single array field. How can I fix this? (preferably without editing the .csv, but I may have to...) Thanks!
  9. I'm trying to read in a csv file and put it into arrays. Shouldn't be too hard... but for some reason, my loop only reads in the first line of the .csv file. Any suggestions? $eday_count = 0; if(($fp=fopen($event_fn, 'r'))!=null) { while(($line=fgetcsv($fp,500,",","\""))!==FALSE) { $event_day[$eday_count]['type'] = $line[$sch_TYPE]; $event_day[$eday_count]['msg'] = $line[$sch_MSG]; $eday_count++; } } After this, my $event_day array only has one entry, and it should have several. Any help would be greatly appreciated.
  10. Well, I decided that it's not a problem if the keywords within links are bolded as well, so unless the client complains, I'm all set. That regex worked perfectly; bolded all the keywords (and permutations of them). 665 matches in 278 files...
  11. No, I'm on a PC. I can upload files to our web server, which does run PHP, but I don't think I can run scripts on it outside of web pages. I probably could put it in a web page and run it there, but I'm just an intern here and I'm not sure my boss would like that. I've almost got this working with the if-else construct anyway... I'll post it when I figure it out.
  12. Thanks, but I read that one already. That would be great if I was allowed to install & run PHP on my computer, but the only regex tool I have is EditPadPro's search and replace - which is usually plenty, luckily I don't have to do this often. But I really don't want to manually bold keywords in 300+ files... I suppose I could use what I've got and then use a second regex to strip out the unwanted bold tags, but it's a lot of files and I'm afraid it's already going to take a lot of time to run through them once. Hmm. Maybe use an if-else? Could I use that to say 'if you find <a, keep going until you find a>, otherwise do what i have now'? Think I'll try that.
  13. If you don't want it to send until the input is valid, what you really need is javascript. Try this site: http://www.w3schools.com/js/js_form_validation.asp edit: this site is more of a tutorial: http://www.tizag.com/javascriptT/javascriptform.php
  14. Quick change, doesn't change functionality (?<= (?<! \? | TITLE | <a[^>]* | \d ) > [^<]*) \b((?: keyword | list | here) '? s?)\b *note: added spaces and colors for readibility
  15. I'm not particularly good at regular expressions, and this is probably the most complex one I've tried. Basically, my company is doing some updates for a very large website, and one of the things they'd like us to do is bold a bunch of keywords in the text throughout the site. So I figured hey, a regex will make that easy... So far my regex filters out keywords contained within html and php tags, like it should. (Wouldn't it be fun to have your php scripts mess up because one of the keywords for the site also happens to be a variable, and you've now stuck tags around it? Or have your links stop working because those same keywords are also part of file names?) So here is what I have so far. (Note: using EditPadPro - JGSoft regex engine.) (?<= (?<! \? | TITLE | (?: href=[^>]*) | [0-9] ) > [^<]*) \b((?: keyword | list | here) '? s?)\b *note: added spaces and colors for readibility Alright, so it currently matches any keyword preceded by a > but not a < (filters out ones in the middle of html tags) where the > is not preceded by title, ? (for php tags), a number (for headers), or a hyperlink. But it does match one case when I don't want it to: <a href="url">some stuff <br>keyword <h2>some stuff</h2></a> If there is another html tag between the <a> and the keyword, the regex matches. I tried using a lookahead with a negated character class (tried [^<] and [^/]), which works as long as the keyword isn't followed by another ending html tag... like the </h2> in the example above. Of course, using .* instead of the negated character class means that any keywords preceding a link won't be caught, even if they're not within the link itself. So I'm lost. I also tried filtering out any > preceded by a ", but then any keywords following an image wouldn't be caught, so that doesn't work for me either. Any help would be greatly appreciated - this is all a little over my head.
  16. I've just installed WAMP5 on Windows XP, and I'm trying to get php to run from the command line. I've added c:\wamp\php\php.exe to my system path, but when I type 'php -v' in my command line, I still get an error message that says 'php is not recognized'. Is there something in the php.ini file that I need to change as well, or something else I need to do with my system path? As far as I know, this should be working... I also have php-win.exe in my php folder. Should I be using that one instead of php.exe? Any help would be greatly appreciated.
  17. Well, nevermind... the original author had it redirecting back to the original products page if the varibale wasn't set and forgot to actually request it. All fixed! On products/bybrand.php: <?php Header("Cache-Control: must-revalidate"); $brand=$_REQUEST['brand']; // I added this if(!isset($brand) || $brand == "null") header("Location: ../products.php"); //was originally products.html
  18. I call the following from products.php: <form action="http://www.mysite.com/products/bybrand.php" method="post"> <select name="brand" onChange="this.form.submit()"> <option value="null"> Select Manufacturer </option> <option value=1>Manufacturer 1</option> <option value=2>Manufacturer 2</option> <option value=3>Manufacturer 3</option> </select></form> but when an option is selected, the page tries to go to products.html (which doesn't exist) instead of products/bybrand.php. I have a few forms like this on products.php that are supposed to go to different pages, but they all do the same thing. Any help would be greatly appreciated.
  19. That was the problem - I just have to upload all my pages now before I can see what they're going to look like. I would use XAMPP, but most of what I do is pure HTML, so dreamweaver's usually good for what I need. Thanks for your help!
  20. Well, it looks like the computer I'm working on doesn't support php, so previewing it in dreamweaver doesn't work. Let me get it uploaded to the server and see if that does it. and yes, it's a .php
  21. I'm sure this question has come up before, but it's hard to find answers. I'm having trouble with my echo statement. <?php echo "<a title=\"UPS Systems\" href=\"/ups.html\" class=\"nav\">UPS Systems</a>"; ?> <a title="APC" href="/ups/dne.html" class="subnav">APC</a> results in: where APC is a link like it's supposed to be, but 'UPS Systems' is plain text. It's as if the ending bracket for the <a> tag isn't recognized, but I can't see how to fix it. Any help would be greatly appreciated. I've also tried the same statement using single quotes instead of escaped double quotes in the echo statement, and surrounded by single quotes with unescaped double quotes. I also tried storing the html string in a variable and then echoing the variable; I've gotten the same results each time - any php code after 'UPS Systems' shows up as plain text. Thoughts?
  22. I'm trying to access a device through php's telnet functions.  I found a script (link: [url=http://www.geckotribe.com/php-telnet/]http://www.geckotribe.com/php-telnet/[/url]) to use, but it keeps returning '[PHP Telnet] Connect failed: Login failed'.  I know I have the IP address, un, and password right; any suggestions?  The only thing I can think of is that the device uses an 'auth' cli command for the login, and maybe this isn't working for that. function call: [code]$result = $telnet->Connect('xxx.xxx.x.x','un','pw');[/code]
  23. The number of pages your code uses has nothing to do with how well or how quickly it runs.  The only reason someone may have told you that is if you tend to add in a lot of extra code that doesn't actually do anything.  For example, the two snippets here will run exactly the same, despite the extra whitespace and comments, and one of them is a lot more readable: [code]if ($_GET['status']) { $status = $_GET['status']; }elseif ($_POST['status']) { $status = $_POST['status']; }[/code] [code]//Something about what this if statement is for if ($_GET['status']) {     $status = $_GET['status']; } elseif ($_POST['status']) {     $status = $_POST['status']; }[/code] Your 2 page version probably does run faster than your 17 page version, because the only way you could get rid of those 15 extra pages is by taking out a whole lot of stuff that the computer didn't need to be doing.  But it's not the number of pages that made the difference, it's the number of calculations and the amount of memory needed to do them.  I don't know how to optimize php at all, cuz I don't do anything that really needs it, but I'm sure you could find stuff on Google if you really wanted to know how to make your scripts either run faster or use less memory.
  24. Try php's time() function, it'll give you a timestamp - you can store this in your db for the order time.  Then when they come back, it's just a calculation and formatting: $time_left = time() - $order_time; echo strftime("You have %j days, %H hours, and %M minutes left", $time_left); There are a few things to be aware of with this script.  The %j option is the day of the year by decimal # (for example, Feb 2nd would be the 33rd day) so it will only go as high as 366.  There are more options listed to include years if you need them - check the manual.  Also, if the user orders access for a day and it crosses daylights savings time, they'll still get exactly 24 hours even though that particular day might have either 25 or 23 hours in it.
×
×
  • 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.