Re: [PHP-DB] Re: Diff between 2 date
Hey Nandar and all, Check out this page: http://www.developertutorials.com/tutorials/php/calculating-difference-between-dates-php-051018/page1.html I found it by pluggin PHP difference between two dates into Google. This one requires you have the date functions, including gregoriantojd() in your PHP install. But if you don't, this one looks like it will do the trick: http://www.weberdev.com/get_example-3240.html Skip On Fri, 2006-10-06 at 11:00 +0700, Nandar wrote: the problem is DATEDIFF command available in MySQL ver 4.1.1 above - Original Message - From: Roby - [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Friday, October 06, 2006 10:44 AM Subject: [PHP-DB] Re: Diff between 2 date Using SQL statement: datediff, example: SELECT datediff( day, '2006-10-05', '2006-10-06' ) Hope it helps you ;-) - All-new Yahoo! Mail - Fire up a more powerful email and get things done faster. No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.407 / Virus Database: 268.13.0/464 - Release Date: 10/5/2006 -- =-=-=-=-=-=-=-=-=-=-=- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, MT 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Populating drop downs
Hey all, Since I get so much great info and help from the lists I'm on, every now and then I like to try and give something back. I just finished some code that is pretty useful for populating one drop down based on the selection of a previous one, so I thought I'd pass it along in case anyone found it useful. I'm sure many of you already have a way to do this in your toolbox, but thought some may not. I've seen many examples of doing this Googling around, but found them overly complex, and I think I've come up with a quite simple and affective way to do it with not too much code. Basically, I had a need to populate a dropdown containing areas within the boroughs of New York City based on which borough was selected. So say they select Manhattan in the first dropdown, the second dropdown then becomes populated with the areas within Manhatan. The code builds the possible arrays for the second dropdown from the database when the page loads, then plugs them directly into the JS, making the whole arrangement dynamic. Change the DB and the dropdown adjusts accordingly. If you'd like to see the code email me off list and I'll pass it along. -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Using MAX with COUNT?
Hey all, I have a table like this: boroughID Area = 1 Chelsea 1 East Village 1 West Village 1 So Ho 2 Prospect Park 2 Brooklyn Heights 3 Prospect Heights What I want to know is which boroughID has the most area's assocated with it, and how many. So I tried this: SELECT max(count(*)) FROM `bsp_area` GROUP BY boroughID ...and got an Invalid use of group function error. Anyone think of another way to do this in a single SQL statement, or some other simple method? -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] authorize.net
Hey all, Anybody on the list know authorize.net integration really well and would be interested in earning a few bucks consulting? I have a new install that has their tech support and myself stumped and I really want to get it going. If so, email me off-list with your level of experience and hourly rate. -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Discussion board integration
Hey all, I've got a requirement for a discussion board on a new site we are building for a client. I've integrated phpBB2 for discussion onto existing sites before, but was wondering if anyone had any experience with other PHP discussion boards they favored over phpBB2. I found the login integration of BB2 especially troublesome, though I did get it to work in the end. -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Discussion board integration
Hey Dave, Thanks much for the tip. How about the log in integration. That was the toughest part about phpBB2, at least for me. I assume MyBB has some kind of independent log in? And how tough was it to accept a user ID say from a $_SESSION variable and auto-log in the user to the BB? Thanks, Skip Dave W wrote: Yea, phpBB2 is tough to integrate. I've been working with MyBB and I think it's great! The templating is very simple (By bb standards). It's less mature than phpBB, but they fix bugs faster and is quickly becoming very stable. It works a lot like vBulletin except it's free and open source. I know there is SMF too, but I don't use it, so I really can't tell you anything about it. On 7/19/06, *Skip Evans* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hey all, I've got a requirement for a discussion board on a new site we are building for a client. I've integrated phpBB2 for discussion onto existing sites before, but was wondering if anyone had any experience with other PHP discussion boards they favored over phpBB2. I found the login integration of BB2 especially troublesome, though I did get it to work in the end. -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Dave W -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Submitting form from a href
If you use a GET and submit through the link you don't carry the check box through with the POST. Here is the code that I used after help from the list: First, the JS function script language='javascript' function submitForm(letter) { document.search.letter.value=letter;// put the letter in the post value document.search.submit(); // submit the form } /script // the check box td class='fieldprompt'All Campusesbrinput type='checkbox' name='all_campuses' !!checked!!/td ... and the links that call the JS function: form name='search' action='modules.php?mod=listreq=listbooks' method='post' a href=javascript:submitForm('A')A/a ...etc, etc... And finally the PHP code that picks up the value for the letter selected. $letter=$_POST['letter']; $all_campuses=$_POST['all_campuses']; This solution was very straightforward and a snap to put in place. Gobs of thanks to the guys who sent through suggestions. I'm sure this is code that I'll be using again. Skip Sean Mumford wrote: Couldn't you achieve the same effect without javascript by simply using GET values instead of post? As in each hyperlink would say something like a href=search.php?letter=aA/a a href=search.php?letter=bB/a, although perhaps you're trying to intentionally avoid using GET as to not clutter up their browser history. .. -Original Message- From: Andrew Kreps [mailto:[EMAIL PROTECTED] Sent: Friday, July 14, 2006 7:15 PM To: Skip Evans Cc: Php-Db Subject: Re: [PHP-DB] Submitting form from a href Skip, Just so you know, there is a general PHP user's list available for just such a request. It's rather high-traffic, so be warned. Now then, on to the problem. I believe I've figured out a way to make this happen. I've only tested it on IE 6 and Firefox 1.5.0.4, so your browser compatibility may vary. I'll just post the scripts I used to test it here and you can take what you need and run with it. Here is the script that my form is built in: -- html head script language=Javascript function submitForm (letter) { document.search.letter.value = letter;// Here's where we're setting the form value 'letter' to the letter the user clicked on. document.search.submit(); // Then, submit the form. } /script /head body form name=search method=POST action=testingLinkSubmit.php input type=hidden name=letter value= !-- If this isn't here, the Javascript letter.value code won't work, since form.letter doesn't exist. -- input type=checkbox name=checky/ Search all campuses br ? for ($i = 65; $i = 90; $i++) { $letter = chr($i); print a href=\javascript:submitForm('$letter')\$letter/a ; } ? /form /body /html - The receiving end of the form looks much as you might expect, it just parses the form values: -- html body ? if (isset($_POST[checky])) { print Checkbox value is: Truebr\n; } else { print Checkbox value is: Falsebr\n; } print Letter: . $_POST[letter]; ? /body /html And there you go! Let me know if you have any problems. On 7/14/06, Skip Evans [EMAIL PROTECTED] wrote: Hey all, This is not database related, but I get the impression this list entertains general PHP questions? If I'm mistaken, flame away. I need submit a form when a hyper link is pressed, and have been trying all manner of onlicks, etc, but have been unable to hit the right combination. Here's the scenario: I have the alphabet in hyper links with a check box below: form... A B C D E F G H I J K. [] check for all campuses /form What needs to happen is that when they click a letter, which is a a href=... now, it submits the check box value as well, to be read through $_POST on the receiving end. And of course I need to know what letter was click, this I was trying to get through a $_REQUEST var, but was not able to do so. Any tips would be monstrously appreciated. -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Getting directory from local machine?
Hey all, I have looked but been unable to find a way to allow the user to specify a directory on their local machine in which to download files using a similar mechanism as the browse button in and input type='file' type thing. Basically, this module needs to FTP all the files in a directory down to the local machine, and they need to be able to browse for the directory to place those files in. Is there such a way? I have not been able to find anything. -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Uploading multiple files?
Hey all, I have a client who uses a Java applet to allow site members upload multiple files (photos) at a time, as many as 40 or 50 sometimes, to his site. He wants to get away from the applet and use a PHP solution that will fit more seamlessly into his site, but it still must be able to upload multiple files. Does anyone know of a way to construct a form such that multiple files can be highlighted in a single stroke, brought into say a textarea type field, and then uploaded? I can't think of a way to do this, so anyone that can point me in the right direction would be most appreciated. Thanks! -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Converting to Decimal
Are you just displaying the value with the decimal places? If so, check out the function number_format($var,2) Skip Miguel Guirao wrote: You could actually do (int) $var or use the sprintf(%d, $var); -Original Message- From: John Meyer [mailto:[EMAIL PROTECTED] Sent: MiƩrcoles, 28 de Junio de 2006 06:04 p.m. To: [EMAIL PROTECTED] Cc: Php-Db Subject: Re: [PHP-DB] Converting to Decimal Mark Bomgardner wrote: I am query a database and pulling some decimal values out of the table, but when I display whole numbers in php, it drops the decimal places. It takes a value of 12.00 in the database and makes it 12, where I need 12.00. I am having trouble finding ways to cast this value. First, off, when you directly query the database, does it come back as a floating number. And secondly, have you checked this out: http://www.php.net/manual/en/function.sprintf.php -- Online library -- http://pueblonative.110mb.com 138 books and counting. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Newly inserted record ID
I am very new to the list, but I get the impression that Jonathan below is rather new to programming in PHP/MySQL and lists like these are great resources for people without the many years of experience some of us have. And while mysql_insert_id() is old hat to most of us, to people with less experience it is not so obvious. So I'm always dissapointed to see more experienced programmers say things like Stut has said below because they tend to intimiate inexperienced coders, make them shy away from asking questions out of fear that gurus like Stut will say the kinds of things he has said below. For this reason I'm going to unsubscribe from the list, lest I ask a question and get similar treatment. Jonathan, if you have any other questions you feel might get you jumped on again for asking please feel free to email me directly. And Stut, please please please please please consider other peoples' feelings before you go shooting off your freaking mouth. Jonathan probably is reading the manual, but may missed the small section on mysql_insert_id(). And for that he doesn't deserve your scron. Sign me, ... unsubscribed from this list, Skip Stut wrote: JONATHAN GRAVOIS wrote: Thanks to the help of this list, I am making great progress. Now this -- I have a multi-part submission form for a support application for us, the manufacturer - the reseller's information is submitted, the customer's information is submitted, then the warranty support information needs to be submitted. How can I retrieve the CustomerID after I insert a record into the customer table in mySQL and pass it to the CSQdetails.php page? http://php.net/mysql_insert_id And please please please please please read the freaking manual before asking questions here! -Stut -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Single quotes in INSERT statements?
Geez, did I start all this? I can see now that my initial assumption that addslashes() was not doing what it was supposed to do was wrong, and that I should have checked the DB before firing off the message. Clearly I should have done more investigation on my own. (Which is often the case.) However, the initial response that was made about perhaps the field itself truncating the data tipped me off to what I should have done previously, look in the database, so once I did that it was clear what the problem was. And then another list member had mentioned htmlentities() and that lit the the old proverbial overhead bulb, and bingo: problem solved. Perhaps a zig zag, somewhat sloppy path to the solution, and I accept responsibility for that, but a solution nonetheless. I must confess I'm happy about that. I do apologize for my assumption starting a thread that was misnamed, and not doing the diligence thing before firing off the message. But I certainly do value and appreciate the assistance given. Skip [EMAIL PROTECTED] wrote: Martin Alterisio wrote: 2006/4/26, [EMAIL PROTECTED] [EMAIL PROTECTED]: Skip Evans wrote: Hello all, I'm brand spanking new to the list and have a quick question. I was under the impression that addslashes() would handle single quote marks in INSERT statements, but when I execute the following: $sql=UPDATE images SET orderno=$orderno, url='.addslashes($url).', banner=$banner,caption='.addslashes($caption).' WHERE imageID=$imageID; ...and $caption contains something like: Don't look ...the data is chopped off at the single quote mark. How, if not addslashes(), does one handle this? No, neither mysql_escape_string or mysql_real_escape_string worked. Yes, I am using MySQL, should have said that, sorry. But anyway, even with both of these functions, the data in the string containing the single quote as in Don't Look is still being truncated at the single quote mark. Any other suggestions would be greatly appreciated. Skip For the archives: Subject of this thread is misleading since the problem was not one of an INSERT failing but of HTML not displaying properly because of quotes or other special characters in the text in the database. Just goes to show that the best way to get the right answer is to analyze the problem accurately and ask the right question. David Well, 80% of solving a problem is finding out what the problem is. If you ask them to solve that 80% on their own then asking for help is rather pointless. Anyway I agree that the subject was misleading, but this was caused by how he explained the problem, particularly on the assumption that addslashes was not doing what it was supposed to do so. What I advise is to avoid assumptions and just present the symptoms of the problem. The devil is in the detail, no? I'm not disagreeing with you, Martin. Clearly incorrect assumptions were made by the initial poster, and responses were consequently at first off-base. Far be it for me to discourage anyone from asking a question, well considered or not. And to be honest, I even rather enjoy those that are off-topic. My apologies if my preceding response seemed impatient or impolite. We all once were beginners, and I still have one or more brain dead moments each day. Reminds me I'm human. David -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Single quotes in INSERT statements?
Hello all, I'm brand spanking new to the list and have a quick question. I was under the impression that addslashes() would handle single quote marks in INSERT statements, but when I execute the following: $sql=UPDATE images SET orderno=$orderno, url='.addslashes($url).', banner=$banner,caption='.addslashes($caption).' WHERE imageID=$imageID; ...and $caption contains something like: Don't look ...the data is chopped off at the single quote mark. How, if not addslashes(), does one handle this? Thanks! -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Single quotes in INSERT statements?
Hello David all, No, neither mysql_escape_string or mysql_real_escape_string worked. Yes, I am using MySQL, should have said that, sorry. But anyway, even with both of these functions, the data in the string containing the single quote as in Don't Look is still being truncated at the single quote mark. Any other suggestions would be greatly appreciated. Skip [EMAIL PROTECTED] wrote: Skip Evens wrote: Hello all, I'm brand spanking new to the list and have a quick question. I was under the impression that addslashes() would handle single quote marks in INSERT statements, but when I execute the following: $sql=UPDATE images SET orderno=$orderno, url='.addslashes($url).', banner=$banner,caption='.addslashes($caption).' WHERE imageID=$imageID; ...and $caption contains something like: Don't look ...the data is chopped off at the single quote mark. How, if not addslashes(), does one handle this? Skip, If you're using MySQl, try mysql_escape_string(), or mysql_real_escape_string. If using some other RDBMS, look for similar functions in their respective manual(s). You might also investigate the setting of the magic_quotes directive in php.ini, or use get_magic_quotes_gpc to return this value programmatically. Hope this helps. David -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Single quotes in INSERT statements?
Martin Alterisio wrote: 1) Check that the string is not being truncated because of the column length This was not it. 2) If you're seeing this data being truncated in the html output of your site, check if it isn't being caused by outputing the data without properly encoding special html characters. Yup! This was it. The data was fine in the database, so I wrapped the output with htmlentities() and all came out good. Thanks to Martin and all who made suggestions. 3) . dunno See number 2 ;) Thanks again! -- Skip Evans Big Sky Penguin, LLC 61 W Broadway Butte, Montana 59701 406-782-2240 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php