[PHP] RE: find (matching) person in other table
Hello Afan list, I recently coded such an animal for a customer. It is a quick and dirty piece of work. They had an existing dataset and wanted to match new registrants against the dataset so as to avoid duplication. First we applied logic to not accept duplicate email addresses in the registration, and sent the potential duplicate user off to the password lookup page. Next we assigned a contact_type, usertype, and sales_status: contact_type enum( company, individual) default company; usertype enum( primary, secondary, other) default primary; sales_status enum( open, hide) default open; Explanation Customer is using data for contact management and sales. sales_status lets the admin toggle off visibility, so as to hide records they don't want to see usertype lets multiple users exist from the same company - we can track everyone in their organization :), but only one is the primary contact Match script So next the match script was built which allows the admin to surf thru the dataset, and lookup any string. Of the data fields these were found to be significant for us: username, email, companyname So the Find Match script lets you click on any of username, email, companyname and pulls out LIKE $username% or LIKE $email% (but just the domain part) OR LIKE $companyname% examples, depending on what you selected. This yields a match in the last part, but not the first, of the selected match variable. I did not apply a percentage result such as you suggest. Matches can and are found in almost every data field. The trained human eye works better than a percentage, always will. Anyway, because the script result returns ONE LINE PER RECORD, and this line contains clickable links to match email, match username or match company (and edit record and other stuff), it lets the admin keep surfing thru the database finding matches, or not. I arbitrarily limited matches to 20 rows, since the user can click on any line to initiate another match of a particular value, its not a biggy to keep searching, in fact, its fun and almost addictive ;) Lastly I added on basic tools so the admin could change any of the values for any of the data fields. So the tool has a byproduct feature of letting the admin clean up their dataset while they're matching. The sales person even had his wife doing match lookups for him within the week :) This I'm sure is not the best or only way, but that's what we did, it works, and the customer is happy. Maybe it will help you too. Sincerely, rob http://phpyellow.com === Date: Wed, 30 May 2007 15:30:59 -0500 From: Afan Pasalic [EMAIL PROTECTED] To: php-general php-general@lists.php.net Subject: find (matching) person in other table hi, the code I'm working on has to compare entered info from registration form with data in members table and list to administrator (my client) all matching people. admin then has to decide is person who registered already in database and assign his/her member_id or the registered person is new one and assign new member_id. I was thinking to assign points (percentage) to matching fields (last name, first name, email, phone, city, zip, phone) and then list people with more than 50%. e.g., if first and last name match - 75%, if only email match - 85%, if first name, last name and email match - 100%, if last name and phone match - 50%... etc. does anybody have any experience with such a problem? or something similar? thanks for any help. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] local v remote
On my localhost this works fine $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); while ($row = mysql_fetch_assoc($result)) { but on my remote i get a mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Can someone expalin the problem? PHP version problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: local v remote
blueboy wrote: On my localhost this works fine $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); while ($row = mysql_fetch_assoc($result)) { but on my remote i get a mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Can someone expalin the problem? PHP version problem? No. It's MySQL problem. If it works fine locally, then make sure the table structure is the same on your remote database as it is on your local database. --- mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS) or die(mysql_error()); --- Using that die statement will also help while debugging your script as it will print out any errors that are caused by your SQL statement. Which you then ask some mysql people if that is the case. Darren -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploading really big files
Richard Lynch wrote: On Wed, May 30, 2007 8:47 am, Angelo Zanetti wrote: We need to develop a system where we can upload really big files. IE 15 - 25 Mb. You're pushing the limit on user patience and browser timeouts... So I know you can set the limit of the upload thats not a problem, I know a problem that we might experience is that the browser might time out. Is there any way around this? Nope. The browser gets tired of waiting around for the upload to complete because your server is too slow/busy, and the user has a very bad experience. file upload was grafted onto HTTP rather late in the game, and shows the scars badly. and also are there other problems I might encounter? Woof. Yes, there are many problems you might encounter :-) Users on slow/flaky connectionns will never have a good experience with HTTP file upload. Give them FTP or SCP or something that is more stable and will re-try. You also have to consider what users might choose to upload that is not what you wanted. There are all kinds of people out there looking to upload interesting content that you don't actually want, most likely. There is a Flikr book out there that might have some insight for you. They obviously dealt with this already, and wrote a whole book all about Flikr, so it's probably got something in there covering this. thanks for the replies. But how does a site like: http://www.yousendit.com/ do the upload of really huge files? Normal upload? thanks -- Angelo Zanetti Systems developer *Telephone:* +27 (021) 469 1052 *Mobile:* +27 (0) 72 441 3355 *Fax:*+27 (0) 86 681 5885 * Web:* http://www.zlogic.co.za *E-Mail:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploading really big files
Zoltán Németh wrote: 2007. 05. 30, szerda keltezéssel 15.47-kor Angelo Zanetti ezt írta: Dear all We need to develop a system where we can upload really big files. IE 15 - 25 Mb. So I know you can set the limit of the upload thats not a problem, I know a problem that we might experience is that the browser might time out. Is there any way around this? and also are there other problems I might encounter? http://www.php.net/manual/en/ref.info.php#ini.max-execution-time yes it does! thanks cheers -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploading really big files
On 5/30/07, Angelo Zanetti [EMAIL PROTECTED] wrote: Dear all We need to develop a system where we can upload really big files. IE 15 - 25 Mb. So I know you can set the limit of the upload thats not a problem, I know a problem that we might experience is that the browser might time out. Is there any way around this? and also are there other problems I might encounter? Thanks in advance angelo -- I've recently followed this example, for a internal use only upload. It is for ASP but you can easily modify it for PHP. You may find it useful, but i can't recommend it over ftp: http://www.codeproject.com/useritems/AJAXUpload.asp The one of the limitations of this method is that its IE only. And also you need to made some registry changes in the clients for it to work, and then it gets ugly. But hey, take a look ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Removing PHPSESSID - CGI Install
Hi, I have PHP installed as a CGI module on my server. I want to stop PHPSESSID from appearing in the URL when a users cookies are turned for just one account. My hosting company says that this is impossible - they would have to change php.ini and that would affect every account on the server. Also if PHP is changed to an Apache module then they won't support it. Is there no other way around this? Removing PHPSESSID is very important for SEO purposes... Thanks for your advice. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] local v remote
On 31/05/07, blueboy [EMAIL PROTECTED] wrote: On my localhost this works fine $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); 1. check return values, $result should not be false unless there's a problem. 2. if $result is false, check mysql_error() it'll tell you more about what's gone wrong. for example: $result = mysql_query($query) or die(mysql_error()); -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: local v remote
On my localhost this works fine $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); while ($row = mysql_fetch_assoc($result)) { but on my remote i get a mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Can someone expalin the problem? PHP version problem? Check your connection resource, as I think it's referring to the optional second variable for mysql_query($sql, $resource). How are you connecting? I assume if you're on your local machine, you're probably connecting to a locally-hosted mysql installation. Are you using the same connection string when you upload? Are you even providing one (even a background, default connection)? You should also always try to pass the resource to the mysql_query function (in most but not all cases). By not passing it, you're telling PHP to use any valid open connection it currently has associated with the script that is running: // Let's first get a connection to the database $link_identifier = mysql_connect('localhost', 'mysql_user', 'mysql_password'); // Next, look at the second, *optional* $link_identifier // This tells PHP which connection to use to perform the query // And also tells it what connection to use to get the result resource mysql_query ( string $query [, resource $link_identifier] ) If you don't provide the $link_identifier as a valid connection resource, and there's none in the background already connected, you get an invalid resource response like you received. To test, you can code $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); echo 'pTest: before query/p' while ($row = mysql_fetch_assoc($result)) { // Do stuff } /code Where you get the error output will clue you in to which function is causing the error (_query() or _fetch())? To check if a resource has connected, you can check the resource by type: if (is_resource($link_identifier) === true) { // Do database stuff that needs a connection } IMPORTANT: Do not use mysql_pconnect() without first reading about it: - http://us2.php.net/manual/en/features.persistent-connections.php - http://us2.php.net/manual/en/function.mysql-connect.php - http://us2.php.net/manual/en/function.mysql-query.php - http://us2.php.net/manual/en/function.is-resource.php -- Jared Farrish Intermediate Web Developer Denton, Tx Abraham Maslow: If the only tool you have is a hammer, you tend to see every problem as a nail. $$
[PHP] Re: Re: Re: Re: preg_match() returns false but no documentation why
Well, sure. It often appears as .* meaning none or any number of any characters. Use it when you honestly don't care what it matches. This is what I thought it meant. Your example more than clears it up. Say you want to find out if the word frog occus in a text followed by the word dog. You could match on: /\bfrog\b(.*\b)?dog\b/i / pattern delimiter \b word boundary frog1st word \b word boundary ( begin subpattern .* zero or any characters \b word boundary ) end subpattern ? zero or one instance of the preceding subpattern dog 2nd word \b word boundary / pattern delimiter i case-insensitive This guarantees that both words are bounded by word boundaries and allows any number of any characters to occur between them. (There's sort of an implicit .* before and after the pattern. Because I haven't used ^ and $ to define the beginning and end of the text, regex looks for my pattern anywhere in the text.) Very helpful! I still have questions, but a PHP mailing list probably isn't the best place. And why is it called full stop? That's what the 'period' is called in British English. http://google.ca/search?q=define%3Afull+stop In English syntax period and full stop are synonymous, and the RegEx manual is throwing dot into the same bag. That's very confusing to call it 'Full Stop' when it doesn't seem to actually correlate to the regex meaning it identifies, don't you think? Maybe to a Brit or someone who understands Commonwealth English would know (I was aware of what it meant in CE, I just woudn't have imagined to apply it here, since it looks to be descriptive). Kind've like an elephant trainer calling her elephant's trunk a boot. -- Jared Farrish Intermediate Web Developer Denton, Tx Abraham Maslow: If the only tool you have is a hammer, you tend to see every problem as a nail. $$
[PHP] file_get_contents and https
I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do this: $x = file_get_contents(https://user:[EMAIL PROTECTED]) I get: Warning: file_get_contents(https://...) [function.file-get-contents]: failed to open stream: Invalid argument in ... on line... I think I have the following correct: 1) I have php_openssl.dll present and indicated as an extension in the ext directory 2) libeay32.dll is on the Windows path What more do I need to do? Thanks, Bob Hanson -- Robert M. Hanson Professor of Chemistry St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: local v remote
Jared Farrish wrote: Jared Farrish wrote: On my localhost this works fine $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); while ($row = mysql_fetch_assoc($result)) { but on my remote i get a mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Can someone expalin the problem? PHP version problem? Check your connection resource, as I think it's referring to the optional second variable for mysql_query($sql, $resource). How are you connecting? I assume if you're on your local machine, you're probably connecting to a locally-hosted mysql installation. Are you using the same connection string when you upload? Are you even providing one (even a background, default connection)? You should also always try to pass the resource to the mysql_query function (in most but not all cases). By not passing it, you're telling PHP to use any valid open connection it currently has associated with the script that is running: // Let's first get a connection to the database $link_identifier = mysql_connect('localhost', 'mysql_user', 'mysql_password'); // Next, look at the second, *optional* $link_identifier // This tells PHP which connection to use to perform the query // And also tells it what connection to use to get the result resource mysql_query ( string $query [, resource $link_identifier] ) If you don't provide the $link_identifier as a valid connection resource, and there's none in the background already connected, you get an invalid resource response like you received. To test, you can code $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); echo 'pTest: before query/p' while ($row = mysql_fetch_assoc($result)) { // Do stuff } /code Where you get the error output will clue you in to which function is causing the error (_query() or _fetch())? To check if a resource has connected, you can check the resource by type: if (is_resource($link_identifier) === true) { // Do database stuff that needs a connection } IMPORTANT: Do not use mysql_pconnect() without first reading about it: - http://us2.php.net/manual/en/features.persistent-connections.php - http://us2.php.net/manual/en/function.mysql-connect.php - http://us2.php.net/manual/en/function.mysql-query.php - http://us2.php.net/manual/en/function.is-resource.php On my localhost this works fine $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); while ($row = mysql_fetch_assoc($result)) { but on my remote i get a mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Can someone expalin the problem? PHP version problem? Check your connection resource, as I think it's referring to the optional second variable for mysql_query($sql, $resource). huh? what? It does say not a valid _mysql result resource_ right? This is just one of those cases where $result is not a _mysql result resource_ but something else (usually the boolean false value). As many people already pointed out, mysql_error() will explain why mysql_query returned false. How are you connecting? I assume if you're on your local machine, you're probably connecting to a locally-hosted mysql installation. Are you using the same connection string when you upload? Are you even providing one (even a background, default connection)? You should also always try to pass the resource to the mysql_query function (in most but not all cases). By not passing it, you're telling PHP to use any valid open connection it currently has associated with the script that is running: // Let's first get a connection to the database $link_identifier = mysql_connect('localhost', 'mysql_user', 'mysql_password'); // Next, look at the second, *optional* $link_identifier // This tells PHP which connection to use to perform the query // And also tells it what connection to use to get the result resource mysql_query ( string $query [, resource $link_identifier] ) If you don't provide the $link_identifier as a valid connection resource, and there's none in the background already connected, you get an invalid resource response like you received. In case you didn't know, 99% of code on this planet using mysql_query does not supply the secondary argument as most code-bases don't use 1 connection in the same script. To test, you can code $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); echo 'pTest: before query/p' while ($row = mysql_fetch_assoc($result)) { // Do stuff } /code Where you get the error output will clue you in to which function is causing the error (_query() or _fetch())? it's the mysql_fetch_assoc which spits out an error as per the error message: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource To check if a resource has connected, you can check the resource by type: if (is_resource($link_identifier) ===
RE: [PHP] file_get_contents and https
[snip] I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do this: $x = file_get_contents(https://user:[EMAIL PROTECTED]) I get: Warning: file_get_contents(https://...) [function.file-get-contents]: failed to open stream: Invalid argument in ... on line... [/snip] The warning that you get is Invalid argument... Have you read http://us2.php.net/file_get_contents to make sure that you are including all needed arguments? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents and https
Thanks, Jay. I tried it first with a simple http://; call, and that worked fine. So unless https:... requires something additional in the way of arguments, that doesn't seem to be the issue. I'm hoping someone who has done this remembers what special installation issues there might be. When I look on the web I see lots of discussion, but it's pretty hard to figure out how much of it is currently applicable and how much of it is ancient history. Bob Jay Blanchard wrote: [snip] I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do this: $x = file_get_contents(https://user:[EMAIL PROTECTED]) I get: Warning: file_get_contents(https://...) [function.file-get-contents]: failed to open stream: Invalid argument in ... on line... [/snip] The warning that you get is Invalid argument... Have you read http://us2.php.net/file_get_contents to make sure that you are including all needed arguments? The URL for file_get_contents doesn't give many clues to its use with https. -- Robert M. Hanson Professor of Chemistry St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents and https
On 5/31/07, Stut [EMAIL PROTECTED] wrote: Bob Hanson wrote: Thanks, Jay. I tried it first with a simple http://; call, and that worked fine. So unless https:... requires something additional in the way of arguments, that doesn't seem to be the issue. I'm hoping someone who has done this remembers what special installation issues there might be. When I look on the web I see lots of discussion, but it's pretty hard to figure out how much of it is currently applicable and how much of it is ancient history. Was PHP built with openssl enabled? If not, that's ya problem. phpinfo() is your friend. -Stut Jay Blanchard wrote: [snip] I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do this: $x = file_get_contents(https://user:[EMAIL PROTECTED]) I get: Warning: file_get_contents(https://...) [function.file-get-contents]: failed to open stream: Invalid argument in ... on line... [/snip] The warning that you get is Invalid argument... Have you read http://us2.php.net/file_get_contents to make sure that you are including all needed arguments? The URL for file_get_contents doesn't give many clues to its use with https. David
Re: [PHP] file_get_contents and https
Bob Hanson wrote: Thanks, Jay. I tried it first with a simple http://; call, and that worked fine. So unless https:... requires something additional in the way of arguments, that doesn't seem to be the issue. I'm hoping someone who has done this remembers what special installation issues there might be. When I look on the web I see lots of discussion, but it's pretty hard to figure out how much of it is currently applicable and how much of it is ancient history. Was PHP built with openssl enabled? If not, that's ya problem. -Stut Jay Blanchard wrote: [snip] I am new to PHP; using Apache 2.2 and PHP 5/Windows. I'd like to do this: $x = file_get_contents(https://user:[EMAIL PROTECTED]) I get: Warning: file_get_contents(https://...) [function.file-get-contents]: failed to open stream: Invalid argument in ... on line... [/snip] The warning that you get is Invalid argument... Have you read http://us2.php.net/file_get_contents to make sure that you are including all needed arguments? The URL for file_get_contents doesn't give many clues to its use with https. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: find (matching) person in other table
Jared Farrish wrote: On 5/30/07, Afan Pasalic [EMAIL PROTECTED] wrote: email has to match in total. [EMAIL PROTECTED] and [EMAIL PROTECTED] are NOT the same in my case. thanks jared, If you can match a person by their email, why not just SELECT by email only (and return the persons information)? 'cause some members can be added to database by administrator and maybe they don't have email address at all. or several memebers can use the same email address ([EMAIL PROTECTED]) and then macthing last name is kind of required. that's how it works now and can't change it. Consider, as well, that each time you're calling a database, you're slowing down the response of the page. So, while making a bunch of small calls might not seem like that much, consider: ||| x ||| ||| a ||| ||| b ||| Versus ||| x, a, b ||| The letters represent the request/response data (what you're giving to get, then get back), and the pipes (|) are the overhead to process, send, receive (on DB), process (on DB), send (on DB), receive, process, return to code. The overhead and latency used to complete one request makes it a quicker, less heavy operation. If you did the first a couple hundred or thousand times, I would bet your page would drag to a halt while it loads... agree. now, I have to figure it out HOW? :-) I was looking at levenshtein, though, I think the richard's solution is just enough: select member_id, first_name, last_name, email, ..., (5*(first_name='$first_name) + 2*(first_name='$first_name')) as score from members where score 0 though, I'm getting error: Unknown column 'score' in where clause?!? thanks jared. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: find (matching) person in other table
On 5/31/07, Afan Pasalic [EMAIL PROTECTED] wrote: Jared Farrish wrote: On 5/30/07, Afan Pasalic [EMAIL PROTECTED] wrote: email has to match in total. [EMAIL PROTECTED] and [EMAIL PROTECTED] are NOT the same in my case. thanks jared, If you can match a person by their email, why not just SELECT by email only (and return the persons information)? 'cause some members can be added to database by administrator and maybe they don't have email address at all. or several memebers can use the same email address ([EMAIL PROTECTED]) and then macthing last name is kind of required. that's how it works now and can't change it. Consider, as well, that each time you're calling a database, you're slowing down the response of the page. So, while making a bunch of small calls might not seem like that much, consider: ||| x ||| ||| a ||| ||| b ||| Versus ||| x, a, b ||| The letters represent the request/response data (what you're giving to get, then get back), and the pipes (|) are the overhead to process, send, receive (on DB), process (on DB), send (on DB), receive, process, return to code. The overhead and latency used to complete one request makes it a quicker, less heavy operation. If you did the first a couple hundred or thousand times, I would bet your page would drag to a halt while it loads... agree. now, I have to figure it out HOW? :-) I was looking at levenshtein, though, I think the richard's solution is just enough: select member_id, first_name, last_name, email, ..., (5*(first_name='$first_name) + 2*(first_name='$first_name')) as score from members where score 0 though, I'm getting error: Unknown column 'score' in where clause?!? thanks jared. Try using the keyword 'having' rather than 'where'. You can't use an alias in a where clause. David
Re: [PHP] Re: find (matching) person in other table
David Giragosian wrote: On 5/31/07, Afan Pasalic [EMAIL PROTECTED] wrote: Jared Farrish wrote: On 5/30/07, Afan Pasalic [EMAIL PROTECTED] wrote: email has to match in total. [EMAIL PROTECTED] and [EMAIL PROTECTED] are NOT the same in my case. thanks jared, If you can match a person by their email, why not just SELECT by email only (and return the persons information)? 'cause some members can be added to database by administrator and maybe they don't have email address at all. or several memebers can use the same email address ([EMAIL PROTECTED]) and then macthing last name is kind of required. that's how it works now and can't change it. Consider, as well, that each time you're calling a database, you're slowing down the response of the page. So, while making a bunch of small calls might not seem like that much, consider: ||| x ||| ||| a ||| ||| b ||| Versus ||| x, a, b ||| The letters represent the request/response data (what you're giving to get, then get back), and the pipes (|) are the overhead to process, send, receive (on DB), process (on DB), send (on DB), receive, process, return to code. The overhead and latency used to complete one request makes it a quicker, less heavy operation. If you did the first a couple hundred or thousand times, I would bet your page would drag to a halt while it loads... agree. now, I have to figure it out HOW? :-) I was looking at levenshtein, though, I think the richard's solution is just enough: select member_id, first_name, last_name, email, ..., (5*(first_name='$first_name) + 2*(first_name='$first_name')) as score from members where score 0 though, I'm getting error: Unknown column 'score' in where clause?!? thanks jared. Try using the keyword 'having' rather than 'where'. You can't use an alias in a where clause. David Yup. that works! :-) Thanks David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents and https
Problem solved. Thank you all very much for such quick responses. The solution was to get ssleay32.dll from the PHP 5 ZIP distribution and put in my PHP directory. For the record: With Windows and PHP 5 all that is needed to use the https protocol in file_get_contents is to make sure that both libeay32.dll ssleay32.dll are on the Windows path, which in my case includes the path to my PHP directory, so I just put them there. Excellent! Many thanks. Bob Hanson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How do YOU initialize the form variables?
Hello, If I have an HTML form with input, example: username lastname mobile .. and so on ... Example simple initialization: // POST $username = $_POST['username']; $lastname = $_POST['lastname']; $mobile = $_POST['mobile']; What is the most popular method for making PHP initialize the many variables on that form? I'm looking to get an understanding of 95% of the possible ways developers are initializing their php variables from a form post. How do YOU initialize the form variables? If you prefer to post your reply direct to info @ phpyellow.com instead of this list, or both, I am happy to receive your comment. Sincerely, Rob http://phpyellow.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 500 server error
my .htacces file only contains 2 lines allowoverride all php_flag display_errors on I get a 500 server error, any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Attempting to search a MySQL database from PHP not working
Hi Everyone, I am attempting to setup a search field on a database application I'm dinking around with and running into problems that I'm hoping someone might be able to shed some light on. Here is the code I am using to display the results of the search: echo ('table border=1'); echo trthFirst Name/ththAuthor/ththPages/th/tr; $result_row[] = mysql_query($query) or die(mysql_error()); echo Result_row dump: $result_row BR; $num=mysql_numrows($result); echo Num dump: $num BR; $i= 0; while($i $num) { echo trtd; echo $result_row[0] . '/tdtd'; echo $result_row[1] . '/tdtd'; echo $result_row[2] . '/td/tr'; $i++; } echo (/table); the problem is instead of printing out the actual results it prints out 6 fields that say: Resource id #5 the query I'm using is: SELECT FName, LName, Add1, Add2 FROM current WHERE FName like '%jason%' which works in MySQL I can't find any errors in my log files to even give me a hint as to what is going on. If someone could take a look I would greatly appreciate it. Jason Pruim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Attempting to search a MySQL database from PHP not working
Em Quinta 31 Maio 2007 16:25, Jason Pruim escreveu: Hi Everyone, I am attempting to setup a search field on a database application I'm dinking around with and running into problems that I'm hoping someone might be able to shed some light on. Here is the code I am using to display the results of the search: echo ('table border=1'); echo trthFirst Name/ththAuthor/ththPages/th/tr; $result_row[] = mysql_query($query) or die(mysql_error()); echo Result_row dump: $result_row BR; $num=mysql_numrows($result); echo Num dump: $num BR; $i= 0; /* while($i $num) { */ $result=$result_row[0]; while($result_row = mysql_fetch_array($result) { echo trtd; echo $result_row[0] . '/tdtd'; echo $result_row[1] . '/tdtd'; echo $result_row[2] . '/td/tr'; $i++; } echo (/table); the problem is instead of printing out the actual results it prints out 6 fields that say: Resource id #5 the query I'm using is: SELECT FName, LName, Add1, Add2 FROM current WHERE FName like '%jason%' which works in MySQL I can't find any errors in my log files to even give me a hint as to what is going on. If someone could take a look I would greatly appreciate it. HTH -- Davi Vidal [EMAIL PROTECTED] [EMAIL PROTECTED] -- Religion, ideology, resources, land, spite, love or just because... No matter how pathetic the reason, it's enough to start a war. Por favor não faça top-posting, coloque a sua resposta abaixo desta linha. Please don't do top-posting, put your reply below the following line. pgpoZaZKvtBnT.pgp Description: PGP signature
Re: [PHP] Attempting to search a MySQL database from PHP not working
On Thu, 2007-05-31 at 15:25 -0400, Jason Pruim wrote: Hi Everyone, I am attempting to setup a search field on a database application I'm dinking around with and running into problems that I'm hoping someone might be able to shed some light on. Here is the code I am using to display the results of the search: echo ('table border=1'); echo trthFirst Name/ththAuthor/ththPages/th/tr; $result_row[] = mysql_query($query) or die(mysql_error()); mysql_query() doesn't return the rows. Go read the manual. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Attempting to search a MySQL database from PHP not working
Your problem is this: $result_row[] = mysql_query($query) or die(mysql_error()); ...you are assigning a query to a variable. What you need to do is something like this: $result = mysql_query($query) or die(mysql_error()); while ($result_row = mysql_fetch_array($result)) { . }
Re: [PHP] How do YOU initialize the form variables?
On Thu, 2007-05-31 at 10:57 -0700, [EMAIL PROTECTED] wrote: Hello, If I have an HTML form with input, example: username lastname mobile .. and so on ... Example simple initialization: // POST $username = $_POST['username']; $lastname = $_POST['lastname']; $mobile = $_POST['mobile']; What is the most popular method for making PHP initialize the many variables on that form? I'm looking to get an understanding of 95% of the possible ways developers are initializing their php variables from a form post. How do YOU initialize the form variables? I use a form engine. It accepts a default values configuration and does all the grunt work for me... first time population of form values, rendering of form elements, application of any registered pre-process/validation/post-process/finalization handlers which can apply to individual fields or the entire form itself, repopulation of form data in the case of an error, etc etc. The only low level form, work I do is when I add new widgets or extend an existing widget for a specific project need. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Attempting to search a MySQL database from PHP not working
On May 31, 2007, at 3:27 PM, Davi wrote: Em Quinta 31 Maio 2007 16:25, Jason Pruim escreveu: Hi Everyone, I am attempting to setup a search field on a database application I'm dinking around with and running into problems that I'm hoping someone might be able to shed some light on. Here is the code I am using to display the results of the search: echo ('table border=1'); echo trthFirst Name/ththAuthor/ththPages/th/tr; $result_row[] = mysql_query($query) or die(mysql_error()); echo Result_row dump: $result_row BR; $num=mysql_numrows($result); echo Num dump: $num BR; $i= 0; /* while($i $num) { */ $result=$result_row[0]; while($result_row = mysql_fetch_array($result) { Worked perfectly after adding a closing ) Thanks for the tip! echo trtd; echo $result_row[0] . '/tdtd'; echo $result_row[1] . '/tdtd'; echo $result_row[2] . '/td/tr'; $i++; } echo (/table); the problem is instead of printing out the actual results it prints out 6 fields that say: Resource id #5 the query I'm using is: SELECT FName, LName, Add1, Add2 FROM current WHERE FName like '%jason%' which works in MySQL I can't find any errors in my log files to even give me a hint as to what is going on. If someone could take a look I would greatly appreciate it. HTH -- Davi Vidal [EMAIL PROTECTED] [EMAIL PROTECTED] -- Religion, ideology, resources, land, spite, love or just because... No matter how pathetic the reason, it's enough to start a war. Por favor não faça top-posting, coloque a sua resposta abaixo desta linha. Please don't do top-posting, put your reply below the following line. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ini_set() security question
There is no bug filed for this. There is only one older bug ( http://bugs.php.net/bug.php?id=38804 ) which makes me think overwriting with ini_set() shouldn't be possible! Richard Lynch schrieb: On Wed, May 30, 2007 3:34 pm, Samuel Vogel wrote: And what happens if you try to allocate 3M of data? $foo = str_repeat('.', 3145728); Nothing. It does it without any errors. I can allocate up to 20MB (well a little bit less of course). Check http://bugs.php.net and see if it's a known issue or an exception to the php_admin_* rule or... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Attempting to search a MySQL database from PHP not working
Em Quinta 31 Maio 2007 16:38, Jason Pruim escreveu: while($result_row = mysql_fetch_array($result) { Worked perfectly after adding a closing ) Thanks for the tip! Forgive me for that!!! #'_'# I *always* forget the closing )... =P -- Davi Vidal [EMAIL PROTECTED] [EMAIL PROTECTED] -- Religion, ideology, resources, land, spite, love or just because... No matter how pathetic the reason, it's enough to start a war. Por favor não faça top-posting, coloque a sua resposta abaixo desta linha. Please don't do top-posting, put your reply below the following line. pgpH2cHUfJswa.pgp Description: PGP signature
Re: [PHP] 500 server error
blueboy wrote: my .htacces file only contains 2 lines allowoverride all php_flag display_errors on I get a 500 server error, any ideas? Check the Apache error log - that usually has more information on what's wrong. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 500 server error
On 5/29/07, Stut [EMAIL PROTECTED] wrote: blueboy wrote: my .htacces file only contains 2 lines allowoverride all php_flag display_errors on I get a 500 server error, any ideas? Check the Apache error log - that usually has more information on what's wrong. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Sounds like you have the good ol' fashion AllowOverride not allowed here problem. This is because it's a core directive, which can only be used in httpd.conf. AllowOverride is actually the directive used to allow .htaccess files to be read, and what options can be set. If you were able to add that to the .htaccess file itself, it would mean that the admin had no control over what could and could not be done with the server as a whole. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Error logging
We have the following php.ini settings: error_reporting = E_ALL display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off on a SuSE 10.1 server and the errors are being logged to /var/log/apache2/error_log (although I can't seem to find a setting that is making that happen.) parse errors ARE being logged to this file and that would be extremely useful information for students to be able to have when trying to find problems in their scripts. I can't just make that file readable to them. So, I had students create a logs directory within their file area and set the permissions so that the server can to it. I have them adding the following to the script(s) that they wish to troubleshoot: ini_set(log_errors, On); ini_set(error_reporting, E_ALL); ini_set(error_log, logs/error_log); Parse errors are not being written to their personal log file, though. Why not?? About the only going in there are NOTICE level entries. Thanks. Clark W. Alexander -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error logging
Clark Alexander wrote: We have the following php.ini settings: error_reporting = E_ALL display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off on a SuSE 10.1 server and the errors are being logged to /var/log/apache2/error_log (although I can't seem to find a setting that is making that happen.) parse errors ARE being logged to this file and that would be extremely useful information for students to be able to have when trying to find problems in their scripts. I can't just make that file readable to them. So, I had students create a logs directory within their file area and set the permissions so that the server can to it. I have them adding the following to the script(s) that they wish to troubleshoot: ini_set(log_errors, On); ini_set(error_reporting, E_ALL); ini_set(error_log, logs/error_log); Parse errors are not being written to their personal log file, though. Why not?? About the only going in there are NOTICE level entries. does log/error_log exist? does the webserver have write permissions on that file? Thanks. Clark W. Alexander -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error logging
Yes, it does write to the file, but the only things going in there are notice type entries. Also, for further information, it is php 5.1.2 using the Suse rpm. On 5/31/07 5:14 PM, in article [EMAIL PROTECTED], Jochem Maas [EMAIL PROTECTED] wrote: Clark Alexander wrote: We have the following php.ini settings: error_reporting = E_ALL display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off on a SuSE 10.1 server and the errors are being logged to /var/log/apache2/error_log (although I can't seem to find a setting that is making that happen.) parse errors ARE being logged to this file and that would be extremely useful information for students to be able to have when trying to find problems in their scripts. I can't just make that file readable to them. So, I had students create a logs directory within their file area and set the permissions so that the server can to it. I have them adding the following to the script(s) that they wish to troubleshoot: ini_set(log_errors, On); ini_set(error_reporting, E_ALL); ini_set(error_log, logs/error_log); Parse errors are not being written to their personal log file, though. Why not?? About the only going in there are NOTICE level entries. does log/error_log exist? does the webserver have write permissions on that file? Thanks. Clark W. Alexander -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error logging
Upon review, I also discover that fatal error entries are being made as well. On 5/31/07 5:14 PM, in article [EMAIL PROTECTED], Jochem Maas [EMAIL PROTECTED] wrote: Clark Alexander wrote: We have the following php.ini settings: error_reporting = E_ALL display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off on a SuSE 10.1 server and the errors are being logged to /var/log/apache2/error_log (although I can't seem to find a setting that is making that happen.) parse errors ARE being logged to this file and that would be extremely useful information for students to be able to have when trying to find problems in their scripts. I can't just make that file readable to them. So, I had students create a logs directory within their file area and set the permissions so that the server can to it. I have them adding the following to the script(s) that they wish to troubleshoot: ini_set(log_errors, On); ini_set(error_reporting, E_ALL); ini_set(error_log, logs/error_log); Parse errors are not being written to their personal log file, though. Why not?? About the only going in there are NOTICE level entries. does log/error_log exist? does the webserver have write permissions on that file? Thanks. Clark W. Alexander -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error logging
On Thu, May 31, 2007 3:25 pm, Clark Alexander wrote: We have the following php.ini settings: error_reporting = E_ALL display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off on a SuSE 10.1 server and the errors are being logged to /var/log/apache2/error_log (although I can't seem to find a setting that is making that happen.) parse errors ARE being logged to this file and that would be extremely useful information for students to be able to have when trying to find problems in their scripts. I can't just make that file readable to them. So, I had students create a logs directory within their file area and set the permissions so that the server can to it. I have them adding the following to the script(s) that they wish to troubleshoot: ini_set(log_errors, On); ini_set(error_reporting, E_ALL); ini_set(error_log, logs/error_log); Parse errors are not being written to their personal log file, though. Why not?? About the only going in there are NOTICE level entries. Step 1: PHP reads and parses script. Errors are logged to the current php.ini settings, the default Apache log. Step 2: PHP begins processing script. log is changed to student's individual log. Step 3: Any script errors AFTER 2 end up in student logs. As you can see, any parse errors will end up in Apache logs, because the student's code has not begun to run. PHP halts on a parse error, so it never even executes the ini_set calls in that case. If there are no parse errors, and if the ini_set happens at the TOP of the script, then the remaining errors are logged to where ini_set has changed the values. If you have .htaccess turned on in httpd.conf, and if you can teach the students to edit .htaccess correctly, they could use: php_value error_log /full/path/to/student/directory/logs/error_log Because this will be applied by Apache *before* it begins executing the script (almost for sure) it should, I think, come much closer to what you want to achieve. There may still be some kind of PHP total failure error that could occur before Apache runs through the .htaccess file, but I can't begin to imagine what that would be, short of a PHP segfault of some kind, with nasty grunge left over from a previous execution causing the real problem... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do YOU initialize the form variables?
On Thu, May 31, 2007 12:57 pm, [EMAIL PROTECTED] wrote: username lastname mobile .. and so on ... Example simple initialization: // POST $username = $_POST['username']; $lastname = $_POST['lastname']; $mobile = $_POST['mobile']; I personally go with: ?php $username = isset($_POST['username']) ? $_POST['username'] : ''; $username_html = htmlentities($username); ? input name=username value=?php echo $username_html? / I dunno that you want to go with what 95% of people go with -- There's a LOT of bad scripts out there... Maybe you should be looking at the best 5% of PHP coders, and see how they do it instead. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Attempting to search a MySQL database from PHP not working
On Thu, May 31, 2007 2:25 pm, Jason Pruim wrote: Hi Everyone, I am attempting to setup a search field on a database application I'm dinking around with and running into problems that I'm hoping someone might be able to shed some light on. Here is the code I am using to display the results of the search: echo ('table border=1'); echo trthFirst Name/ththAuthor/ththPages/th/tr; $result_row[] = mysql_query($query) or die(mysql_error()); I also have to wonder why you are building an array of query result resources... You probably could do this with just one SQL query and some order by clauses to get what you want, without hitting the DB so much. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ini_set() security question
File a bug report then, and see what happens... But you may want to test with most recent versions if you are not already on current PHP versions. On Thu, May 31, 2007 2:46 pm, Samuel Vogel wrote: There is no bug filed for this. There is only one older bug ( http://bugs.php.net/bug.php?id=38804 ) which makes me think overwriting with ini_set() shouldn't be possible! Richard Lynch schrieb: On Wed, May 30, 2007 3:34 pm, Samuel Vogel wrote: And what happens if you try to allocate 3M of data? $foo = str_repeat('.', 3145728); Nothing. It does it without any errors. I can allocate up to 20MB (well a little bit less of course). Check http://bugs.php.net and see if it's a known issue or an exception to the php_admin_* rule or... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 500 server error
On Thu, May 31, 2007 2:10 pm, blueboy wrote: my .htacces file only contains 2 lines allowoverride all php_flag display_errors on I get a 500 server error, any ideas? Check Apache error_log to be sure, and ask on Apache mailing list... But I will point out that: The purpose of AllowOverride in httpd.conf is to define what is allowed to be over-ridden in .htaccess If AllowOverride worked in .htaccess, then that gives the power to decide what to override in .htaccess to the people who can edit .htaccess. That makes the whole purpose of AllowOverride moot, as now the end user can override what they are allowed to override and then override what they weren't supposed to be able to overrirde in the first place. Thus, I'm going to go out on a limb here, and without actually reading Apache docs, nor your error_log file, I will predict that AllowOverride is not allowed within .htaccess :-) PS I don't think AllowOverride has any bearing on php_value or php_flag at all... But maybe it needs to be set in httpd.conf to have +Options or somesuch... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing PHPSESSID - CGI Install
On Thu, May 31, 2007 5:55 am, Shaun wrote: I have PHP installed as a CGI module on my server. I want to stop PHPSESSID from appearing in the URL when a users cookies are turned for just one account. My hosting company says that this is impossible - they would have to change php.ini and that would affect every account on the server. Also if PHP is changed to an Apache module then they won't support it. Is there no other way around this? Perhaps you can turn it off in .htaccess Does CGI utilize .htaccess??? Perhaps you could get them to use suExec and run your CGI with a different user and environment (i.e., different php.ini) if they don't want to use Module. Removing PHPSESSID is very important for SEO purposes... Really? I'd expect that the search engine authors are smart enough to not be messed up by something as common as PHPSESSID in a URL. Can you provide any objective independent study reference to support such a claim? Much SEO information out there is utter crap... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploading really big files
On Thu, May 31, 2007 5:07 am, Angelo Zanetti wrote: thanks for the replies. But how does a site like: http://www.yousendit.com/ do the upload of really huge files? Normal upload? I guess they've already worked through all the issues, assuming their service actually works... Or, perhaps, they don't really care about users on slow/flaky connections, and simply refund anybody who is unhappy. I dunno. Ask them. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] local v remote
On Thu, May 31, 2007 4:50 am, blueboy wrote: On my localhost this works fine $result= mysql_query(SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS); while ($row = mysql_fetch_assoc($result)) { but on my remote i get a mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Can someone expalin the problem? PHP version problem? The problem is probably that you never even managed to connect to the MySQL database in the first place... But it could be something else entirely. We can't tell you, but you can find out by using the mysql_error() function a lot. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: local v remote
On Thu, May 31, 2007 8:07 am, M. Sokolewicz wrote: In case you didn't know, 99% of code on this planet using mysql_query does not supply the secondary argument as most code-bases don't use 1 connection in the same script. That does not make it a Good Practice... I spent days fixing somebody else's code who thought they were opening a second connection (not) and then were closing it (yep) but they were actually closing *MY* database connection, because they were too lazy to type that second arg. I personally think you should never, ever, ever, write code that relies on the default open connection. Sooner or later, the project will grow, morph or merge into something where you'll get your wires crossed. It costs only a few keystrokes in a few places to do it right. YMMV -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Streaming download to IE doesn't work
On Wed, May 30, 2007 9:16 pm, Daniel Kasak wrote: On Wed, 2007-05-30 at 13:40 -0500, Richard Lynch wrote: On Tue, May 29, 2007 6:37 pm, Daniel Kasak wrote: Actually, that blog had absolutely nothing to do with my problem ( thanks for RTFP!). Not only that, but the recommendation that I construct URLs: http://address.com/script/thing=2/this=3/that=4/download.txt is patently ridiculous. Why? It's excessively complex for no actual benefit. It means you have to have extra code to 'explode' out the various parts of the URL. Even after reading your description of the code that handles this, it was non-obvious what it was for. If I returned to this 2 years later ( or God forbid, someone else had to look at it ), they wouldn't have a clue what it was doing, or why. But also, as I noted, this 'solution' is to a different problem - the problem of IE not naming downloads properly. IE names them properly for me ... it just doesn't download them ( if over SSL ). Actually, it solves more than just IE not naming them properly. It also solves some versions of IE not opening PDF from FDF links when the user has chosen to not embed PDF reader in browser bug. It also solved a host of other IE bugs over the years. It would not surprise me in the least if it didn't solve your bug as well, actually. IE is just plain flaky with its stupid attempts to guess about content type and intent from URL analysis. I'm sorry you found a simple loop to look at the URL and pull the values into an array confusing... :-v TETO -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using mysql_escape_string with implode() !!
On Wed, May 30, 2007 9:55 pm, Jim Lucas wrote: Greg Donald wrote: On 5/30/07, Richard Lynch [EMAIL PROTECTED] wrote: You want to use mysql_escape_string, and NOT addslashes and NOT Magic Quotes. function slashes( $var ) { if( is_array( $var ) ) { return array_map( 'slashes', $var ); } else { return mysql_real_escape_string( $var ); } } Say I wanted to use this on something other than $_GET, $_POST, $_COOKIE? Would it not be better practice to do this the other way around? function slashes ( $var ) { if ( is_scalar($var) ) { return mysql_real_escape_string( $var ); } else { return array_map( 'slashes', $var ); } } This way, even if someone passes something that is not an array, but still not processable by mysql_real_escape_string(), it won't foul up the processor. set_magic_quotes_runtime( 0 ); if( get_magic_quotes_gpc() == 0 ) { $_GET = isset( $_GET ) ? array_map( 'slashes', $_GET ) : array(); $_POST = isset( $_POST ) ? array_map( 'slashes', $_POST ) : array(); $_COOKIE = isset( $_COOKIE ) ? array_map( 'slashes', $_COOKIE ) : array(); } Well, if it's not a scalar, and it's not an array, and you call array_map on it, things could get very ugly very fast... I'm not sure what other datatypes you might try to pass in, that PHP won't type-juggle to a string when it goes to mysql_real_escape_string... Exactly what other data are you planning on calling 'slashes' on? -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec dont work for svn
On Wed, May 30, 2007 4:30 pm, Manolet Gmail wrote: 2007/5/30, Richard Lynch [EMAIL PROTECTED]: On Tue, May 29, 2007 10:44 am, Manolet Gmail wrote: 2007/5/28, Greg Donald [EMAIL PROTECTED]: On 5/28/07, Manolet Gmail [EMAIL PROTECTED] wrote: but this doesnt work: exec(svn update,$out); exec(svn update, $out, $error); if ($error) echo OS Error: $error. Use perror $error in shell to get message; give me error 1: OS error code 1: Operation not permitted also, the checkout was did by other user. but i do chmod -R 777 * as root. so what i can do ? [shudder] Having a bunch of root owned files set to 777 is definitely the wrong way to go... Think about it for awhile. As far as the OS Error goes, we don't even know exactly what is wrong here... Maybe the PHP user can't run svn maybe the PHP user can run svn, but can't alter the hidden .svn files that you probably didn't chmod. Maybe... I'd suggest doing an 'su' to the PHP User and trying to do svn update on the command line, before you put PHP into the mix. You also should use a full path to 'svn' and you need to be in the right directory before you do 'svn', so I'd put a 'cd /whatever; svn up' instead. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match() returns false but no documentation why
On Wed, May 30, 2007 4:25 pm, Jared Farrish wrote: On 5/30/07, Richard Lynch [EMAIL PROTECTED] wrote: If you can't find them documented, print them out: echo PREG_NO_ERROR: ', PREG_NO_ERROR, '; Doh! PREG_NO_ERROR: 0 PREG_INTERNAL_ERROR: 1 PREG_BACKTRACK_LIMIT_ERROR: 2 PREG_RECURSION_LIMIT_ERROR: 3 PREG_BAD_UTF8_ERROR: 4 So apparently, PREG_NO_ERROR is synonymous for you need delimiters, egghead. I think the error mechanism you are checking never even had a chance to kick in... It's kind of like an in-flight warning system for an airplane that never got off the ground... It's going to keep saying no error while the plane burns to a cinder if it never got turned on in the first place as it never got in the air. preg_match(/^ldap(s)?:\/\/([a-zA-Z0-9-])+\.[a-zA-Z.]{2,5}$/,$this-server) Try using | instead of / for your delimiter, so that you don't have to dink around with escaping the / in the pattern... You only have to escape / if it's part if it's the pattern delimiter? Makes the code less cluttered and more clear. Fo' sho'. Yup. You only need to escape the delimiter you chose if it's in the pattern. Or, looking at it from the pattern point of view: Pick a delimiter you are unlikely to ever need in the pattern, so you won't need to escape it. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match() returns false but no documentation why
On Wed, May 30, 2007 5:04 pm, Jim Lucas wrote: btw: why is there a period in the second pattern? Also, why are you allowing for uppercase letters when the RFC's don't allow them? LDAP URL domain can't be ALL CAPS?! Last I heard, domain names were case-insensitive in every other URL... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Re: Re: Re: preg_match() returns false but no documentation why
On Thu, May 31, 2007 7:26 am, Jared Farrish wrote: That's what the 'period' is called in British English. http://google.ca/search?q=define%3Afull+stop In English syntax period and full stop are synonymous, and the RegEx manual is throwing dot into the same bag. That's very confusing to call it 'Full Stop' when it doesn't seem to actually correlate to the regex meaning it identifies, don't you think? Maybe to a Brit or someone who understands Commonwealth English would know (I was aware of what it meant in CE, I just woudn't have imagined to apply it here, since it looks to be descriptive). Kind've like an elephant trainer calling her elephant's trunk a boot. @Brits: So is a comma or semi-colon called a Half Stop :-) PS Nitpik: Regex Coach also runs very nicely on Linux, not just Windows, thank goodness. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: find (matching) person in other table
MySQL doesn't let you use the calculated values (score) in the where clause. PostgreSQL does, as I recall. Sorry. You may be able to get around that with: Do a GROUP BY on something unique, so the GROUP BY is pointless, but then you can use HAVING score 0 Use a sub-query in MySQL 4.mumble or higher, and the outer query can use 'score' to get rid of the 0-point non-matches Build up the expression for $score and $where at the same time like: $where = ' 0 '; $score = ' 0 '; $where .= OR lastname = '$lastname'; $score .= + 5 * (lastname = '$lastame' ) ; $where .= OR firstname = '$firstname' ; $score .= + 2 * (firstname = '$firstname' ) ; This gets tiresome to type, but is least confusing to non-programmers... On Thu, May 31, 2007 9:36 am, Afan Pasalic wrote: Jared Farrish wrote: On 5/30/07, Afan Pasalic [EMAIL PROTECTED] wrote: email has to match in total. [EMAIL PROTECTED] and [EMAIL PROTECTED] are NOT the same in my case. thanks jared, If you can match a person by their email, why not just SELECT by email only (and return the persons information)? 'cause some members can be added to database by administrator and maybe they don't have email address at all. or several memebers can use the same email address ([EMAIL PROTECTED]) and then macthing last name is kind of required. that's how it works now and can't change it. Consider, as well, that each time you're calling a database, you're slowing down the response of the page. So, while making a bunch of small calls might not seem like that much, consider: ||| x ||| ||| a ||| ||| b ||| Versus ||| x, a, b ||| The letters represent the request/response data (what you're giving to get, then get back), and the pipes (|) are the overhead to process, send, receive (on DB), process (on DB), send (on DB), receive, process, return to code. The overhead and latency used to complete one request makes it a quicker, less heavy operation. If you did the first a couple hundred or thousand times, I would bet your page would drag to a halt while it loads... agree. now, I have to figure it out HOW? :-) I was looking at levenshtein, though, I think the richard's solution is just enough: select member_id, first_name, last_name, email, ..., (5*(first_name='$first_name) + 2*(first_name='$first_name')) as score from members where score 0 though, I'm getting error: Unknown column 'score' in where clause?!? thanks jared. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using mysql_escape_string with implode() !!
Richard Lynch wrote: On Wed, May 30, 2007 9:55 pm, Jim Lucas wrote: Greg Donald wrote: On 5/30/07, Richard Lynch [EMAIL PROTECTED] wrote: You want to use mysql_escape_string, and NOT addslashes and NOT Magic Quotes. function slashes( $var ) { if( is_array( $var ) ) { return array_map( 'slashes', $var ); } else { return mysql_real_escape_string( $var ); } } Say I wanted to use this on something other than $_GET, $_POST, $_COOKIE? Would it not be better practice to do this the other way around? function slashes ( $var ) { if ( is_scalar($var) ) { return mysql_real_escape_string( $var ); } else { return array_map( 'slashes', $var ); } } This way, even if someone passes something that is not an array, but still not processable by mysql_real_escape_string(), it won't foul up the processor. set_magic_quotes_runtime( 0 ); if( get_magic_quotes_gpc() == 0 ) { $_GET = isset( $_GET ) ? array_map( 'slashes', $_GET ) : array(); $_POST = isset( $_POST ) ? array_map( 'slashes', $_POST ) : array(); $_COOKIE = isset( $_COOKIE ) ? array_map( 'slashes', $_COOKIE ) : array(); } Well, if it's not a scalar, and it's not an array, and you call array_map on it, things could get very ugly very fast... I'm not sure what other datatypes you might try to pass in, that PHP won't type-juggle to a string when it goes to mysql_real_escape_string... Exactly what other data are you planning on calling 'slashes' on? Things that will work with mysql_real_escape_string() boolean, integer, double, float, string, NULL Things that won't work with mysql_real_escape_string() array, object, resource id -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Unknown -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: find (matching) person in other table
Jumping in late so forgive if I'm mistaken, but can't you just use HAVING in place of WHERE select member_id, first_name, last_name, email, ..., (5*(first_name='$first_name) + 2*(first_name='$first_name')) as score from members HAVING score 0 -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thursday, May 31, 2007 3:42 PM To: Afan Pasalic Cc: Jared Farrish; php-general@lists.php.net Subject: Re: [PHP] Re: find (matching) person in other table MySQL doesn't let you use the calculated values (score) in the where clause. PostgreSQL does, as I recall. Sorry. You may be able to get around that with: Do a GROUP BY on something unique, so the GROUP BY is pointless, but then you can use HAVING score 0 Use a sub-query in MySQL 4.mumble or higher, and the outer query can use 'score' to get rid of the 0-point non-matches Build up the expression for $score and $where at the same time like: $where = ' 0 '; $score = ' 0 '; $where .= OR lastname = '$lastname'; $score .= + 5 * (lastname = '$lastame' ) ; $where .= OR firstname = '$firstname' ; $score .= + 2 * (firstname = '$firstname' ) ; This gets tiresome to type, but is least confusing to non-programmers... On Thu, May 31, 2007 9:36 am, Afan Pasalic wrote: Jared Farrish wrote: On 5/30/07, Afan Pasalic [EMAIL PROTECTED] wrote: email has to match in total. [EMAIL PROTECTED] and [EMAIL PROTECTED] are NOT the same in my case. thanks jared, If you can match a person by their email, why not just SELECT by email only (and return the persons information)? 'cause some members can be added to database by administrator and maybe they don't have email address at all. or several memebers can use the same email address ([EMAIL PROTECTED]) and then macthing last name is kind of required. that's how it works now and can't change it. Consider, as well, that each time you're calling a database, you're slowing down the response of the page. So, while making a bunch of small calls might not seem like that much, consider: ||| x ||| ||| a ||| ||| b ||| Versus ||| x, a, b ||| The letters represent the request/response data (what you're giving to get, then get back), and the pipes (|) are the overhead to process, send, receive (on DB), process (on DB), send (on DB), receive, process, return to code. The overhead and latency used to complete one request makes it a quicker, less heavy operation. If you did the first a couple hundred or thousand times, I would bet your page would drag to a halt while it loads... agree. now, I have to figure it out HOW? :-) I was looking at levenshtein, though, I think the richard's solution is just enough: select member_id, first_name, last_name, email, ..., (5*(first_name='$first_name) + 2*(first_name='$first_name')) as score from members where score 0 though, I'm getting error: Unknown column 'score' in where clause?!? thanks jared. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Re: Re: Re: preg_match() returns false but no documentation why
Richard Lynch wrote: On Thu, May 31, 2007 7:26 am, Jared Farrish wrote: That's what the 'period' is called in British English. http://google.ca/search?q=define%3Afull+stop In English syntax period and full stop are synonymous, and the RegEx manual is throwing dot into the same bag. That's very confusing to call it 'Full Stop' when it doesn't seem to actually correlate to the regex meaning it identifies, don't you think? Maybe to a Brit or someone who understands Commonwealth English would know (I was aware of what it meant in CE, I just woudn't have imagined to apply it here, since it looks to be descriptive). Kind've like an elephant trainer calling her elephant's trunk a boot. @Brits: So is a comma or semi-colon called a Half Stop :-) No. @Americans: What did the letters s and u ever do to you? -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do YOU initialize the form variables?
On Thu, May 31, 2007 5:39 pm, [EMAIL PROTECTED] wrote: Thank you. Will use of your initialization method protect one from sql injection? It isn't clear from reading this: http://ca.php.net/htmlentities ??? htmlentities has absolutely ZERO protection against SQL Injection. None. Nada. Zip. Zilch. It only protects, if that, against XSS attack, in that it converts any funky character into its HTML Entity to be rendered as data in the browser, rather than as a code (where code means JavaScript and/or HTML). A clever XSS attacker might craft a stirng that after htmlentities turns into Bad Things, but it's a bit tougher. In fact, if I understood Rasmus' keynote at the php|tek correctly, an HTML-entity of #39 is actually a valid apostrophe in JS, so that: var foo = 'This is an XSS attack#39; is actually VALID JavaScript code! [shudder] Which means that htmlentities won't always be enough to protect against XSS attacks, I don't think... But it was early in the morning for me, and I was freaking out about the dang microphone (grrr!) so wasn't 100% focused on what he was saying... Anyway, if the incoming data is also bound for SQL, as well as for output to the browser, I might also do like this at the top: $messages[] = array(); require 'connect.inc'; //sets up $connection $username = isset($_POST['username']) ? $_POST['username'] : ''; $username_html = htmlentities($username); $username_sql = mysql_real_escape_string($username, $connection); //validate username: //the code to put here is CUSTOM //it depends on YOUR business needs for a username //that, in turn, depends on YOUR potential user base //beware any kind of generic code for this //it might be close to what you want //but it will rarely really really be what you want... //That said, here are some tests you might consider modifying: $valid = true; if (!strlen($username)){ //this probably is always gonna need to be there... $messages[] = Username cannot be blank; $valid = false; } if (!ctype_graph($username)){ //maybe you WANT to allow control characters in your username? $messages[] = Username cannot contain invisible charactes or whitespace; $valid = false; } if (preg_match('|^[a-z]*$|i', $username)){ //all alpha usernames are usually not so good... $messages[] = Username must contain at least one character that's not A to Z; $valid = false; } if (preg_match('|^[0-9]*$', $username)){ //all digit usernames are probably also not so good... $messages[] = Username cannot be only digits 0-9. Add at least one A-Z character.; $valid = false; } if (is_dictionary_word($username)){ //perhaps more appropriate for a password in general //but on higher-level security systems //even a username shouldn't be in Websters' dictionary $messages[] = Username must not be a single dictionary word. Consider using two unrelated words.; $valid = false; //NOTE: Websters' 2nd Edition is available in Public Doamin //and is often available as rpm/package //quite handy to check for this kind of stuff } You could, of course, go on at length in this way, and even more so for passwords. But once you reach this point, if $valid is still true, you have an SQL-injection safe username in $username_sql, so use that in the queries. $query = select user_id from user where username = '$username_sql' ; Use the HTML one for HTML: input name=username value=?php echo $username_html? / NOTE: The filter extension available since (??? 5.2.2 ???) looks like it will make this all a LOT easier. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ZIP it :o)
Auto-Deppe, C. Haensel wrote: I have been trying to find an easy to use way to zip an archive on a linux box running PHP5. Now I've tried the zip-lib.php and others, but they always throw an error msg But that is not the question. I am looking to use exec(zip archive.zip $directory); $directory has been tried with both full path and relative path ... but that doesn't work. I don't get an error, it just doesn't create the zip-file... So, after a day of Google-ing and trying, I thought I might ask you for help. Most likely a permissions problem. Does the PHP user have write access to the place where archive.zip will be created? -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ZIP it :o)
Auto-Deppe, C. Haensel wrote: Morning guys, I have been trying to find an easy to use way to zip an archive on a linux box running PHP5. Now I've tried the zip-lib.php and others, but they always throw an error msg But that is not the question. I am looking to use exec(zip archive.zip $directory); $directory has been tried with both full path and relative path ... but that doesn't work. I don't get an error, it just doesn't create the zip-file... So, after a day of Google-ing and trying, I thought I might ask you for help. Cheers for any answers and hints. Regards, Chris Read up on this page http://us2.php.net/manual/en/function.exec.php Then try this instead ?php exec(zip archive.zip {$directory} 21, $output); echo $output; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ZIP it :o)
Auto-Deppe, C. Haensel wrote: Morning guys, I have been trying to find an easy to use way to zip an archive on a linux box running PHP5. Now I've tried the zip-lib.php and others, but they always throw an error msg But that is not the question. I am looking to use exec(zip archive.zip $directory); $directory has been tried with both full path and relative path ... but that doesn't work. I don't get an error, it just doesn't create the zip-file... So, after a day of Google-ing and trying, I thought I might ask you for help. Cheers for any answers and hints. http://pear.php.net/package/Archive_Zip and/or http://pear.php.net/package/File_Archive and please create a *new* message instead of replying to an existing one and changing the topic. It screws up message threading (in email clients and in the archives). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ZIP it :o)
Morning guys, I have been trying to find an easy to use way to zip an archive on a linux box running PHP5. Now I've tried the zip-lib.php and others, but they always throw an error msg But that is not the question. I am looking to use exec(zip archive.zip $directory); $directory has been tried with both full path and relative path ... but that doesn't work. I don't get an error, it just doesn't create the zip-file... So, after a day of Google-ing and trying, I thought I might ask you for help. Cheers for any answers and hints. Regards, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php