Re: [PHP-DB] MySQL Result
Hi Chris I have delete working perfectly by doing the following: include(connectionstart.php); mysql_query (DELETE FROM emaillist WHERE EMail = '$email' ); However, how do I return a true or false flag whether the row was deleted or not? I basically need to know how to do a 0 or 1 I guess once the row has been deleted or if the specified email address wasn't found. The manual is your friend (http://www.php.net/manual/en/function.mysql-query.php) There are a couple of reasons why a query/DELETE might fail. Most command checking code failure occurs because people fail to appreciate that the return-value from mysql_query() takes advantage of PHP's loose (data) typing, and can be a boolean value sometimes, and a resource 'pointer' at others. The next 'hole' to fall into is the correctness of the syntax of the query, or that the connection between PHP and MySQL has been broken/not established - illustrated in the manual ref given. The second 'level' of the game is (as you ask) to check that MySQL was actually able to do what was instructed. For this you need mysql_affected_rows() (manual: http://www.php.net/manual/en/function.mysql-affected-rows.php) Here's a particularly pedantic (but hopefully illustrative)piece of code for you: ... if ( DEBUG ) echo brQuery=$SQLquery~; $bValidity = $MySQLResultSet = mysql_query( $SQLquery, $MySQLConnection ); $iNumRowsDeleted = mysql_affected_rows( $MySQLConnection ); if ( MYSQL_DEBUG ) echo brResult=$MySQLResultSet~ Num rows=$iNumRowsDeleted~; if ( FALSE == $bValidity ) { MySQLdbError( $MySQLConnection, Error: MySQL DELETE syntax/semantic/privilege error ); } return $bValidity; - the DELETE is performed within a function - DEBUG and MYSQL_DEBUG are script-global constants set/reset according to taste - MySQLdbError() logs any errors, in or out of user view, also according to taste - note that the query is error-suppressed and its result assigned twice to vars of different types (by naming convention if not PHP construct) - the function returns a 'worked' or 'didn't' (boolean) value - other values are returned in the function parameter/argument list, eg the number of rows deleted - the mainline can call the function within an IF statement - the IF-valid check can then proceed to inspect $iNumRowsDeleted to ensure expected behavior Other refs: a number of the tutorials linked from MySQL AB's site cover this topic area. Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Next birthday?
I have a table called 'members' with a field (among many others) 'member_dob' - the birthday of a particular member. The data type of this field is date (-mm-dd). What I'd like to do now is to fetch one particular row from the database (I am using MySQL 3.23.37) - namely the row of the member who is the next one to have a birthday. Can this be done only with a advanced query or should I fetch all rows and use PHP to find out who is the next one to have a birthday? I'd prefer letting MySQL to do the job... Any ideas? TIA, Kristjan P.S. Pls. CC to [EMAIL PROTECTED] as well - I am only on the digest. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Result
mysql_affected_rows(int resource_id); This will return the number of rows that were affected by the last operation, so you could do something like this: if(mysql_affected_rows($connection) == 1){ //insert, update or delete succeeded }else{ //operation failed } - Original Message - From: Chris Payne [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, March 07, 2002 7:34 PM Subject: [PHP-DB] MySQL Result Hi there everyone, I have delete working perfectly by doing the following: include(connectionstart.php); mysql_query (DELETE FROM emaillist WHERE EMail = '$email' ); However, how do I return a true or false flag whether the row was deleted or not? I basically need to know how to do a 0 or 1 I guess once the row has been deleted or if the specified email address wasn't found. Thanks for your help everyone. Chris -- PHP Database Mailing List (http://www.php /) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Email Validation
On Fri, 2002-03-08 at 04:10, CrossWalkCentral wrote: How would I go about doing the DNS look up part? with checkdnsrr() I'd assume: checkdnsrr($host) Searches DNS for records of type type corresponding to host. Returns TRUE if any records are found; returns FALSE if no records were found or if an error occurred. the default type is MX. http://www.php.net/manual/en/function.checkdnsrr.php On Tuesday 12 February 2002 06:19, CrossWalkCentral wrote: I am working on a form that I have in php and am looking for some advise on form validation or specifically email address validation so i can insure that some one has put in a properly formatted email address Well. something like if (!eregi(^[A-Za-z0-9\_-]+@[A-Za-z0-9\_-]+.[A-Za-z0-9\_-]+.*, $email)) { echo $email doesn't seem to be a valid e-mail address!; } would do the job. Of course, that doesn't stop people from entering a false email address. You could do a DNS-lookup to see if the domain-part of the address really exists, too. -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Email Validation
hi there, is there any way to check the existence of an e-mail address without sending an email? i mean not only DNS lookup, but also user validation? 10x, cristi radulescu http://translator.urbanxp.org http://www.urbanxp.org ML On Fri, 2002-03-08 at 04:10, CrossWalkCentral wrote: How would I go about doing the DNS look up part? ML with checkdnsrr() I'd assume: ML checkdnsrr($host) ML Searches DNS for records of type type corresponding to host. Returns ML TRUE if any records are found; returns FALSE if no records were found or ML if an error occurred. ML the default type is MX. ML http://www.php.net/manual/en/function.checkdnsrr.php _ Do You Yahoo!? Get your free yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Email Validation
No. Some mail servers (qmail for sure) have the user auth section seperated from the piece that accepts mail from the internet. As long as the mail is for the correct domain, it will accept it, and passes it to a seperate program that checks for the user and either bounces or delivers the mail. -Original Message- From: cristi radulescu [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 7:13 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Email Validation hi there, is there any way to check the existence of an e-mail address without sending an email? i mean not only DNS lookup, but also user validation? 10x, cristi radulescu http://translator.urbanxp.org http://www.urbanxp.org ML On Fri, 2002-03-08 at 04:10, CrossWalkCentral wrote: How would I go about doing the DNS look up part? ML with checkdnsrr() I'd assume: ML checkdnsrr($host) ML Searches DNS for records of type type corresponding to host. Returns ML TRUE if any records are found; returns FALSE if no records were found or ML if an error occurred. ML the default type is MX. ML http://www.php.net/manual/en/function.checkdnsrr.php _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Next birthday?
The simple answer might be: SELECT member.* FROM `member` WHERE DAYOFYEAR(member_dob) = DAYOFYEAR(CURDATE()) ORDER BY member_dob DESC LIMIT 1 Seems to work for me. The problem is that it wouldn't support members that have a birthday on the same day :) To solve that I would select the next birthday from the 'member' table, then go back and select all the members that have that birthday. It also would not support selecting January birthdays in December (which might be a problem Dec 31). so you would actually need three queries: SELECT member_dob FROM `member` WHERE DAYOFYEAR(member_dob) = DAYOFYEAR(CURDATE()) ORDER BY member_dob DESC LIMIT 1 if that returns 0 results, then you would likely be in December trying to show the next birthday in January. Go back to the database starting with January 1 and select brithdays starting at the begining of the year. SELECT member_dob FROM `member` WHERE DAYOFYEAR(member_dob) = 0 ORDER BY member_dob DESC LIMIT 1 then take that result and: SELECT member.* FROM `member` WHERE member_dob = '$result_from_previous_query' ORDER BY last_name This really seems like overkill. This query would be much simpler if you just showed everyone's birthday next month (or something like that). Robert Zwink http://www.zwink.net/daid.php -Original Message- From: Kristjan Kanarik [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 5:30 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Next birthday? I have a table called 'members' with a field (among many others) 'member_dob' - the birthday of a particular member. The data type of this field is date (-mm-dd). What I'd like to do now is to fetch one particular row from the database (I am using MySQL 3.23.37) - namely the row of the member who is the next one to have a birthday. Can this be done only with a advanced query or should I fetch all rows and use PHP to find out who is the next one to have a birthday? I'd prefer letting MySQL to do the job... Any ideas? TIA, Kristjan P.S. Pls. CC to [EMAIL PROTECTED] as well - I am only on the digest. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Next birthday?
On Fri, 8 Mar 2002, Robert V. Zwink wrote: The simple answer might be: SELECT member.* FROM `member` WHERE DAYOFYEAR(member_dob) = DAYOFYEAR(CURDATE()) ORDER BY member_dob DESC LIMIT 1 Seems to work for me. Not for me. I think it should be ordered like this: ORDER BY DAYOFYEAR(member_dob) ASC Otherwise it will display the person who was born on 25th of March 1988 instead of the one born 11th of March 1980. Pls. correct me if I am wrong. Thanks Cheers, Kristjan P.S. Pls. CC to [EMAIL PROTECTED] - I am only on the digest. The problem is that it wouldn't support members that have a birthday on the same day :) To solve that I would select the next birthday from the 'member' table, then go back and select all the members that have that birthday. It also would not support selecting January birthdays in December (which might be a problem Dec 31). so you would actually need three queries: SELECT member_dob FROM `member` WHERE DAYOFYEAR(member_dob) = DAYOFYEAR(CURDATE()) ORDER BY member_dob DESC LIMIT 1 if that returns 0 results, then you would likely be in December trying to show the next birthday in January. Go back to the database starting with January 1 and select brithdays starting at the begining of the year. SELECT member_dob FROM `member` WHERE DAYOFYEAR(member_dob) = 0 ORDER BY member_dob DESC LIMIT 1 then take that result and: SELECT member.* FROM `member` WHERE member_dob = '$result_from_previous_query' ORDER BY last_name This really seems like overkill. This query would be much simpler if you just showed everyone's birthday next month (or something like that). Robert Zwink http://www.zwink.net/daid.php -Original Message- From: Kristjan Kanarik [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 5:30 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Next birthday? I have a table called 'members' with a field (among many others) 'member_dob' - the birthday of a particular member. The data type of this field is date (-mm-dd). What I'd like to do now is to fetch one particular row from the database (I am using MySQL 3.23.37) - namely the row of the member who is the next one to have a birthday. Can this be done only with a advanced query or should I fetch all rows and use PHP to find out who is the next one to have a birthday? I'd prefer letting MySQL to do the job... Any ideas? TIA, Kristjan P.S. Pls. CC to [EMAIL PROTECTED] as well - I am only on the digest. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: why won't session_start() work?
You may try to put session_start(); at the most begining. But should you also add a session path first? Ryan Snow [EMAIL PROTECTED] ¼¶¼g©ó¶l¥ó [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... when I do: session_start(); session_register('signor'); session_register('username'); I get: Warning: Cannot send session cookie - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/index.php on line 14 Warning: Cannot send session cache limiter - headers already sent (output started at /var/www/html/index.php:3) in /var/www/html/index.php on line 14 Anybody know why? Thanks. Ry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Soft-Linking and includes
My limited understanding of Unix hard and soft links is that /www/dir2/subdir is not a directory, it is a pointer to the inode that is pointed to by /www/dir1/subdir. I think to accomplish what you want, /www/dir2/subdir would have to be a true directory, filled with soft links to each of the files in /www/dir1/subdir, or your include would need an explicit path. Jonathan Hilgeman wrote: I'm on a red hat system, and I've soft-linked two directories: /www/dir1/subdir /www/dir2/subdir -- /www/dir1/subdir Now, inside subdir is a file that tries to include(../info.php); which prints out some information about the file paths and my database stuff. So there's: /www/dir1/info.php /www/dir1/subdir/includer.php /www/dir2/info.php /www/dir2/subdir -- /www/dir1/subdir Now, when I run /www/dir2/subdir/includer.php, it SHOULD include the file ../info.php which translates into /www/dir2/info.php. However, the symbolic linking seems to have messed it up, and instead of running dir2's info.php, it seems to think it is in dir1, and instead includes dir1's info.php file. Has anyone run into this and/or know a fix for it? Thanks! - Jonathan -- Out beyond the ideas of wrong-doing and right-doing there is a field. I'll meet you there. -Rumi *(O)* [EMAIL PROTECTED] *** under construction *** http://centralcoasthealing.net Healing Resources on the Central Coast http://kornsnake.com Internet Development -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Looking for a good MySQL db abstraction layer
I'm looking for a good MySQL db abstraction layer. I'm just coming back to PHP/MySQL and rather writing my own I figured I'd try to see if any are already out there. The layer should obviously have the basics, of connect, query, and close, and possibly some error checking and handling. thanks, ~ Mike -- Mike Zornek | Project Leader Apple Student Developers The Insanely Great Site with the Insanely Long URL http://www.applestudentdevelopers.org Personal Site: http://www.mikezornek.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Looking for a good MySQL db abstraction layer
Try those provided in PEAR(in the distro). Best regards, Andrey Hristov On Friday 08 March 2002 08:04 pm, you wrote: I'm looking for a good MySQL db abstraction layer. I'm just coming back to PHP/MySQL and rather writing my own I figured I'd try to see if any are already out there. The layer should obviously have the basics, of connect, query, and close, and possibly some error checking and handling. thanks, ~ Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Looking for a good MySQL db abstraction layer
on 3/8/02 1:04 PM, Michael Zornek at [EMAIL PROTECTED] appended the following bits to my mbox: I'm looking for a good MySQL db abstraction layer. I'm just coming back to PHP/MySQL and rather writing my own I figured I'd try to see if any are already out there. The layer should obviously have the basics, of connect, query, and close, and possibly some error checking and handling. You should probably look into PEAR. http://pear.php.net/ You probably have the basic PEAR stuff if you did a source install of PHP. They have a DB Abstraction class that is similar to Perl DBI and it appears to be the way of the future. http://pear.php.net/manual/en/core.db.php FWIW, the author of the PHP Developers' Cookbook (Sams) did all of the database examples using PEAR syntax. Of course, I've not made the switch over yet so take my advice with a grain of salt. Hope it helps. Sincerely, Paul Burney http://paulburney.com/ ?php If ($your_php_version 4.1.2) { upgrade_now(); // to avoid major security problems /* Please see http://security.e-matters.de/advisories/012002.html */ ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Is this possible in mysql?
list($sum)=mysql_fetch_assoc(mysql_query('SELECT SUM(salary') FROM employes;')); Best regards, Andrey Hristov On Friday 08 March 2002 09:17 pm, you wrote: I need to add up the (integer) values of columns, and return the added up value as one column to php. Is this possible? Or is there something else to do it? (I'd rather not have to mysql_fetch_array() in a while loop and add it up there, it might be a lot of rows) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Looking for a good MySQL db abstraction layer
PEAR, Metabase, and ADODB are all good db abstraction packages with their respective merits. But if your looking for something simple, efficient, for mysql only try: http://www.phpclasses.org/browse.html/package/107.html The package contains basic connection, sql command, and recordset classes. I like it because it's easy to understand and play around with. Also has sql logging which can be switched on for debugging. Michael Zornek wrote: I'm looking for a good MySQL db abstraction layer. I'm just coming back to PHP/MySQL and rather writing my own I figured I'd try to see if any are already out there. The layer should obviously have the basics, of connect, query, and close, and possibly some error checking and handling. thanks, ~ Mike -- Out beyond the ideas of wrong-doing and right-doing there is a field. I'll meet you there. -Rumi *(O)* [EMAIL PROTECTED] *** under construction *** http://centralcoasthealing.net Healing Resources on the Central Coast http://kornsnake.com Internet Development -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Soft-Linking and includes
You must use absolute paths in includes. essentially the include will reference itself as the starting point, rather than the script you are calling it from. olinux --- Jonathan Hilgeman [EMAIL PROTECTED] wrote: I'm on a red hat system, and I've soft-linked two directories: /www/dir1/subdir /www/dir2/subdir -- /www/dir1/subdir Now, inside subdir is a file that tries to include(../info.php); which prints out some information about the file paths and my database stuff. So there's: /www/dir1/info.php /www/dir1/subdir/includer.php /www/dir2/info.php /www/dir2/subdir -- /www/dir1/subdir Now, when I run /www/dir2/subdir/includer.php, it SHOULD include the file ../info.php which translates into /www/dir2/info.php. However, the symbolic linking seems to have messed it up, and instead of running dir2's info.php, it seems to think it is in dir1, and instead includes dir1's info.php file. Has anyone run into this and/or know a fix for it? Thanks! - Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do You Yahoo!? Try FREE Yahoo! Mail - the world's greatest free email! http://mail.yahoo.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Soft-Linking and includes
However, on a different, FreeBSD platform, this is not the case. A linked file can call an include and have the desired file be called instead of the source one. That's where I'm getting confused. - Jonathan -Original Message- From: olinux [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 12:28 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Soft-Linking and includes You must use absolute paths in includes. essentially the include will reference itself as the starting point, rather than the script you are calling it from. olinux --- Jonathan Hilgeman [EMAIL PROTECTED] wrote: I'm on a red hat system, and I've soft-linked two directories: /www/dir1/subdir /www/dir2/subdir -- /www/dir1/subdir Now, inside subdir is a file that tries to include(../info.php); which prints out some information about the file paths and my database stuff. So there's: /www/dir1/info.php /www/dir1/subdir/includer.php /www/dir2/info.php /www/dir2/subdir -- /www/dir1/subdir Now, when I run /www/dir2/subdir/includer.php, it SHOULD include the file ../info.php which translates into /www/dir2/info.php. However, the symbolic linking seems to have messed it up, and instead of running dir2's info.php, it seems to think it is in dir1, and instead includes dir1's info.php file. Has anyone run into this and/or know a fix for it? Thanks! - Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do You Yahoo!? Try FREE Yahoo! Mail - the world's greatest free email! http://mail.yahoo.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Where to get freetype2.x precompiled for windows 2000
Hi guys, does anybody know where to get freetype 2 for win2k as a binary? I did try it on freetype.org and through google but all links seem to lead to nothing. Maybe someone has the .dll already installed on his machine. If so, please send me a copy I would appreciate it. Thanx for any help Andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] two different MySQL connections without always select_db?
How would you keep two different MySQL connections to two different MySQL databases (on two different MySQL servers) up and available with two different pointers (id), and not need to always do select_db() to switch between them? I thought that if I did this: --- php: - $aaa_link = mysql_pconnect(localhost, u, p); mysql_select_db(apples, $aaa_link); $zzz_link = mysql_pconnect(remotehost, u, p); mysql_select_db(zebras, $zzz_link); -- ... that I'd be able to access both pretty easily. Like this: --- php: - $aaa_result = mysql_query(select * from apples, $aaa_link); $orchard = mysql_fetch_assoc($aaa_result); $zzz_result = mysql_query(select * from zebras, $zzz_link); $zoo = mysql_fetch_assoc($zzz_result); $aaa_result = mysql_query(update apples set something=' . $zoo['zebrafur'] . ', $aaa_link); -- But it seems to tell me that $zzz_result is not a valid resource - unless I do the select_db thing inbetween the two commands. Is there anyone doing this successfully? Back-n-forth between two databases? Thanks for any help. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: [PHP] two different MySQL connections without always select_db?
i dont know if this will work, but you can try selecting them in the query... i.e.: select * from database.table I am by no means a guru on sql queries, but it may work. -Original Message- From: PHP freak [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 8:39 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP] two different MySQL connections without always select_db? How would you keep two different MySQL connections to two different MySQL databases (on two different MySQL servers) up and available with two different pointers (id), and not need to always do select_db() to switch between them? I thought that if I did this: --- php: - $aaa_link = mysql_pconnect(localhost, u, p); mysql_select_db(apples, $aaa_link); $zzz_link = mysql_pconnect(remotehost, u, p); mysql_select_db(zebras, $zzz_link); -- ... that I'd be able to access both pretty easily. Like this: --- php: - $aaa_result = mysql_query(select * from apples, $aaa_link); $orchard = mysql_fetch_assoc($aaa_result); $zzz_result = mysql_query(select * from zebras, $zzz_link); $zoo = mysql_fetch_assoc($zzz_result); $aaa_result = mysql_query(update apples set something=' . $zoo['zebrafur'] . ', $aaa_link); -- But it seems to tell me that $zzz_result is not a valid resource - unless I do the select_db thing inbetween the two commands. Is there anyone doing this successfully? Back-n-forth between two databases? Thanks for any help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php