Jump to content

lessthanthree

Members
  • Posts

    85
  • Joined

  • Last visited

    Never

Everything posted by lessthanthree

  1. list($arUrl[], $arEmail[], $arSize[], $arCommand[]) = explode("\t", $strPingCurrentLine);
  2. $n = 0; foreach($cats as $cat_to_add) { $main = ($n == 0) ? 'Y' : 'N'; $sql = "INSERT INTO table1 (`testdata`, `main`) VALUES ('$cat_to_add', '$main') "; $query = mysql_query($sql); $n++; }
  3. Lots of ways you could do it, if you're sure you only want this field to ever be 'Y' for that value then you can just do it like the below: foreach($cats as $cat_to_add) { $main = ($cat_to_add == '1000') ? 'Y' : 'N'; $sql = "INSERT INTO table1 (`testdata`, `main`) VALUES ('$cat_to_add', '$main') "; $query = mysql_query($sql); }
  4. To add to Ken's statement....If your PHP ini was set to not display warnings (as it should be on a production/live server) then you would not see the warning message. The '@' symbol in front of a function is used to supress any warnings that the function may throw on it's running. As it's only a warning (as opposed to a 'fatal error')the script would continue to run and as ken said, display any further warnings / errors that your script may have. The exit/die statement will kill the script exactly where it is, thus resulting in no further errors being displayed. Hope that clears it up a bit.
  5. You should actually be able to run whole blocks of text through that regex...I think it might struggle to work correctly if there's more than one URL in the text though....I'm far from a regex expert, but someone here surely is. In any case, a regex of some shape or form is almost certainly your best bet.
  6. $input = $bad_url; //this is the input that contains the url you want to replace. preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])/i", "", $input);
  7. Should $angle[1] = $pi - $angle[0] - $angle[2]; not be: $angle[1] = $pi - ($angle[0] - $angle[2]); ?
  8. What are you trying to do? What does $ffmpegcmd1 contain? What are you doing with $ret? Any Errors? Does your PHP ini allow shell exec?
  9. Quite possibly you have to have some installation of Excel on the machine you're attempting to run the COM code on. My mistake, hadn't thought of that, thanks for pointing it out!
  10. If your server is a Windows machine running > PHP5.0, you can use a .xls workbook directly by loading it as a COM object. Something like: $excel_app = new COM("Excel.application"); You can then do what you want with the data, check the PHP manual for full info here However, as it's unlikely your server is running Windows and doing this will make your code extremely unportable (only ever going to work on a Windows box, which lets face it, aren't all that common in the PHP world) I suggest you follow the advice above and export the files as CSV, which not only is more portable, but far far easier to manipulate/get into MySQL. Just though I'd let you and anyone else that may want to try it, that it is actually possible to work directly with a .xls (and other) file type.
  11. Seriously, a short while ago I too had this problem. I consider myself an advanced PHP programmer, but having only ever learned scripting languages, OO was somewhat a new concept to me so I had a bit of trouble getting to grips with it all. Classes / Methods etc all made sense to me and I could use other peoples classes/libraries without a problem, but I always ran into an issue when creating things by myself. I didn't know which classes to construct and what each one should do. I know alot of people don't use books to learn...preferring to 'learn by doing' and using examples already out there on the web, but the Apress book 'PHP 5 Objects, Patterns, Practice' is absolutely superb at filling in the gaps that most web tutorials leave out. It'll tell you how to construct classes, but also the important part of WHY you should create a class to perform tasks. It really is the most useful book I've ever owned to do with PHP. I would link to it, but I'm not sure if this board allows it, so you can find it at the usual retailers (cough, amazon)...Honestly, I can't reccomend it enough.
  12. As well as causing problems with tables like you mentioned, it's generally not seen as a good idea to ever echo/print inside a function unless it's for debugging purposes. Return the value, then print that.
  13. [quote author=radalin link=topic=105522.msg421869#msg421869 date=1156503531] Sigh, yeah even the best idea that comes to your mind had already been thought by someone else and even realized (just like in this case:)). Yeah that's quite true :). I have lost of my enthousiasme to make something that nobody has done years ago, aaaah, poor me :) But I'm a bit confused on your words that there is no point using PHP. Then you should have done something very different than what I thought. Javascript cannot execute sql queries (even it can, sql server's username and password is seen which is vert problematic for security) so you should be using something different then writing to db and then fetching it. I'm curious about that and I would be glad if you talk about it even a little :) [/quote] The javascript did not execute SQL queries...it can't....The javascript was used to call a "background" php script to connect to the db and check for new messages in a very ajax style manner....which is exactly what you would need to do with this...albeit you might choose to use the XMLHttpRequest object and make it "true ajax"...god i hate that term :)
  14. [quote author=ronverdonk link=topic=105588.msg421853#msg421853 date=1156500826] When you are using Windows, the following must be defined in your PHP.INI [code] ; For Win32 only. SMTP = mail.yourprovider.xx smtp_port = 25 ; For Win32 only. sendmail_from = your_emailid@your_provider.xx[/code] You SMTP must define your real mail provider and not localhost.xxx unless you run a mailserver yourself. Ronald   8) [/quote] I don't think he's running a windows server.
  15. It's already been done, using PHP and Javascript, long before the term AJAX was even a twinkle in anyones eye. AJAX is NOT new....it's a phrase that was recently coined for something that developers have been doing for a long long time. We've had a PHP IM system running where I work for 3/4 years that uses javascript (not XMLHttpRequest mind) to get messages realtime for the user that is logged in. To be honest, there's really no point using PHP for something like this, it's not the best tool to get the job done. Knowing which tool to use to complete your job better is a major part of being a good developer. On the other hand, if you want to do it for the sake of having done it, then go ahead :), It can't harm in learning how "AJAXY" stuff works so you can then use it in other projects in the future, just be aware that you're not doing anything that hasn't already been done :)
  16. There's a million ways to do this but.... [code=php:0] $myName = "Phil P"; $fs = "10"; print "<ul>"; for ($i = 0; $i <= 4; $i++) { print "<li style='font-size:".$fs."px'>".$myName."</li>"; $fs = $fs+2; } print "</ul>"; [/code]
  17. Unfortunately I know absolutely nothing about MsSQL, so I can't specifically point you to the right place, I would however suggest you check your query syntax. The empcode bit you've put in there is the only fieldname I can see with single quotes around it....I used backticks (`) in my query as that's what you use to define that it is a fieldname in MySQL... Of course, it goes without saying to make sure you actually have a field named empcode in your table... I'm also not sure why you skip in and out of PHP where you're echoing the $RESULT stuff when it could be in one php block...
  18. [quote author=kenrbnsn link=topic=105362.msg420775#msg420775 date=1156348514] [code]<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>[/code] Ken [/quote] or [code] <?php print "<pre>"; print_r($_POST); print "</pre>"; ?> [/code] Same thing, just my preferred method of typing it, find it easier to find where I'm displaying my POST array when it's in a block like that, particularly on a busy page. :)
  19. [quote author=Moron link=topic=105102.msg420761#msg420761 date=1156347916] That worked, too.   :) My next hair-puller is to figure out how to pull records based on the passed $empcode variable. [/quote] Wouldn't that just be a simple SQL query? [code] mysql_query("SELECT * FROM history WHERE `empcode` = '".$_SESSION["empcode"]."'"); [/code] If you originally obtaining the empcode value from $_GET don't forget to clean the value and check the data is matching what you're expecting, else you're open to people injecting mallicious code into your script.
  20. Have you looked at running some sort of Javascript implementation...I hate using the word, but some kind of AJAX methodology sounds like what you require here..... In simple terms, you can have a javascript run on your main page, that sends any requests to a php page running in the "background"...the JS page is able to make changes to the page a viewer is seeing when the php has finished.
  21. It depends on whether you are talking about making a new password due to the old one being forgotten or lost, or just updating the password. If the old password is lost, there is no way you can retrieve the original value if you are using MD5, SHA1 or similar as these are irreversible hashes that can only be broken via brute forcing. If you want to change a password, you just get them to enter their current password, and a new password. On submission of the new password verify that the hashed value of the old password they entered matches the hash in your database. If it does, hash the new password and enter that...If it doesn't they typed the old password wrong and you should fail the password change. Hope that makes sense.
  22. Well, you probably have a form handler page that sends all the payment stuff off to paypal, just put a process on that same page to add their details into your "members" table/db. You'll probably want to add a field to your members table to flag that they have paid, you can then use this to implement the "donor" icon....
  23. Is there a file in the site somewhere called functions.php or core.php or similar? It might be in there if there is, it depends on how the site was developed.
  24. [quote author=mikeweb link=topic=105339.msg420687#msg420687 date=1156343364] sorry guys ... my message somehow got deleted... I'm having trouble getting my php variables to show up in the table that I'm trying to email using mail(). I've done alot of research on the web but no good clues. Any suggestions p.s. newLine=<<br>> but doesn't show up in my post as it's html as well [/quote] My bad, I think I misread a bit of the way your code works...teach me to scan too quickly...I'll have a deeper look (with a bit more care)
  25. ...and to display it how you want when you take it back out of the database: [code] $myDate = "2006-12-10"; //this will actually come from your mysql table print date("d F Y", strtotime($myDate)); [/code]
×
×
  • 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.