[PHP-DB] Php mariadb unique field selection for index of query result.
Hi, Quick question. I may be missing something but for years I've been processing the output of a query into a new array using the unique(normally primary key) field in the table as the index so I can pull data matches simply further into the script without another loop through all the returned data. Is there an option I'm missing to assign a field as the output array index from a PHP based query? Thanks, -- Richard Scotford
RE: [PHP-DB] MySQLnd support for ed25519
Mysql 8 is already the stable version and has been for a while. I for development use it on windows and its v8 -Original Message- From: Ruprecht Helms Sent: 08 September 2021 16:02 To: php-db@lists.php.net Subject: Re: [PHP-DB] MySQLnd support for ed25519 Hi Dimi, I think mysql 8 is the new version of mysql. I don't know if there a exists a stable release or only a beta. My thoughts are that the last php-version maybe can handle the mentioned authentication method or you have to try to compile the handling for the mysql-plugin in the php-mysqldriver. Maybe the question about enhancing the php is relation on the Linuxdistribution. Here I mean an additional rpm if you use Redhat, Fedora, Centos, Suse... or .deb if you use Debian, Ubuntu or such of these. To mix a tarball with one of these packages I think it is to difficult in this case. Regards, Ruprecht Am 08.09.21 um 15:20 schrieb dimi_php: > Hi Ruprecht, > > yes, if a provider not changed the default authentication > (mysql_nativ_password) there is nothing customers have to do, because > the default authentication on mysql 5.7 and 10.5 is the same (SHA-1 based). > Mysql changed this starting from version 8, were the default authentication > now is the plugin caching_sha2_password. > Mariadb not changed the default, but recommends to use a safer authentication > method like the ed25519-plugin. > > I would like to use it, but then i have the problem that PHP (the > Mysql nativ driver) cames with an error like "The server requested > authentication method unknown to the client". > > So i would be glad if this authentication method would be implemented. > > Regards, > Dimi -- PHP Database Mailing List (https://link.edgepilot.com/s/bc6bf762/v5jGKG7Xd0e-fT3zNkB0xg?u=http://www.php.net/) To unsubscribe, visit: https://link.edgepilot.com/s/cb035ec6/Rl3bBHstt0_Aj5u5ZnK0vg?u=http://www.php.net/unsub.php
[PHP-DB] Getting PDO-OCI to work in PHP 7
I have made multiple attempts to get PDO-OCI to work in PHP 7. Sometimes it fails to compile at all, other times appears to compile correctly, but I can't connect to any Oracle databases. Thus far, this has kept me stuck on PHP 5.x. The relevant part of my configure statement is: ./configure \ ... --with-mysqli=/usr/bin/mysql_config \ --with-pdo-mysql=/usr \ --with-pdo-odbc=unixODBC,/usr \ --with-pdo-oci=instantclient,/usr/lib/oracle/18.3/client64/lib/ \ --with-unixODBC=/usr \ ... The latest error is when I run "make": ...snip... In file included from /root/php-7.2.4/ext/ldap/php_ldap.h:30:0, from main/internal_functions.c:50: /usr/include/oracle/18.3/client64/ldap.h:988:18: error: conflicting types for ‘ber_scanf’ LDAPFUNCDECL int ber_scanf ( BerElement *ber, char * fmt, ... ); ^ In file included from /root/php-7.2.4/ext/ldap/php_ldap.h:27:0, from main/internal_functions.c:50: /usr/include/lber.h:335:1: note: previous declaration of ‘ber_scanf’ was here ber_scanf LDAP_P(( ^ make: *** [main/internal_functions.lo] Error 1 Can anyone offer me some ideas? Thanks in advance. -John -- John Stokes – Certified Oracle of Security seeking Zend wearing a Red Hat. (CISSP, ZCE, RHCSA) Software Engineer Verizon Wireless - West Territory Data Tools & Reporting *Three Pillars: Humility, Communication, Balance*
confirm subscribe to php-db@lists.php.net
Hi! This is the ezmlm program. I'm managing the php-db@lists.php.net mailing list. I'm working for my owner, who can be reached at php-db-ow...@lists.php.net. To confirm that you would like arch...@mail-archive.com added to the php-db mailing list, please send an empty reply to this address: php-db-sc.1347368276.dpkjpidceimmnlhfeoec-archive=mail-archive@lists.php.net Usually, this happens when you just hit the reply button. If this does not work, simply copy the address and paste it into the To: field of a new message. or click here: mailto:php-db-sc.1347368276.dpkjpidceimmnlhfeoec-archive=mail-archive@lists.php.net This confirmation serves two purposes. First, it verifies that I am able to get mail through to you. Second, it protects you in case someone forges a subscription request in your name. Some mail programs are broken and cannot handle long addresses. If you cannot reply to this request, instead send a message to php-db-requ...@lists.php.net and put the entire address listed above into the Subject: line. --- Administrative commands for the php-db list --- I can handle administrative requests automatically. Please do not send them to the list address! Instead, send your message to the correct command address: For help and a description of available commands, send a message to: php-db-h...@lists.php.net To subscribe to the list, send a message to: php-db-subscr...@lists.php.net To remove your address from the list, just send a message to the address in the ``List-Unsubscribe'' header of any list message. If you haven't changed addresses since subscribing, you can also send a message to: php-db-unsubscr...@lists.php.net or for the digest to: php-db-digest-unsubscr...@lists.php.net For addition or removal of addresses, I'll send a confirmation message to that address. When you receive it, simply reply to it to complete the transaction. If you need to get in touch with the human owner of this list, please send a message to: php-db-ow...@lists.php.net Please include a FORWARDED list message with ALL HEADERS intact to make it easier to help you. --- Enclosed is a copy of the request I received. Return-Path: nore...@php.net Received: (qmail 4170 invoked from network); 11 Sep 2012 12:57:56 - Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Sep 2012 12:57:56 - Return-Path: nore...@php.net Authentication-Results: pb1.pair.com header.from=arch...@mail-archive.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=nore...@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 140.211.15.143 as permitted sender) X-PHP-List-Original-Sender: nore...@php.net X-Host-Fingerprint: 140.211.15.143 osu1php.osuosl.org Received: from [140.211.15.143] ([140.211.15.143:57985] helo=osu1php.osuosl.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/A2-24398-3553F405 for php-db-subscribe-archive=mail-archive@lists.php.net; Tue, 11 Sep 2012 08:57:56 -0400 Authentication-Results: osu1php.osuosl.org smtp.mail=nore...@php.net; spf=neutral; sender-id=neutral Authentication-Results: osu1php.osuosl.org header.from=arch...@mail-archive.com; sender-id=softfail Received-SPF: neutral (osu1php.osuosl.org: 127.0.0.1 is neither permitted nor denied by domain of php.net) Received: from [127.0.0.1] ([127.0.0.1:60119] helo=localhost) by osu1php.osuosl.org (envelope-from nore...@php.net) (ecelerity 3.3.2.44647 r(44647)) with ESMTP id 79/D0-30231-F453F405; Tue, 11 Sep 2012 12:57:51 + Date: Tue, 11 Sep 2012 12:57:51 + Message-ID: 79.d0.30231.f453f...@osu1php.osuosl.org X-Authentication-Warning: osu1php.osuosl.org: nobody set sender to nore...@php.net using -f To: php-db-subscribe-archive=mail-archive@lists.php.net Subject: PHP Mailing List Website Subscription X-PHP-Originating-Script: 0:subscribe.php From: arch...@mail-archive.com This was a request generated from the form at http://www.php.net/mailing-lists.php by 109.61.3.34.
[PHP-DB] Simple MySQL sample code runs out of memory
Running PHP 5.3.5 on FreeBSD 8.2 connecting to a MySQL 5.1.55 server. Why does this code (below) run out of memory? It queries test_table for all rows, all fields and sorts them by the numeric 'contract' field. It then iterates through the rows, and tallies the number of rows per contract. That's not the end goal of the processing, but the processing does not require storing multiple rows in memory (except in the MySQL result buffer). One row at a time in memory is all I need. The schema is not huge: +--+-+--+-+-+---+ | Field| Type| Null | Key | Default | Extra | +--+-+--+-+-+---+ | contract | int(11) | YES | | NULL| | | A| int(8) unsigned | NO | | 0 | | | B| datetime| YES | | NULL| | | C| int(8) unsigned | YES | | 0 | | | D| char(8) | YES | | NULL| | | E| char(8) | YES | | | | | F| int(4) | YES | | 0 | | | G| int(1) | YES | | 0 | | | H| char(8) | YES | | 00:00 | | | I| varchar(100)| YES | | XXX | | +--+-+--+-+-+---+ ?php require_once( '../include/mysql_funcs.php' ); $db_host = $test_db_host; $db_user = $test_db_user; $db_name = $test_db_name; $db_pwd = $test_db_pwd; if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd ))) die( Can't connect to MySQL server\n ); if (!mysql_select_db( $db_name, $db_conn )) die( Can't connect to database $db_name\n ); $qry = select * from test_table order by contract; if ($result = mysql_query( $qry, $db_conn )) { $row = mysql_fetch_array( $result ); while ($row) { $c = $row[ 'contract' ]; $n = 0; while ($row ($c == $row[ 'contract' ])) { $n++; $row = mysql_fetch_array( $result ); } echo sprintf( |%13d |%7d |\n, $c, $n ); } // while } else { die( mysql_error() . \n ); } ? The output ends with: ... |39582 |518 | |39583 |384 | |39584 |429 | |39585 |433 | |39586 |359 | PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20 bytes) in xx2.php on line 26 Line 26 seems to be the innermost mysql_fetch_array call. The sum of the right-hand column for all the output produced prior to running out of memory is 274547. There are 295287 total rows in the table. What can I change to prevent this code from running out of memory even with an arbitrarily large number of rows returned from the 'select' query? Thank you for your time! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Simple MySQL sample code runs out of memory
On Thu, Oct 27, 2011 at 09:17:21PM -0500, tamouse mailing lists wrote: That said, I think there must be a way to do this in SQL. Absolutely, there's a way to do this in SQL; select contract, sum(1) from test_table group by contract But as I said, simply counting is not the intent of the actual processing that will be done. I need to find a method that can iterate through a large number of records and process each record (in whatever way I choose to define) without running out of RAM. I only need to access one record at a time, so I thought this would be pretty trivial, and was surprised to find that the routine ran out of memory. This simple counting exercise is merely a test of the loop algorithm so that I can do a 'cmp' or 'diff' comparison of the output of the PHP versus the output of the SQL to verify that in fact the PHP algorithm is indeed finding and processing each record (and thus arriving at the same per-contract counts that the SQL statement does). I will experiment with your suggestions. Thank you, Jim -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Simple MySQL sample code runs out of memory
On Thu, Oct 27, 2011 at 09:50:14PM -0500, tamouse mailing lists wrote: Still, an inner and outer loop don't really seem necessary here, as you're spinning through one set of data, there doesn't seem a need to run through it that way. A more traditional method is to do something like: $last_contract = ''; while ($row = $msql_fetch_assoc($results) { if ($last_contract == $row['contract]) { // do what ever you'd do with the same contract } else { $last_contract = $row['contract']; // do what ever you'd do with the new contract } } assuming you are ordering by contract as in the example select. Thanks for that suggestion, also. Something more fundamental is going on. Here is simpler code which still reproduces the problem. ?php require_once( '../include/mysql_funcs.php' ); $test_db_host = localhost; $test_db_user = msm; $test_db_pwd = EetGiOj6; $test_db_name = test_msm; $db_host = $test_db_host; $db_user = $test_db_user; $db_name = $test_db_name; $db_pwd = $test_db_pwd; if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd ))) die( Can't connect to MySQL server\n ); if (!mysql_select_db( $db_name, $db_conn )) die( Can't connect to database $db_name\n ); $qry = select * from test_spot_table order by contract; if ($result = mysql_query( $qry, $db_conn )) { $n = 0; while ($row = mysql_fetch_array( $result )) { $n++; } // while echo $n\n; } else { die( mysql_error() . \n ); } ? I get: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20 bytes) in xx3.php on line 26 What's up with that? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Simple MySQL sample code runs out of memory
On Thu, Oct 27, 2011 at 10:43:48PM -0500, Karl DeSaulniers wrote: Maybe this.. HTH, ?php ... $result = mysql_query( $qry, $db_conn ) or die( mysql_error() . \n ); $num_rows = mysql_numrows($result); if(!$result || ($num_rows = 0)){ echo Error displaying info; } else if($num_rows 0){ for($i=0; $i$num_rows; $i++){ $c = mysql_result($result,$i,contract); echo sprintf( |%13d |%7d |\n, $c, $i ); } } ? Best, Karl Wow, working code! Thanks. I did try it: ?php require_once( '../include/mysql_funcs.php' ); $test_db_host = localhost; $test_db_user = msm; $test_db_pwd = EetGiOj6; $test_db_name = test_msm; $db_host = $test_db_host; $db_user = $test_db_user; $db_name = $test_db_name; $db_pwd = $test_db_pwd; if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd ))) die( Can't connect to MySQL server\n ); if (!mysql_select_db( $db_name, $db_conn )) die( Can't connect to database $db_name\n ); $qry = select * from test_spot_table order by contract_seq; $result = mysql_query( $qry, $db_conn ) or die( mysql_error() . \n ); $num_rows = mysql_numrows($result); if(!$result || ($num_rows = 0)){ echo Error displaying info; } else if($num_rows 0){ for($i=0; $i$num_rows; $i++){ $c = mysql_result($result,$i,contract); echo sprintf( |%13d |%7d |\n, $c, $i ); } } ? But it does the same thing: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20 bytes) in /usr/local/www/apache22/data/bogus_copy/xx4.php on line 31 Line 31 is: 31$c = mysql_result($result,$i,contract); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: WAMP server Problem and Correct way to install PHP and MySQL???
when you click on the wamp icon in your taskbar you will get an popup menu: by clicking on phpMyAdmin your browser will open with phpMyAdmin. From there you can check the database and create databases and tables as you go. If phpmyadmin could not open. : page times out then click on the wamp icon again, move to Apache, then Service, and then click on Test port 80, then you should get something like -- Your port 80 is actually used by : Server: Apache/2.2.11 (Win32) PHP/5.2.8 Press Enter to exit... -- if you get an error on port 80 that it is in use, check that IIS is not running on your pc and if you use skype check that you selected in the options so that skype doesnt make use of port 80 If you downloaded a new WAMP version, i would suggest that you make one minor change in the php.ini file. Put a semi-colon before error_reporting = E_ALL so that it looks like this ;error_reporting = E_ALL and remove the colon before error_reporting = E_ALL ~E_NOTICE. This is just one of my personal adjustments to the wamp default php.ini file. Then for installing Apache. Like Sashikanth Gurram said WAMP is Windows Apache MySql PHP. So apache gets installed with wamp. The linux version of wamp is LAMP just for interrest sake. O yes. almost forgot. The WAMP icon should have a completely white background, not yellow. if its yellow go and check the PHP Logs, Apache Logs and MySql Logs to determine which service is not running. I do hope this help. Sashikanth Gurram sashi...@vt.edu wrote in message news:497a0a60.9000...@vt.edu... Hello everyone, I have installed WAMP server on my PC. Then I have installed the MySQL and PHP software by downloading them from the site. The PHP programs I have written used to work fine but when I tried to connect to the MySQL database or create a new database using the PHP programming nothing happens in the browser. I do not know what happened. After several attempts I finally uninstalled the MySQL and PHP programs and then when I tried to connect to the MySQL usin PHP it worked fine I do not know the reason for this. Can anyone tell me what the reason is? Further more I would like to install PHP and MySQL along with a server like APACHE. But I do not know where to download the APACHE server from. Also When I install PHP and MySQL how do I link PHP and MySQL so that they work in tandem. Would be great if anyone can clear these doubts. I know that these are very basic questions but I am a starter. Thanks, Sashi __ Information from ESET Smart Security, version of virus signature database 4052 (20090504) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4052 (20090504) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] First and Last ID of a table
SELECT MIN(id), MAX(id) FROM mytable :) Hope that helps! -TG = = = Original message = = = I have a table where I need to figure out the very first ID and the very last ID, so here is what I wrote: $first_query = SELECT id FROM mytable ORDER BY id LIMIT 1; $first_result = mysql_query($first_query,$con); $first_id = mysql_result($first_result,0,'id'); $last_query = SELECT id FROM mytable ORDER BY id DESC LIMIT 1; $last_result = mysql_query($last_query,$con); $last_id = mysql_result($last_result,0,'id'); I'm just wondering if there was any way to do this more efficiently, like with one query instead of two. Or is this about as simple as I can do it? Thanks. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada College www.wnc.edu 775-445-3326 ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] First and Last ID of a table
Sounds about right... you can also do something like this (syntax should be right): SELECT MIN(id) as minid, MAX(id) as maxid FROM mytable $array['minid'] and $array['maxid'] Basically it's going to be whatever the heading of that column is. Using as gives it an alias for less ugly headings. If you did SELECT COUNT(Qty) FROM SomeTable Then you might get: $array['Count of Qty'] or something goofy like that. I forget the exact circumstances but there's times you get goofy stuff like that. If you run the SQL through some DB client (like mysql's command line stuff or I use WinSQL Lite in Windows to connect to our MySQL database across the network) you can usually see what the heading name is going to end up being, if you don't explicitly set it with an AS clause. AS also works on table names: SELECT l.LeadID, ld.FirstName FROM Leads as l, LeadData as ld WHERE l.LeadID = ld.LeadID (actually a lot of the time you can leave out the as and just do Leads l) Fun times.. -TG = = = Original message = = = [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] SELECT MIN(id), MAX(id) FROM mytable As an aside, is you are using associative arrays, be sure to use the following keys: $array['MIN(id)'] and $array['MAX(id)'] Just something I figured out recently :) Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] sql statement - complex order by
Try this: SELECT * FROM productgroup WHERE groupid = $productid ORDER BY label = 'Cats' DESC, title The test SQL I did to make sure I understood it was this (against our Users table): select * from users order by first = 'Bob' DESC, first, last It put all the Bobs first, sorting them by first/last, then put everyone else after the Bobs sorted by first/last. If you don't put DESC on the 'Cats', it looks like it'll put the 'Cats' at the bottom of the list. Also refer to the user comments here: http://dev.mysql.com/doc/refman/4.1/en/sorting-rows.html good luck! -TG = = = Original message = = = SELECT * FROM productgroup WHERE groupid = $productid AND label = 'Cats' ORDER BY title SELECT * FROM productgroup WHERE groupid = $productid AND label != 'Cats' ORDER BY label,title I'd like to find a way to combine these 2 statements. I want to list out all the products, ordered by title but listing out all the Cats products first. Any way to do that without having separate statements? Thanks... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Search for whole words in MySQL 3.23
I suck at regex, but looks like 3.23 may actually support it. And most regex implementations have a word boundary code for doing exactly what you're talking about. Referring to this page: http://dev.mysql.com/doc/refman/4.1/en/regexp.html I found this example.. hopefully it'll help you (and work ok in 3.23): [[::]], [[::]] These markers stand for word boundaries. They match the beginning and end of words, respectively. A word is a sequence of word characters that is not preceded by or followed by word characters. A word character is an alphanumeric character in the alnum class or an underscore (_). mysql SELECT 'a word a' REGEXP '[[::]]word[[::]]'; - 1 mysql SELECT 'a xword a' REGEXP '[[::]]word[[::]]'; - 0 -TG = = = Original message = = = Hi all, I'm setting up a database search on a site, where I will essentially be BOOLEAN searching about 6 database fields. Unfortunately, the database I'm using is MySQL version 3.23 (completely out of my control), so I cannot use IN BOOLEAN MODE to simplify the process on my end. I've been able to put together a function that does almost everything that I want, but I'm running into a problem - searching for whole words that may or may not be in the beginning or end of the database field. For example, syntax like this: ...WHERE `field` LIKE '%searchterm%'... has the limitation that if the search term is 'car', it will also bring back 'scar', 'cartoon', etc. While if the syntax is: ...WHERE `field` LIKE '% searchterm %'... (with spaces) it misses words that are the first or last words of the field, or words that are at the end of sentences, before commas, etc. I've looked around and haven't been able to find a way to search only for complete words within a block of text. Any help? Thanks in advance, Zeth ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Values in a date field
Assuming you're using MySQL, try MONTH(). As in: SELECT MONTH(SomeDateField) FROM SomeTable http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html If this isn't a database question, but a general PHP question, try this: // For numeric month without leading zero, use n echo date(n, strtotime($subscription_begins)); http://us3.php.net/manual/en/function.date.php -TG = = = Original message = = = I have a $subscription_begins variable. It the date type. -MM-DD How may I find out the month value (1 to 12) of this variable? Ron ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL Query - Using variable from another SQL Query
Try this as your SQL. It should give you all the results, then you can use PHP to sort it all out. SELECT * FROM egw_cal WHERE cal_category='501' and cal_id in (SELECT cal_id FROM egw_cal_dates where cal_start $tstamp) -TG = = = Original message = = = Hello Everyone Got a simple / stupid question. Worked on this all night. I'm over looking something very basic here. The query event_time brings back the calendar id for each event that is pending in the future. ie 12, 13, 14, 26 (There could be 100 of them out there) The second query events needs to meet both reqirements. 1 - cal_category='501' 2 - cal_id= a number from the event_time query I think i need to do a loop inside of a loop Thanks... Matt Here is my code: ?php $todays_year = date(Y); $todays_month = date(m); $todays_day = date(d); $tstamp = mktime(0, 0, 0, $todays_month, $todays_day, $todays_year); $event_time = mysql_query(SELECT cal_id FROM egw_cal_dates where cal_start $tstamp, $db); $events = mysql_query(SELECT * FROM egw_cal WHERE cal_category='501' and cal_id='$event_time'\n, $db); if ($event = mysql_fetch_array($events)) echo center\n; echo HR\n; do echo BFont Size='10'$event[cal_title]nbsp;nbsp;nbsp;nbsp;-nbsp;nbsp;nbsp;$event[cal_location]/B/Font\n; echo BR\n; echo $event[cal_description]; echo BR\n; echo HR\n; while ($event = mysql_fetch_array($events)); else echo No Public Events Are Currently Scheduled...; ? ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] 2 queries -- 1 array
Not sure if this is exactly what you're looking for, Matt, but I think it is. ?php $query = SELECT t1.NAME, t1.BUSINESS, t1.ADDRESS, t1.CITY, t1.PHONE, t2.CONTACT_NAME, t2.CONTACT_VALUE FROM Table1 as t1, Table2 as t2 WHERE t1.ID = t2.CONTACT_ID $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { // to make it easier to read, I'll assign the values to variables for this demonstration $name = $row['NAME']; $business = $row['BUSINESS']; $address = $row['ADDRESS']; $city = $row['CITY']; $phone = $row['PHONE']; $contactname = $row['CONTACT_NAME']; $contactvalue = $row['CONTACT_VALUE']; $bigarray[$name][$contactname] = $contactvalue; } $JoeBrownPrevsys = $bigarray['Joe Brown']['Prevsys']; ? If that's not right, please re-describe the problem and let's see what we can figure out. If you have questions about what/how/why/etc... feel free to ask. -TG = = = Original message = = = Hello, I need to query two different tables and create one BIG array. I can query both tables, but can't find a way to combine the results in one array. The problem comes in with the second table. It has a weird layout. The second table only has four fields. They are: contact_id, contact_owner, contact_name, and contact_value a.. The 'contact_id' needs to be linked to 'id' field from the first table. b.. The contact_name is a field I need to use to reference what i'm looking for. example... contact_name HAS values of RANO, PrevSys, Supplier, Dynamic each of them has the same contact_id different contact_names with different contact_values To query the second table I do something like this: SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='Supplier' and contact_id=' XXX' The xxx is the ID from the first table. - Table 1: IDNAMEBUSINESS ADDRESSCITY PHONE 1 John SmithSmith's Phone Co. 100 Main St Someplace 555- 2 Joe Brown Brown's Shoe Store105 Grant St.This City 555-0001 Table 2: CONTACT_IDCONTACT_NAME CONTACT_VALUECONTACT_OWNER 1 PrevSys NONE 4 1 RANO 100102 4 1 Supplier TrueValue 4 1 Dynamic 192.168.0.0 4 2 PrevSys OLD POS SYS 4 2 RANO 100105 4 2 Supplier Orgill 4 2 Dynamic 192.168.100.0 4 I want to query both tables and create a array. The extra fields from table two need to have their own field in the array. I need to call those extra fields in the array by the contact_name field... example $myrow[supplier] $myrow[PrepSys] $myrow[name] I have tried alot of stuff to get this done, but i think i was very off task. Some help/guide is needed I'm new Thanks... Matt ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] 2 queries -- 1 array
Ok, in your original message you said something about using the name as dominant key (or whatever you want to call it). All the SQL does is gather all the data together in an associated fashion. You can use the array you build to organize the data. I'm still not 100% sure what you're doing, so I can't say this is the best way, but let's look at the exampe I gave and change it to hopefully suit your last description: $name = $row['NAME']; $business = $row['BUSINESS']; $address = $row['ADDRESS']; $city = $row['CITY']; $phone = $row['PHONE']; $contactname = $row['CONTACT_NAME']; $contactvalue = $row['CONTACT_VALUE']; // $bigarray[$name][$contactname] = $contactvalue; $bigarray[$contactname][$name] = $contactvalue; foreach ($bigarray['Supplier'] as $name = $value) { echo Supplier: $name has CONTACT_VALUE = $valuebr\n; } There may be an elegant way to do what you want in SQL too, I'm just not fully groking the situation I think. -TG $name = $row['NAME']; $business = $row['BUSINESS']; $address = $row['ADDRESS']; $city = $row['CITY']; $phone = $row['PHONE']; $contactname = $row['CONTACT_NAME']; $contactvalue = $row['CONTACT_VALUE']; $bigarray[$name][$contactname] = $contactvalue; = = = Original message = = = yeah..that is what i'm trying to do, but I need to query WHERE contact_name='Supplier' and bring back the value for contact_value query WHERE contact_name='RANO' and bring back the value for contact_value query WHERE contact_name='Dynamic' and bring back the value for contact_value query WHERE contact_name='PrevSys' and bring back the value for contact_value Which are all different rows in the second table with the same ID field thats how they are linked to the first table thanks... Matt - Original Message - From: [EMAIL PROTECTED] To: php-db@lists.php.net Cc: [EMAIL PROTECTED] Sent: Friday, January 12, 2007 4:26 PM Subject: Re: [PHP-DB] 2 queries -- 1 array Not sure if this is exactly what you're looking for, Matt, but I think it is. ?php $query = SELECT t1.NAME, t1.BUSINESS, t1.ADDRESS, t1.CITY, t1.PHONE, t2.CONTACT_NAME, t2.CONTACT_VALUE FROM Table1 as t1, Table2 as t2 WHERE t1.ID = t2.CONTACT_ID $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) // to make it easier to read, I'll assign the values to variables for this demonstration $name = $row['NAME']; $business = $row['BUSINESS']; $address = $row['ADDRESS']; $city = $row['CITY']; $phone = $row['PHONE']; $contactname = $row['CONTACT_NAME']; $contactvalue = $row['CONTACT_VALUE']; $bigarray[$name][$contactname] = $contactvalue; $JoeBrownPrevsys = $bigarray['Joe Brown']['Prevsys']; ? If that's not right, please re-describe the problem and let's see what we can figure out. If you have questions about what/how/why/etc... feel free to ask. -TG = = = Original message = = = Hello, I need to query two different tables and create one BIG array. I can query both tables, but can't find a way to combine the results in one array. The problem comes in with the second table. It has a weird layout. The second table only has four fields. They are: contact_id, contact_owner, contact_name, and contact_value a.. The 'contact_id' needs to be linked to 'id' field from the first table. b.. The contact_name is a field I need to use to reference what i'm looking for. example... contact_name HAS values of RANO, PrevSys, Supplier, Dynamic each of them has the same contact_id different contact_names with different contact_values To query the second table I do something like this: SELECT contact_value FROM egw_addressbook_extra WHERE contact_name='Supplier' and contact_id=' XXX' The xxx is the ID from the first table. - Table 1: IDNAMEBUSINESS ADDRESSCITY PHONE 1 John SmithSmith's Phone Co. 100 Main St Someplace 555- 2 Joe Brown Brown's Shoe Store105 Grant St.This City 555-0001 Table 2: CONTACT_IDCONTACT_NAME CONTACT_VALUECONTACT_OWNER 1 PrevSys NONE4 1 RANO 100102 4 1 Supplier TrueValue 4 1 Dynamic 192.168.0.0 4 2
Re: [PHP-DB] Filter array results... no copies
If all you want is a unique list of adr_one_region codes, then use the DISTINCT keyword in your SQL: SELECT DISTINCT adr_one_region FROM egw_addressbook WHERE cat_id='8' ORDER BY adr_one_region -TG = = = Original message = = = Hello everyone I'm back working on the website again... I'm having lots of fun. I have a sql query that looks at one field in a database. (result2 query) Then i have mysql_fetch_array statement. I then use this array to print links on the page. Works fine except I don't want duplicate links. It creates links for the states. If we have four customers from Pennsylvania. This current process gives me four different PA links on my page. I need a statement that says...if its already printed...don't print it... Thanks... Here is my code: html body ?php $db = mysql_connect(HOST, USERNAME, PASSWORD); mysql_select_db(DATABASE,$db); if ($_GET[area]==) $master = mysql_query(SELECT * FROM egw_addressbook WHERE cat_id='8' ORDER BY org_name, $db); else $master = mysql_query(SELECT * FROM egw_addressbook WHERE cat_id='8' and adr_one_region='$_GET[area]' ORDER BY org_name, $db); $result2 = mysql_query(SELECT adr_one_region FROM egw_addressbook WHERE cat_id='8' ORDER BY adr_one_region, $db); if ($area = mysql_fetch_array($result2)) echo Sort by State: ; do echo a href='index.php?area=$area[adr_one_region]'$area[adr_one_region]/a\n; echo - ; while ($area = mysql_fetch_array($result2)); echo a href='index.php?area='ALL/a\n; else echo ERROR; if ($myrow = mysql_fetch_array($master)) echo CENTER\n; echo table border=0\n; echo img src=file.jpg width='611' height='136'\n; echo BR\n; echo BR\n; do printf(tr td/tdtdb%s/b/tdtd/tdtd/tdtd%s/td/tr\n, $myrow[org_name], $myrow[fn]); printf(tr td/tdtd%s/tdtd/tdtd/tdtd%s/td/tr\n, $myrow[adr_one_street], $myrow[tel_work]); printf(tr td/tdtd%s, %s %s/tdtd/tdtd/tdtd/tdtd/td/tr\n, $myrow[adr_one_locality], $myrow[adr_one_region], $myrow[adr_one_postalcode]); while ($myrow = mysql_fetch_array($master)); echo /table\n; echo /CENTER\n; else echo Sorry, no records were found!; ? /body /html ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Displaying next ten items
I am wondering what the mySQL commands are to display the next 10 records / previous 10 records. I am wondering how you pass a variable through a PHP script so the script knows which next or previous 10 entries to display. (Especially since this is all variable driven) Would you do something like ?next=21 and ?previous=1 as part of the URL link to know where your query should begin? I do know the LIMIT = mySQL command to limit 10 items to be displayed. How do you tell when there aren't 10 more entries left to display? IE If there are 46 records in a table and you are displaying 40 to 46 you don't want to offer a link to display records 50 to 59. Ron
[PHP-DB] 10 rows
I would normally just pass the offset through the get var. I understand what you are saying in concept ... but what would a sample command be like? a href=http://www.host.com/script.php?next=21;Next Link/a a href=http://www.host.com/script.php?previous=1;Previous Link/a Ron
Re: [PHP-DB] Order By [blank]
This is a little weird looking, but should do the job. Remember that items in your 'order by' can be manipulated conditionally. In this case, I'm looking for NULL as well as '' (empty) and changing it to something that should come after all your normal alphabetical values, but it doesn't change what appears in your results. This only affects the sorting: select * from sometable order by if(ifnull(somecolumn, '') = '', '', somecolumn) Hope that helps. -TG = = = Original message = = = I have this column in mysql: A F D [ empty ] A C If I do an order by on that column, this is what I get: [ empty ] A A C D F What I would like is this: A A C D F [ empty ] Is there any way to achieve this in a single MySQL query? Using DESC in this case doesn't work, because while it puts the empty row in the last place, it does the rest as well. I could also do 2 queries where it calls it once in order WHERE !='', and then do another query to get the empty ones, but that seems a bit cumbersome. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Order By [blank]
This is a little weird looking, but should do the job. Remember that items in your 'order by' can be manipulated conditionally. In this case, I'm looking for NULL as well as '' (empty) and changing it to something that should come after all your normal alphabetical values, but it doesn't change what appears in your results. This only affects the sorting: select * from sometable order by if(ifnull(somecolumn, '') = '', '', somecolumn) Hope that helps. -TG = = = Original message = = = I have this column in mysql: A F D [ empty ] A C If I do an order by on that column, this is what I get: [ empty ] A A C D F What I would like is this: A A C D F [ empty ] Is there any way to achieve this in a single MySQL query? Using DESC in this case doesn't work, because while it puts the empty row in the last place, it does the rest as well. I could also do 2 queries where it calls it once in order WHERE !='', and then do another query to get the empty ones, but that seems a bit cumbersome. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Order By [blank]
You shouldn't have to do that. the IFNULL() handles all that. If the item is null, it returns an emptry string ''. If it's blank/empty, it returns an empty string. This is just used for the comparison = ''. This determines if it's empty or null and if so, returns 'ZZ', if not, it returns the unaltered value. And again, this returned value is only used for the sorting. The values you get from select * will be unaltered. Is this more efficient than doing two SELECTs and a UNION? I have no idea. But I like to keep things as clean as possible and in my reading and experience, letting the server handle an IFNULL() function should be quicker than doing four value checks (is null, is not null, = '' and != ''), collecting the values of two SELECTS then checking to see if it's able to UNION them together. Also, less code/typing typically means less chance of typos. BTW: In my example, realistically you could probably shorten the morphed value to ZZ or ZZZ unless you think you'll values in your database that will start with and get bumped lower on the sorting. -TG = = = Original message = = = In case the blank is a null or is really a blank: select * from blank where tchar_10 is not null and tchar_10 != '' union all select * from blank where tchar_10 is null or tchar_10 = '' - Dave On 12/21/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: This is a little weird looking, but should do the job. Remember that items in your 'order by' can be manipulated conditionally. In this case, I'm looking for NULL as well as '' (empty) and changing it to something that should come after all your normal alphabetical values, but it doesn't change what appears in your results. This only affects the sorting: select * from sometable order by if(ifnull(somecolumn, '') = '', '', somecolumn) Hope that helps. -TG = = = Original message = = = I have this column in mysql: A F D [ empty ] A C If I do an order by on that column, this is what I get: [ empty ] A A C D F What I would like is this: A A C D F [ empty ] Is there any way to achieve this in a single MySQL query? Using DESC in this case doesn't work, because while it puts the empty row in the last place, it does the rest as well. I could also do 2 queries where it calls it once in order WHERE !='', and then do another query to get the empty ones, but that seems a bit cumbersome. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MSSQL Server
I had some issues a couple years ago connecting to the MS SQL Server where I was employed at the time. I was probably just doing something wrong, but what I ended up using that worked for me was using the ADODB database abstraction layer. Helped me connect to MS SQL , Oracle and some other random data sources I had to from time to time. http://adodb.sourceforge.net/ Sorry I don't have time to look for good examples, but maybe the documentation will help out some and get you on the right path. -TG = = = Original message = = = I cannot connect to my MSSQL server. I use the following connection string: php: -- $connection = mssql_connect http://php.net/mssql_connect('server','user', 'password') or die ('server connection failed'); $database = mssql_select_db http://php.net/mssql_select_db(database_name , $connection) or die ('DB selection failed'); ? -- The MSSQL server is setup to use Windows and Server Authentication. I have a *local* dummy account setup for testing and when using this account I can connect with no problems, but when I try and use my domain/network account I cannot connect at all. (my network account has full access to the server, database and tables) I can even login to the SQL Management Studio using Windows Authentication and my network account, but still cannot connect using PHP. Any ideas? ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] search result error message
Sorry, don't have time to test and noodle through why yours may or may not be working, but I see some differences in how you're doing it and how we tend to do it here. After doing the connection and database selection, this is how we handle stuff (simplified): $query = select * from sometable; $result = mysql_query($query); $count = mysql_affected_rows(); while ($row = mysql_fetch_assoc($result)) { // do some stuff $address = $row['address']; // example of how to get/use data returned } Nothing inside the while construct should execute if you get zero results. You really don't need to use the mysql_affected_rows() either unless you want to test for zero results and display an error message, like I believe you wanted to do. -TG = = = Original message = = = Hi, The below mentioned code works fine. Connects to the database, fetches the result, and displays neatly in a table. If there is no data then it jumps to the if condition and displays the error message. BUT if the 'if' condition is running and no data is present the Table headings and the bottm of empty table is still displayed above the error message. Can you please check and share with me as in where exactly the logic is wrong. -- -- Code --- h2Your favorites search result/h2divYou are here: index.htm Home Your favorites/div~~ div class=internalContentArea sgtable ~~~div class=tableHeadSub-category search result/div~~ ~div ~table width='100%' id='table1' cellspacing=0theadtr th scope=colShop name/th /tr/theadtbody ?php // database information $host = 'xxx'; $user = 'xxx'; $password = 'xxx'; $dbName = 'xxx'; mysql_connect(localhost,$user,$password); @mysql_select_db($dbName ) or die( Sorry But There Seems To Be A Problem Connecting To The Database); $query=SELECT * FROM shop; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i $num) $shopname=mysql_result($result,$i,shopname); echo tr td$shopname/td /tr; $i++; ?/tbody/table index.htm Back to search div /div ? if ($num == 0) echo div div class='alert'The search criteria you entered did not generate any result, index.htm please try again ./div ~/div; ? ~ /div. -- View this message in context: http://www.nabble.com/search-result-error-message-tf2867391.html#a8014018 Sent from the Php - Database mailing list archive at Nabble.com. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ORDER BY
Is it possible to do an ORDER BY column_a column_b ASC ? IE Can you specify two columns to cause the output to be displayed in a specific order? Ron
[PHP-DB] Verifying syntax executed correctly
If I give this command through PHP to mySQL mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = UPDATE `table` SET `last_activity_field` = '$current_date' WHERE `reference` = '$account_reference' LIMIT 1;; mysql_query($query); mysql_close(); is there a way to know if it executed successfully? Ron
[PHP-DB] month
Is there a slick and easy way to convert January to 01 ? (and February to 02, etc) Ron
Re: [PHP-DB] month
I have completely missed it and need to try again.
[PHP-DB] Files uploaded through a form
The way my web hosting server was configured is that files uploaded through a web form to be processed by PHP are owned by 'www'. I am wondering if I am able to change the owner of the file to my ftp user name before I use the move_uploaded_file command to the directory I need the file to move to. I am also wondering what the IF syntax is to see if the file upload was successful. Somehow I would like to know if move_uploaded_file( $userfile , $destination_file_name); worked successfully before I update my table. Ron
[PHP-DB] ECHO $variable
In one of my scripts I have input type=text name=message_title size=40 maxlength=80 value=?echo $saved_message_title;? where $saved_message_title is 1 Peter 5:7 Cast all your cares on Him for He cares about you --- note the When this is displayed on the screen it reads 1 Peter 5:7 I am assuming the closes the value= How may I echo this to the screen and have the full text be displayed, not just 1 Peter 5:7 ? Ron
[PHP-DB] SELECT date query
I am wondering if someone would help me write a SELECT date query ... Weekly mailings go out every Wednesday. I am setting up an administration function and table to store the mailing name, PDF to be contained within the mailing and the date for it to be used. The SELECT query I want to create is for the next 12 records which are going to be used to be displayed. The first record would be next Wednesday (not October 11th, but calendar wise based on when the script ran) and then the following 11 Wednesdays. SELECT * FROM christian_discipleship WHERE created_for_date = '$next_wednesday' ORDER BY created_for_date ASC LIMIT 12 I am not sure how to generate the value for $next_wednesday Any ideas? Ron
RE: [PHP-DB] Search engine
What I haven't figured out is how to crawl my site. If I knew how to crawl my site I could write a basic search engine and develop it over time. This is the crucial issue I need help with. I have a really basic search engine I wrote last year. I told my web site what pages the user could search ... as in I keyed in the URL's I am giving my site a face lift and making some serious changes to it ... I have my database out of date ... I would like to crawl my site once a day to update what changes I made during the past 24 hours and delete HTML files which no longer exist. If someone knew how to retrieve various a href= then I could start with something and build on it over time ... Ron On Thu, 2006-09-28 at 11:44 +0100, Shaun A Riches wrote: What about the MySQL LIKE command? Research it. This is assuming your data is stored properly without redundant data and in a MySQL database. ___ Shaun Riches Computer Science Student -Original Message- From: Ron Piggott (PHP) [mailto:[EMAIL PROTECTED] Sent: Thu 28/09/2006 03:44 To: PHP DB Subject: [PHP-DB] Search engine ___ Shaun Riches Computer Science Student -Original Message- From: Ron Piggott (PHP) [mailto:[EMAIL PROTECTED] Sent: Thu 28/09/2006 03:44 To: PHP DB Subject: [PHP-DB] Search engine Has anyone wrote a search engine for the web site? I am wondering if someone has the time to help me walk through doing this. Ron
[PHP-DB] Searching PHP strings
I have been playing tonight for a few minutes. The following code: ? $lineArray = file(/home/actsmin/www/home_page.html); // make an empty variable first $content = ; // concat all array element foreach($lineArray as $eachLine) { if ( eregi(a href= , $eachLine) == 1 ) { #line contains a link echo strlen(stristr($eachLine, a href=)) . \r\n; echo trim(stristr($eachLine, a href=)) . \r\n; } $content .= $eachLine; } ? Produces me output like: 137 a href=http://www.actsministrieschristianevangelism.org/christianliving/quiet_time_quotations_and_reflection_topics.html;here/a.p What I want to do now is to remove the a href= and just be left with http://www.actsministrieschristianevangelism.org/christianliving/quiet_time_quotations_and_reflection_topics.html and remove all the text which follows this --- On this line it is here/a.p Would someone help me do this? Ron
[PHP-DB] I still have a bit more of the string to get rid of ...
Where '$eachLine' is a line of HTML code the following command echo str_replace(a href=\, , trim(stristr($eachLine, a href=))) . \r\n; give me this result: http://www.actsministrieschristianevangelism.org/christianliving/quiet_time_quotations_and_reflection_topics.html;here. I want to get rid of everything including and following the What do I do next?
[PHP-DB] $_SERVER
Is there a predefined variable that will tell me the resolution of the browser that is looking at my site? EXAMPLE 1024 X 768 OR 800 X 600 Ron
[PHP-DB] Search engine
Has anyone wrote a search engine for the web site? I am wondering if someone has the time to help me walk through doing this. Ron
RE: [PHP-DB] Re: Page refresh and database updation
You can redirect the page to the result page after the data is saved, using header(Location: successpage.php). I've used this on several sites. It's a little extra work but does prevent the reposting of data. Another option is to use AJAX to send the data to the webserver and then have the javascript open the result page after the update is complete. I do this on several of my webpages and it works great. Tamkhane, Pravin wrote: Hi All, I am a PHP newbie. I am using HTTP POST request to send some data to Apache and then using MySql to store that information. Once information is stored in MySql DB successfully, I display a result page. But the problem I am facing is that, if I refresh the result page displayed after database updation, the information is stored again in database which I don't want to. Please guide me on how I can avoid duplication of information in database on refreshing the page. Thanks in advance! Regards, Pravin You probly want to use a seperate script to build the results, or even a PEAR template mechanism. /cs -- 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] ViewSonic VX724
I realized this is off topic; I am not sure where I would look online. Today I purchased a VX724 LCD monitor for my computer. I am running Fedora Core (Linux). I am not sure where I would find a driver for my monitor. ViewSonic's tech support told me they don't support the monitor directly and I would need to build my own driver. I am wondering if this has already been done. The monitor does work on my computer, but the color scheme is off. If someone could help send me in the right direction I would appreciate it. Ron
[PHP-DB] Displaying a PDF file
I am creating a submit button on the fly. The purpose of this is to open up a new browser window and then display the contents of a PDF file. The code for this button reads: input type='button' value='Psalm 91' onclick=window.open('index.php?request=view_prayer_ministry_documentdocument_reference=1','prayer_ministry_document_viewer','width=800,height=600,toolbars=no,resizable=yes,scrollbars=yes'); The window name is prayer_ministry_document_viewer I am trying to access document_reference 1 which is in a mySQL table. mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query=SELECT * FROM prayer_ministry_documents WHERE reference = '$document_reference'; $document_result=mysql_query($query); mysql_close(); $document_file_name = mysql_result($document_result,0,document_file_name); #now here I start to get the contents of the PDF file to display $lineArray = file($document_file_name); // make an empty variable first $document_contents_to_display = ; // concat all array element foreach($lineArray as $eachLine) { $eachLine = wordwrap($eachLine); $document_contents_to_display .= $eachLine; } #when I try to display it the PDF it displays it as text with the various ASCII characters --- #what I am doing wrong / what is the correct way to do this #I know I could simply specify the file name / path following the window.open ... but I am trying to see if I am able to accomplish the same results this way. echo $document_contents_to_display; ? Ron
[PHP-DB] Forms with letter verification
You know forms which have a security field where the user reads back the letters that are displayed? I am wondering if someone has the time to coach me in writing this --- or if you know of a web page that shows how to create this feature. I have already created a set of graphical letters. Ron
Re: [PHP-DB] running program after insert w/MySQL 4.1
cron or Windows Task Manager would work if you want to check the status of the data periodically, but I believe you can also use Access to hit a web address (it doesn't have to display anything) so you could, at time of insert, have Access activate a PHP script on your web server that does the database check. You could probably get the last inserted ID number as well and pass that to the PHP script if you want to check specific records right after they're inserted. -TG = = = Original message = = = I have an Access database connecting via ODBC to a local MySQL machine and doing inserts. It does these inserts throughout the day. After each insert, I need a PHP program run. Alas, MySQL 4.1 doesn't do triggers, etc., and upgrading to 5.x looks non-trivial. What else can I do? Is there any way to trigger something via the ODBC connection? A cron job? I'm open to suggestions. kind regards, bill ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem with list#2
You may get duplicate messages sometimes when someone responds directly to you as well as copying the message to the main mailing list. Like in this ccase, my To: field is the PHP DB list, and my CC: field is your personal email address. If that's not the issue, then try what Dave suggested and unsubscribe using one of your email addresses and see if that solves the problem. -TG On 7/7/06, Karl James [EMAIL PROTECTED] wrote: Team, I am still receiving duplicate emails. I check with my ISP and they tell me it is Not their problem. I tried to check the headers But I am not able to see anything that indicates What email address its being sent to because I have two of them. Can anyone help suggest on how to resolve this. I would send a screen shot but its not advise to In forums. Off list I can for sure if any one wants To see what's going on. Karl James (TheSaint) mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] www.theufl.com ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LIMIT
Here are some thoughts on the couple of methods shown: 1. SELECT count(*) as MyCount FROM aTable # Fast query done on server size SELECT * FROM aTable LIMIT 5 # Fast limited data return query done server side 2. SELECT * FROM aTable # Potentially slow query, lots of data stored in PHP mysql_num_rows() # Quick PHP-side function to tell how many results returned 3. SELECT SQL_CALC_FOUND_ROWS * FROM $table LIMIT 5 # Fast server side query that does the same as SELECT count(*) and SELECT LIMIT 5 at the same time SELECT FOUND_ROWS() # Fast server side query Seems like #1 and #3 are your best options. Both are pretty easy on your system. #3 is definitely pretty slick, thanks to whoever originally posted that. But I'm wondering if it'll be fully compatible in the future. #1 is pretty SQL 101 type stuff, so it should remain functional and be usable on other database platforms as well. That's the one I'd go for, just for the sake of keeping things simple if nothing else. Seems like a waste to do two database queries, but as long as you're not closing and re-opening the connection in between, it should cause very minimal impact on your system. Sometimes two queries are better than one. -TG = = = Original message = = = I see they call mysql_query twice which doesn't look like I'm gaining anything over running the 2 queries: SELECT count(*) as MyCount FROM aTable SELECT * FROM aTable LIMIT 5 But I suppose I need to time it for my app. http://us3.php.net/mysql_num_rows mancini at nextcode dot org 14-Nov-2005 02:24 here is a really fast mysql_num_rows alternative that makes use of the SELECT FOUND_ROWS() MySQL function , it only reads a single row and it is really helpfull if you are counting multiple tables with thousands of rows ?php function get_rows ($table) $temp = mysql_query(SELECT SQL_CALC_FOUND_ROWS * FROM $table LIMIT 1); $result = mysql_query(SELECT FOUND_ROWS()); $total = mysql_fetch_row($result); return $total[0]; ? +++ alex dot feinberg 4t gm41l 28-Apr-2005 04:56 Re dzver at abv dot bg's note... I just ran some tests using MySQL Super Smack. Surprisingly, a SELECT * followed by a SELECT COUNT(*) actually was close in speed to a SELECT SQL_CALC_FOUND_ROWS * followed by a SELECT FOUND_ROWS(), but the SQL_CALC_FOUND_ROWS solution was still a bit faster. Perhaps it varies by table structure? Either way, it might be worth checking which is faster for your application. Regards, Dwight -Original Message- From: Dwight Altman [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 05, 2006 9:53 AM To: 'php-db@lists.php.net' Subject: RE: [PHP-DB] LIMIT So how do I get this information on the PHP side? mysql SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name - WHERE id 100 LIMIT 10; mysql SELECT FOUND_ROWS(); I count 2 queries above (unless there is some caching magic). Whatever. I was hoping to add another column (like FOUND_ROWS) to an existing query and be able to pull out the FOUND_ROWS when I loop over the result set. Something like: SELECT *, FOUND_ROWS FROM aTable LIMIT 5 But since that single query doesn't work, how do I apply the MySQL solution and extract it on the PHP side? http://dev.mysql.com/doc/refman/4.1/en/information-functions.html http://www.mysqlfreaks.com/statements/101.php Regards, Dwight -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Friday, June 30, 2006 9:46 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] LIMIT If you're using MySQL then: SELECT SQL_CALC_FOUND_ROWS * FROM aTable LIMIT 5 SELECT FOUND_ROWS() It's in the mysql documentation under SELECT syntax I believe. Chris Dwight Altman wrote: Is there a way to get the number of rows that would have been returned had there not been a LIMIT clause in a SELECT statement? For example, if Query #1) SELECT * FROM aTable would normally return 100 rows. But Query #2) SELECT * FROM aTable LIMIT 5 will return 5 rows. Is there a way to find out that 100 rows would have been returned if there was no LIMIT clause, by using only Query #2 and maybe a PHP function on the $result? Regards, Dwight -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Cron unlink
Does anyone have experience in getting unlink to work within the context of a cron? I created my own garbage collection function and I am trying to delete some session files through a cron that runs every 10 minutes. The session files are owned by 'www' The cron is ran by 'actsmin' The 'unlink' command works within the context of a php script when activated by a user on the web site. Is there another file deletion command within PHP other than unlink? Here is the error message I am e-mailed by the cron when it doesn't successfully delete a session file: Warning: unlink(/path/to/sessions/files/): Is a directory in /path/to/php/script/cron/calls/script.php on line 47 Any suggestions? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ftp_connect($ftp_server);
Every now and then the following command fails --- the FTP connection is refused by the server: $conn_id = ftp_connect($ftp_server); Is there a way to delete a file within PHP without having to FTP to the server? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Conditional updating...
Thank you for the thought, however, I don't have a shell that I can run in, hence, I have to rely on help from others. JupiterHost.Net [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Grae Wolfe - PHP wrote: Sorry I have been out of touch... I thought I had this problem beat, but I was wrong. I decided that the best thing to do was to filter the variables as the $sql statement was being created. I tried using the following code, and got a message back that it was invalid and my Query couldn't execute... Can anyone tell me where I screwed this one up?? Print out $sql and then try to manually do it in your mysql (or whatver DB engine) shell. I imagine you have a syntax error and that will tell you exactly what and where it is :) And I hope you're only criteria for the value of each colum isn't that its just not empty. If so you will be vilnerable to SQL injection attacks and your data will be compromised. You should at the very least quote the values with a valid SQL quoting function. (IE not just wraping it in quotes but one that actually escapes certain characters and wraps it in quotes as need be) Do not rely on that automaticaly being done (IE think how crappliy unreliable and dangerous relying on Magic Quotes is, oi what pile *that* is...) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Conditional updating...
Sorry I have been out of touch... I thought I had this problem beat, but I was wrong. I decided that the best thing to do was to filter the variables as the $sql statement was being created. I tried using the following code, and got a message back that it was invalid and my Query couldn't execute... Can anyone tell me where I screwed this one up?? $sql = UPDATE $table SET; if(!empty($first_name)) $sql .='first_name='.$first_name.','; if(!empty($last_name)) $sql .='last_name='.$last_name.','; if(!empty($hs_last_name)) $sql .='hs_last_name='.$hs_last_name.','; if(!empty($street_address1)) $sql .='street_address1='.$street_address1.','; if(!empty($street_address2)) $sql .='street_address2='.$street_address2.','; if(!empty($city)) $sql .='city='.$city.','; if(!empty($state)) $sql .='state='.$state.','; if(!empty($zip)) $sql .='zip='.$zip.','; if(!empty($phone1)) $sql .='phone1='.$phone1.','; if(!empty($phone2)) $sql .='phone2='.$phone2.','; if(!empty($email_address)) $sql .='email_address='.$email_address.','; if(!empty($current_info)) $sql .='current_info='.$current_info.','; if(!empty($today)) $sql .='date_registered='.$today; WHERE first_name='$first_name' AND last_name='$last_name'; Jeffrey [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Perhaps I have misunderstood something here. But it seems to me that anyone who just happens to put John Smith's name in could alter Mr. Smith's data. If users can update their own data, should you not have a log in process to ensure that only the original user can update his data? Them once he has logged in, you can populate all fields with data from the DB. Jeffrey Grae Wolfe - PHP wrote: That was the first thing that I was going to do, but there is a concern there for security of the data being input... This is a registration site, and I don't want to provide information on John Smith to anyone who just happens to put his name in. Alejandro Tesone [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Why don't you try populating the fields the user intends to modify with the information you already have? Alex T On 6/17/06, Grae Wolfe - PHP [EMAIL PROTECTED] wrote: Good day! I have been working on this little free project for a while, and now I have hit another major hiccup. Is there a simple way to only update fields that have something in them? The problem that I am having is that if someone fills out information and submits it, it saves to the DB just fine. However, if they come back later and just put in, for example, a new phone number, it replaces all of the other information with blanks. Here is my current $sql query: $sql = UPDATE $table SET first_name='$first_name', last_name='$last_name', hs_last_name='$hs_last_name', guest_name='$guest_name', street_address1='$street_address1', street_address2='$street_address2', city='$city', state='$state', zip='$zip', phone1='$phone1', phone2='$phone2', email_address='$email_address', farmers_barn='$farmers_barn', wrhs_tour='$wrhs_tour', crystal_rose='$crystal_rose', registration_comments='$registration_comments', date_registered='$today' WHERE first_name='$first_name' AND last_name='$last_name'; -- 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] Conditional updating...
Good day! I have been working on this little free project for a while, and now I have hit another major hiccup. Is there a simple way to only update fields that have something in them? The problem that I am having is that if someone fills out information and submits it, it saves to the DB just fine. However, if they come back later and just put in, for example, a new phone number, it replaces all of the other information with blanks. Here is my current $sql query: $sql = UPDATE $table SET first_name='$first_name', last_name='$last_name', hs_last_name='$hs_last_name', guest_name='$guest_name', street_address1='$street_address1', street_address2='$street_address2', city='$city', state='$state', zip='$zip', phone1='$phone1', phone2='$phone2', email_address='$email_address', farmers_barn='$farmers_barn', wrhs_tour='$wrhs_tour', crystal_rose='$crystal_rose', registration_comments='$registration_comments', date_registered='$today' WHERE first_name='$first_name' AND last_name='$last_name'; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Conditional updating...
That was the first thing that I was going to do, but there is a concern there for security of the data being input... This is a registration site, and I don't want to provide information on John Smith to anyone who just happens to put his name in. Alejandro Tesone [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Why don't you try populating the fields the user intends to modify with the information you already have? Alex T On 6/17/06, Grae Wolfe - PHP [EMAIL PROTECTED] wrote: Good day! I have been working on this little free project for a while, and now I have hit another major hiccup. Is there a simple way to only update fields that have something in them? The problem that I am having is that if someone fills out information and submits it, it saves to the DB just fine. However, if they come back later and just put in, for example, a new phone number, it replaces all of the other information with blanks. Here is my current $sql query: $sql = UPDATE $table SET first_name='$first_name', last_name='$last_name', hs_last_name='$hs_last_name', guest_name='$guest_name', street_address1='$street_address1', street_address2='$street_address2', city='$city', state='$state', zip='$zip', phone1='$phone1', phone2='$phone2', email_address='$email_address', farmers_barn='$farmers_barn', wrhs_tour='$wrhs_tour', crystal_rose='$crystal_rose', registration_comments='$registration_comments', date_registered='$today' WHERE first_name='$first_name' AND last_name='$last_name'; -- 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] Forms with letter security
I have a set of graphical letters A to Z. I want some displayed and then keyed into a security field to verify a person is submitting the form. I have seen these used before on shopping carts. I know about creating salts to select which letters to choose. What I am wondering is if there is a way to join the letters together instead of having 6 different images displayed. Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select distinct field won't return distinct value
Correct me if I'm wrong, but it sounds like you have something like this: 123 Joe 124 Joe 125 Sue 126 John 127 Joe 128 Frank 129 Sue And you want to output something like: Joe 123, 124, 127 Sue 125, 129 John 126 Frank 128 But what you're getting is: Joe 123 Joe 124 ..etc You have two ways you can solve this: 1. Do two SQL queries: SELECT DISTINCT cus_name FROM customers while ($result) { // forgive the pseudo-code SELECT cus_id FROM customers WHERE cus_name = $result['cus_name'] while ($result2) { echo $output; } } Or.. 2. Collect data into an array and process 'distinctness' on output SELECT cus_name, cus_id FROM customers while ($result) { $cus_arr[$cus_name][] = $cus_id; } foreach ($cus_arr as $cus_name = $cus_idarr) { echo $cus_name as ids: . implode(, , $cusidarr) . br\n; } There may be some tricky ways in SQL to get the data the way you want it, but ultimately it's not worth the bending over backwards for (do I remember right that you can do it with crosstab queries? don't even know if MySQL will do those properly). Easier just to do it with one of the methods above. Good luck! -TG = = = Original message = = = I want select distinct field and return value of that field, but I have problem which is: select distinct returns duplicate value. eg, I wan select distinct customer name and id from the customer table. one customer may have different cus_ids since cus_ids are auto increment and depend on the purchased items. so what I want is to select distinct customer name so that I can print customer name and customer id once. here is algorithm; select distinct cus_name, cus_id from customers order by cus_name asc While row is not empty do echoa href=\page?cus=cus_id\costomer name/abr /; ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Automatically +1 every 30 mins to a value in the database.
An alternative to cron jobs or scheduled tasks (if they're not an option) is to have a marker somewhere (probably in your database) that records a timestamp for the last 'gold' update then when someone does get around to accessing the database through normal operations, have it figure out how many 30 minute periods have occurred between the timestamp and now and update the gold then. The cron job is preferrable but if you're looking for alternate ideas, there's one for ya. Good luck! -TG = = = Original message = = = Hi there. I've posted this up on both this list, and the mysql list as I'm not sure whether this is something that I'd need to do with the php or mysql. Basically, I am making an add-on to my small website which is a mini online game. Every user will have gold, and every 30mins I'd like their amount of gold to go up by 1 (or say a variable say $goldupdateamount). I'd like to know which would be the best way of doing this, and if there is a command in php which would achieve this. Regards, Alex. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Combining Fields
Good Day! I am trying to use my limited knowledge to create a VERY simple process to display some of the information in my table, allow a particular record to be selected, then opened on a page with text boxes to edit the information, after which the UPDATE command will be used to update the database. That being said, I have a way that I think this will work, but I don't have a unique record number in my table for each of the entries. I have tried getting PHPMyAdmin to set this up, but I cannot seem to make it work. SO - I need to try to create that ID on the fly. I figured I could just combine the first and last names to make this ID, but I am not sure what the syntax should be. Here is the code I have dealing with defining the variables... Any help or thoughts would be splendid! while ($row = mysql_fetch_array($result)) { $id = $row['last_name'],$row['first_name']; $fname = $row['first_name']; $lname = $row['last_name']; $option_block .= option value=\$id\$lname, $fname/option; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Combining Fields
Thank you Brad - That is what I was looking for, but now that I see how it behaves, I am thinking that it isn't going to work the way I wanted. I need to then be able to pass the ID back to MySQL so that it will retrieve just the one record for editing. I guess I need to go back to making the DB create an auto-incrementing ID number. Hmmm... Thanks!! Brad Bonkoski [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Grae Wolfe - PHP wrote: Good Day! I am trying to use my limited knowledge to create a VERY simple process to display some of the information in my table, allow a particular record to be selected, then opened on a page with text boxes to edit the information, after which the UPDATE command will be used to update the database. That being said, I have a way that I think this will work, but I don't have a unique record number in my table for each of the entries. I have tried getting PHPMyAdmin to set this up, but I cannot seem to make it work. SO - I need to try to create that ID on the fly. I figured I could just combine the first and last names to make this ID, but I am not sure what the syntax should be. Here is the code I have dealing with defining the variables... Any help or thoughts would be splendid! while ($row = mysql_fetch_array($result)) { $id = $row['last_name'],$row['first_name']; $fname = $row['first_name']; $lname = $row['last_name']; $option_block .= option value=\$id\$lname, $fname/option; Use the dot (.) for appending variables... so it would be: $id = $row['last_name'].$row['first_name']; ...or course if you want that would look like this: 'SmithAdam' if you want 'Smith,Adam' as your id then: $id = $row['last_name'].,.$row['first_name']; -Brad -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Combining Fields
Again, my many thanks - I didn't know about the 'explode' function - that may be a huge help. Hopefully, I am on the right track now... thanks! Brad Bonkoski [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Grae Wolfe - PHP wrote: Thank you Brad - That is what I was looking for, but now that I see how it behaves, I am thinking that it isn't going to work the way I wanted. I need to then be able to pass the ID back to MySQL so that it will retrieve just the one record for editing. I guess I need to go back to making the DB create an auto-incrementing ID number. Hmmm... Thanks!! Well, the unique ID would probably be the *best* way to go, but you could also get the record with the below solution, of course this requires every combination of first and last name is unique... if you do: $id = Smith,Adam Then: list($fname, $lname) = explode(,,$id); select * from table where first_name = '$fname' and last_name='$lname' would do the trick... Of course this has many what-ifs asociated with it...all of which would be taken care of with an auto-incrementing/primary key ID field for wach record ;-) -Brad Brad Bonkoski [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Grae Wolfe - PHP wrote: Good Day! I am trying to use my limited knowledge to create a VERY simple process to display some of the information in my table, allow a particular record to be selected, then opened on a page with text boxes to edit the information, after which the UPDATE command will be used to update the database. That being said, I have a way that I think this will work, but I don't have a unique record number in my table for each of the entries. I have tried getting PHPMyAdmin to set this up, but I cannot seem to make it work. SO - I need to try to create that ID on the fly. I figured I could just combine the first and last names to make this ID, but I am not sure what the syntax should be. Here is the code I have dealing with defining the variables... Any help or thoughts would be splendid! while ($row = mysql_fetch_array($result)) { $id = $row['last_name'],$row['first_name']; $fname = $row['first_name']; $lname = $row['last_name']; $option_block .= option value=\$id\$lname, $fname/option; Use the dot (.) for appending variables... so it would be: $id = $row['last_name'].$row['first_name']; ...or course if you want that would look like this: 'SmithAdam' if you want 'Smith,Adam' as your id then: $id = $row['last_name'].,.$row['first_name']; -Brad -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Processing a web form / loop etc.
I have a web form that accepts up to 3 suggested categories. In the form they are part of I have named these variables $suggested_category_1 $suggested_category_2 $suggested_category_3 I have come up with this simple code to store the suggestion in a table: if ( $suggested_category_1 ) { #the user could leave the suggestion blank because what is already provided is sufficient mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = INSERT INTO table_name VALUES ( '$variable' , '$reference_number', '$suggested_category_1'); mysql_query($query); mysql_close(); } Is there any way to create a loop to check all three instead of me repeating this code twice more changing $suggested_category_1 to _2 and _3 ? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Processing a web form / loop etc.
Hi Stutt Thanks. I hadn't included much of the code for easy reading. I just had to use the $_POST[$val] to get the actual values. Thanks for your help. Ron for ($num = 1; $num = 3; $num++) { $varname = 'suggested_category_'.$num; $val = $$varname; // Stick your code here replacing references to the $suggested_category_1 var with $val } Incidentally, I do hope that code was simplified for brevity. There should be extensive use of mysql_real_escape_string in there. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Left Join Question
One thing I've done in situations like this is just load your returned DB data into an array. Something like this would do: $dvdarr[$result['call_number']]['Title'] = $result['title']; $dvdarr[$result['call_number']]['Publisher'] = $result['publisher']; $dvdarr[$result['call_number']]['Comments'][] = $result['comment']; Put that in a loop of your results. Notice the [] on the comments. That'll collect all your comments under the umbrella of 'Comments'. Then when you go to do your output, you'd do something like this: forach ($dvdarr as $callnumber = $dvddata) { $title = $dvddata['Title']; $publisher = $dvddata['Publisher']; $comments = $dvddata['Comments']; foreach ($comments as $comment) { // do whatever } } There are other ways to handle this.. this might be one of the easier ones (if I'm understanding your problem correctly). -TG = = = Original message = = = Hello, all. I don't know if this is a php-mysql question or just a mysql, but here goes: I have a list of DVDs that my library loans out, and I'd like to allow people to add comments to each item. Since this list gets regenerated periodically (it's extracted from another system, the library catalog), there isn't a consistent ID in the dvd tables, so I'm using the call number (which will look like DVD 2324) as the key. Anyhow, I join the tables like this to get all the DVDs and all the comments associated with the DVDs: SELECT distinct dvds.title, dvds.publisher, dvds.publication_date, dvds.call_number, comment.id, comment.parent_id, comment.comment, comment.name FROM dvds LEFT JOIN comment ON dvds.call_number=comment.parent_id WHERE dvds.title LIKE 'A%' ORDER BY dvds.title With this, I'll get results like DVD 101A.I. This movie rocked DVD 101A.I. This Movie stunk DVD 102Adaptation . . . DVD 103After Hours . . . When I loop in PHP through the records, of course, I want just the one DVD with however many comments associated with it. Is it possible to do this (i.e., screen out DVD dupes) in MySQL, or do I have to do it in PHP? If this is a dumb question, my humblest apologies, and I'd be interested if there was a better way to handle this . . . . Andrew ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Adding url to google
Sounds like you're asking how to programmatically add your web site to Google's search. I didn't dig very deep, but it doesn't look like Googles API provides for the ability to submit (only search) and by Google's addurl page (http://www.google.com/addurl/?continue=/addurl) it appears that they don't want you to be able to automate the adding of URLs or else they wouldn't be using CAPTCHA methods to prevent bots from spamming them. You may look into software like SubmitWolf or some of the others that automate submissions and try to figure out how they do it (if at all) but I'm guessing it's not going to really be feasible for you to do this... not easily at least. -TG = = = Original message = = = Hi all, I am developing the site using php and mysql. I have to add the url at google site through php code. If any one have idea about it, please help me. Regards Manoj ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Too stupid to UPDATE...
I am trying to write a script to handle event registration. Most of the people that will be registering are already in the database, but not all, and those that are may not have current information. Here is my latest effort, or at least a snippet of it... Can anyone point out where I went stupid, or if there is a better way of doing this? THANKS!!! ===--- BEGIN SNIPPET ---=== $db = @mysql_select_db($dbname, $connection) or die(Couldn't Select Database.); $link = mysql_connect($server, $user, $pass); mysql_select_db($dbname, $link); $result = mysql_query(SELECT * FROM $table WHERE first_name='$first_name' AND hs_last_name='$hs_last_name' AND last_name='$last_name', $link); $num_rows = mysql_num_rows($result); if($num_rows) { $sql = UPDATE $table SET first_name=\$first_name\, last_name=\$last_name\, hs_last_name=\$hs_last_name\, guest_name=\$guest_name\, street_address1=\$street_address1\, street_address2=\$street_address2\, city=\$city\, state=\$state\, zip=\$zip\, phone1=\$phone1\, phone2=\$phone2\, email_address=\$email_address\, number_attending=\$number_attending\, payment=\$payment\, registration_comments=\$registration_comments\, date_registered=\$today\ WHERE first_name=\$first_name\ AND last_name=\last_name\; $result = @mysql_query($sql,$connection) or die(Couldn't Execute Query.); } else { $sql = INSERT INTO $table (first_name, last_name, hs_last_name, guest_name, street_address1, street_address2, city, state, zip, phone1, phone2, email_address, number_attending, payment, registration_comments, date_registered) VALUES (\$first_name\, \$last_name\, \$hs_last_name\, \$guest_name\, \$street_address1\, \$street_address2\, \$city\, \$state\, \$zip\, \$phone1\, \$phone2\, \$email_address\, \$number_attending\, \$payment\, \$registration_comments\, \$today\) ; $result = @mysql_query($sql,$connection) or die(Couldn't Execute Query.); ===--- END SNIPPET ---=== -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Too stupid to UPDATE...
Don't have time to totally disect it, but you might change the if($num_rows) to if($num_rows 0) just to make sure. Also, try echoing out your SQL statement to check and make sure things like $table got a real value or other silly things. Lastly, I usually use single quotes for SQL statements.. in this case, it would simplify your PHP SQL statement by removing the necessity to escape all the double quotes \ If you echo the SQL and it looks ok, try running it manually through mysql's command line or via a program like WinSQL Lite on Windows to try to isolate if it's the query or your PHP. Good luck! -TG = = = Original message = = = I am trying to write a script to handle event registration. Most of the people that will be registering are already in the database, but not all, and those that are may not have current information. Here is my latest effort, or at least a snippet of it... Can anyone point out where I went stupid, or if there is a better way of doing this? THANKS!!! ===--- BEGIN SNIPPET ---=== $db = @mysql_select_db($dbname, $connection) or die(Couldn't Select Database.); $link = mysql_connect($server, $user, $pass); mysql_select_db($dbname, $link); $result = mysql_query(SELECT * FROM $table WHERE first_name='$first_name' AND hs_last_name='$hs_last_name' AND last_name='$last_name', $link); $num_rows = mysql_num_rows($result); if($num_rows) $sql = UPDATE $table SET first_name=\$first_name\, last_name=\$last_name\, hs_last_name=\$hs_last_name\, guest_name=\$guest_name\, street_address1=\$street_address1\, street_address2=\$street_address2\, city=\$city\, state=\$state\, zip=\$zip\, phone1=\$phone1\, phone2=\$phone2\, email_address=\$email_address\, number_attending=\$number_attending\, payment=\$payment\, registration_comments=\$registration_comments\, date_registered=\$today\ WHERE first_name=\$first_name\ AND last_name=\last_name\; $result = @mysql_query($sql,$connection) or die(Couldn't Execute Query.); else $sql = INSERT INTO $table (first_name, last_name, hs_last_name, guest_name, street_address1, street_address2, city, state, zip, phone1, phone2, email_address, number_attending, payment, registration_comments, date_registered) VALUES (\$first_name\, \$last_name\, \$hs_last_name\, \$guest_name\, \$street_address1\, \$street_address2\, \$city\, \$state\, \$zip\, \$phone1\, \$phone2\, \$email_address\, \$number_attending\, \$payment\, \$registration_comments\, \$today\) ; $result = @mysql_query($sql,$connection) or die(Couldn't Execute Query.); ===--- END SNIPPET ---=== ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Sending filing attachments using PHP
Does any one know how to send a file attachment using PHP? I have been using the mail() command to send e-mail in various scripts, but have spotted a file attachment syntax to use on the php web page. Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] auto_increment
How do I change the auto_increment / auto_index value? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] auto_increment
I am using mySQL On Mon, 2006-05-01 at 13:21 +, replies-lists- [EMAIL PROTECTED] wrote: Original Message Date: Monday, May 01, 2006 09:14:36 AM -0400 From: Ron Piggott (PHP) [EMAIL PROTECTED] Subject: [PHP-DB] auto_increment How do I change the auto_increment / auto_index value? Ron -- End Original Message -- that depends on the database you're using -- and probably best asked on the appropriate db-specific mailing list. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Web forms
I am creating some web based functions for the staff and volunteers to use. Access to these functions is designated by those who need it. I have two tables. One table describes the component --- It has a component reference number column. The second table indicates who has access to what --- containing the component reference number from the component table (described above) and also the member reference number. Essentially if you are logged in your reference number is in a session variable and using PHP mySQL the script is checking to see which components to allow you access to in your menu and only displaying those menu options. So far I have been updating this table using phpmyadmin. I have begun writing a script to do this in a more smooth fashion. The script I am writing produces a form in a table. Column 1 shows the component name. Column 2 is a check box for the user to check in if the person whose permissions are being modified should have access to this component. I have named the check box the component reference number --- 1 for example. There are about 16 components are growing. I am not sure how to check if $1 = on indicating the check box was checked in. I know you would use an IF ( ) { } statement --- but I want to automate this so when new components are added in I want have to modify the script which actually updates who has access to what component. What I have done so far is selected all the components and started a WHILE loop --- $i will go from 0 to 15 so I am able to look at each check box to see if it was selected or not and then I am going to use the INSERT INTO or DELETE commands to update the table, etc. How can I find out if $1 and $2 and $3 and ... $15 are on? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Search / Replace using PHP
Is there a command in PHP that is equal to the search replace function in a word processor? If I want to search for 'this' and replace it with 'that' what would the syntax be? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Ye old $_SESSION variables :)
I am wondering if form method=POST causes the session_id(); to change or be reset. Some how my $_SESSION[''] variables are dumping when I use the POST command above. More importantly I am not sure what to do about it. Any ideas? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Excel to CSV
The other response is half correct.. I havn't seen anything to read data from Excel with PHP (although it's technically possible, just kind of complicated) so the easiest solution is to use Excel and just have it load the file and save it in CSV format. The part that's not entirely correct is the PHP can't talk to Excel part. It's cumbersome, but PHP can use a COM connection to control Excel (or Word or MapPoint or Access or Outlook..etc). This means you'd have to have Excel loaded on the server that was running PHP, which may not be an option. For an example of PHP + COM with Excel, check out: http://www.php.net/manual/en/class.com.php Look down the page for the entry posted by flintjt at hotmail dot com If COM doesn't work for you and you don't mind getting your hands dirty, I believe you can get the Excel file format spec.. maybe through the OpenOffice sources.. and figure out how to read XLS files that way. The Excel Object Model might help you with the proper properties/methods/etc: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrgrfexcelworkbookobject.asp Good luck. -TG = = = Original message = = = Dear All, Have you any script/example how to Save As Excel file to CSV using PHP? Thanks Regards, Anita ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] unescape a string
Is there a way to unescape a string once the command mysql_real_escape_string($variable); has been used on it? (This is to display it to the screen, instead of sending it to the database.) Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Renaming a table once it has been created
Is there a way to re-name a table once you have created it? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Installing PEAR
I remember the quick install/test I did using PEAR and I kind of had a similar experience, but I figured out what the issue was for me. PEAR installed perfectly but doing the pear install thing where it pulls the package down and puts it where it needs to put it, I was doing what you were doing pear packagename and it wasn't working. What fixed it for me was adding the version number to the end of the name. Looks like PEAR DB is at 1.7.6, so try something like: pear install db1.7.6 But it also sounds like maybe you're not getting the pear install to work properly too. So maybe you need to fix something else before you get to this point. Just wanted to mention it to prevent a potential extra frustration for you. Back to work for me.. working late on a Friday sucks.. so forgive me if I'm not entirely helpful.. just wanted to pass that nugget along in case it was useful. -TG = = = Original message = = = I know this may be a bit off-topic, but I would like to use the PEAR library to implement some of my database functions. Unfortunately, the PEAR documentation is woefully incomplete and as a result i've been unable to install it properly. Here's the procedure i went through: PHP Version: 5.1.2 Apache Version: 2.0.55 MySQL Version: 5.0.18 Windows XP Pro 1. launch the go-pear batch file 2. select system-wide installation 3. use default install directories: (Seems fine to me since PHP is installed into C:\PHP) Installation Base ($prefix) C:\PHP Binaries DirectoryC:\PHP PHP code Directory ($php_dir) C:\PHP\pear Documentation Directory C:\PHP\pear\docs Data Directory C:\PHP\pear\data Tests DirectoryC:\PHP\pear\tests Name of Configuration FileC:\WINDOWS\pear.ini Path to CLI php.exe C:\PHP\. 4. The batch file tells me pear is installed 5. I add the environment variable via the PEAR_ENV.reg file 6. add the line require db.php and load to this message: Warning: require(DB.php) [function.require http://localhost/function.require ]: failed to open stream: No such file or directory in C:\wwwroot\phpinfo.php on line 2 Fatal error: require() [function.require http://localhost/function.require ]: Failed opening required 'DB.php' (include_path='.;C:\PHP\pear') in C:\wwwroot\phpinfo.php on line 2 7. Figure DB might not be installed by default, so follow the website's instructions by attempting to call it from the command line: pear install db = not recognized as internal or external command, bla bla bla c:\php\pear install db = see above c:\php\pear\pear install db = see above 8. get annoyed, go back to phpinfo file, remove erroneous line and look for references to PEAR, come up with the following (only) line: include_path~.;C:\PHP\pear~.; C:\PHP\pear 9. Go crazy, hit cute, fuzzy animals. I apolagize for the length of my e-mail, but I know that being thorough helps most of the time. Does anyone have any advice or ideas? ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate rows
Depends on how you determine if something's a duplicate or not. For example, if it's just one column that can be used, you can do something like this: select ItemName, count(ItemName) from ItemListTable group by ItemName having count(ItemName) 1 That'll show you if ItemName is repeated. Then you can go back through and just search for ItemName and remove the ones you don't want. You can do pretty much the same thing as above but CONCATenating multple columns if that's what you need to do to determine uniqueness. I know you're dealing with 15k rows still, so you probably want something a little more automated. Without more info though, it's hard to say exactly what can be done. Hope that helps a little bit. -TG = = = Original message = = = My dear beloved friends, I have a catalog of products that a product provider gave, sadly for me, in this CSV file there are many duplicated rows. I edited the file in my Linux system with the uniq -u command, and it worked somewhat fine, it eliminated some duplicated rows, originally the file had 24K rows, and now it has been reduced to 15k rows. Anyhow, there are still duplicated rows, and since this is a catalog, it should not have duplicated rows!!! Now the catalog has been has been loaded into the DB. How can I continue eliminating duplicated rows? As far as I remember the is a sentence in SQL to only show ONE row of duplicated rows, maybe if I do a select using this sentence and then put this new recordset in another table, it will work!! Any ideas? --- Miguel Guirao Aguilera Logistica R8 TELCEL Tel. (999) 960.7994 Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate rows
Haha.. oh yeah.. DISTINCT works too.. in this case you'd get a list of all totally 100% unique records. If you had an auto_increment column though, you'd want to exclude it from the list. -TG = = = Original message = = = SELECT DISTINCT * FROM `tablename` On Wednesday 01 March 2006 7:24 am, Miguel Guirao wrote: My dear beloved friends, I have a catalog of products that a product provider gave, sadly for me, in this CSV file there are many duplicated rows. I edited the file in my Linux system with the uniq -u command, and it worked somewhat fine, it eliminated some duplicated rows, originally the file had 24K rows, and now it has been reduced to 15k rows. Anyhow, there are still duplicated rows, and since this is a catalog, it should not have duplicated rows!!! Now the catalog has been has been loaded into the DB. How can I continue eliminating duplicated rows? As far as I remember the is a sentence in SQL to only show ONE row of duplicated rows, maybe if I do a select using this sentence and then put this new recordset in another table, it will work!! Any ideas? --- Miguel Guirao Aguilera Logistica R8 TELCEL Tel. (999) 960.7994 Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Writing to a file
I wonder if someone would tell me the command in PHP that allows me to write to a file --- for example test.txt Just for this example I would like the word apple to be the contents of test.txt Now if I want to re-create test.txt --- erasing all the contents and start over and this time have the word orange in it how would you do this? What commands do you use? Thanks for your help. Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Numbers to words
Is there a command within PHP that would convert numbers to words: echo 1; # 1 appears on screen echo command('1'); # one appears on screen --- what would the command be? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Numbers to words
I did some searching and found the function on the PHP web site. Ron ? /** * convert long integer into American English words. * e.g. -12345 - minus twelve thousand forty-five * Handles negative and positive integers * on range -Long.MAX_VALUE .. Long.MAX_VALUE; * It cannot handle Long.MIN_VALUE; */ function num2words( $num ){ $ZERO = zero; $MINUS = minus; $lowName = array( /* zero is shown as since it is never used in combined forms */ /* 0 .. 19 */ , one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen); $tys = array( /* 0, 10, 20, 30 ... 90 */ , , twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety); $groupName = array( /* We only need up to a quintillion, since a long is about 9 * 10 ^ 18 */ /* American: unit, hundred, thousand, million, billion, trillion, quadrillion, quintillion */ , hundred, thousand, million, billion, trillion, quadrillion, quintillion); $divisor = array( /* How many of this group is needed to form one of the succeeding group. */ /* American: unit, hundred, thousand, million, billion, trillion, quadrillion, quintillion */ 100, 10, 1000, 1000, 1000, 1000, 1000, 1000) ; $num = str_replace(,,,$num); $num = number_format($num,2,'.',''); $cents = substr($num,strlen($num)-2,strlen($num)-1); $num = (int)$num; $s = ; if ( $num == 0 ) $s = $ZERO; $negative = ($num 0 ); if ( $negative ) $num = -$num; // Work least significant digit to most, right to left. // until high order part is all 0s. for ( $i=0; $num0; $i++ ) { $remdr = (int)($num % $divisor[$i]); $num = $num / $divisor[$i]; // check for 1100 .. 1999, 2100..2999, ... 5200..5999 // but not 1000..1099, 2000..2099, ... // Special case written as fifty-nine hundred. // e.g. thousands digit is 1..5 and hundreds digit is 1..9 // Only when no further higher order. if ( $i == 1 /* doing hundreds */ 1 = $num $num = 5 ){ if ( $remdr 0 ){ $remdr += $num * 10; $num = 0; } // end if } // end if if ( $remdr == 0 ){ continue; } $t = ; if ( $remdr 20 ){ $t = $lowName[$remdr]; } else if ( $remdr 100 ){ $units = (int)$remdr % 10; $tens = (int)$remdr / 10; $t = $tys [$tens]; if ( $units != 0 ){ $t .= - . $lowName[$units]; } }else { $t = $inWords($remdr); } $s = $t . . $groupName[$i] .. $s; $num = (int)$num; } // end for $s = trim($s); if ( $negative ){ $s = $MINUS . . $s; } $s .= and $cents/100; return $s; } // end inWords ? On Thu, 2006-02-09 at 22:18 -0500, Ron Piggott (PHP) wrote: Is there a command within PHP that would convert numbers to words: echo 1; # 1 appears on screen echo command('1'); # one appears on screen --- what would the command be? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] screen resolution!
Or you can have a page which detects resolution by javascript and redirects to another PHP page with the resolution data On 2/4/06, Bastien Koert [EMAIL PROTECTED] wrote: As the other poster mentioned you need JS to detect the screen widththe usual approach is to use js to detect the screen res and the include the appropriate CSS file to match the screen res. Bastien From: JeRRy [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] screen resolution! Date: Sun, 5 Feb 2006 02:44:19 +1100 (EST) Hi, I have written a website in PHP using MYSQL. But I have come accross an un-common problem. Normally when I create a website it's done on a desktop PC. But this time for the first time I did it on laptop meaning the screen resolution is different. Is there any sort of script/code I can use to create another section of my site in a desired screen resolution without me having to do it all manually? I know of many scripts online that I can DETERMINE visitors screen resolutions and recommend the correct one but don't know one that will adjust the website to suit that visitors screen resolution. Am aware of scripts that redirect to another web page but that requires you to write the website again to cater for that. Is there a quicker way/solution? Thanks! J -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Hi Everyone, I am running PHP 5 on Windosws XP SP2 with MySQL5, Bye Now!
Re: [PHP-DB] Getting PHP 5 w/mysqli to communicate with MySQL 5
did you turn on display_errors and set error reporting to E_ALL in php.ini? if not you should On 1/20/06, Allen Schultz [EMAIL PROTECTED] wrote: Sorry, I was in a rush to work guys. All these were downloaded pre-compliled for Win32. Apache 2.0.55 PHP 5.1.1 w/php_mysqli.dll (improved mysql) MySQL 5.0.18 This script: htmlhead/headbody ?php $link = mysqli_connect('localhost','root','xx'); if (mysqli_connect_errno()) { echo error; exit(); } else { echo no error; } ? /body/html turns into this: htmlhead/headbody no error /body/html And this script: htmlhead/headbody ?php $link = mysqli_connect('localhost','root','xx'); if (mysqli_connect_errno()) { echo error; exit(); } if (!mysqli_select_db($link,pers)) { echo pers not found; } else { if ($result = mysqli_multi_query($link, select helloworld();)) { $row = mysqli_fetch_array($result, MYSQLI_NUM); echo $row[0]; } else { echo problem :(; } } ? /body/html turns to this: htmlhead/headbody /body/html In summary again, It seems to want to connect to the database, but doesnt see anything after connecting using mysqli functions. That helloworld() function in the database exists. I'm following this page for a tutorial to find out why I cant use the database: http://mysql.gilfster.com/page.php?parent_id=4page_id=4.0.2 On 1/19/06, Julien Bonastre [EMAIL PROTECTED] wrote: If you only compiled php with the mysqli libraries then you need to use them What exactly are you have troubles with? A code snippet or version examples would be good. Also is your database mysql5 engine I take it? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Hi Everyone, I am running PHP 5 on Windosws XP SP2 with MySQL5, Bye Now!
[PHP-DB] auto_increment and INSERT INTO
I have various tables where a column is set to auto_increment in my table structure. I have been using the following INSERT query format: INSERT INTO table VALUES ('$auto_increment_variable','$variable_1', '$variable_2') and then in applications where I have needed to know the value of the $auto_increment_variable I have immediately queried the table for $variable_1 and $variable_2 and used $reference = mysql_result($result,$i,reference); to determine what numeric value was assigned. Is there a way I may find out what value was assigned to the $auto_increment_variable when the INSERT INTO query is issued? Thanks. Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] auto_increment and INSERT INTO
That is the function I was looking for. Thanks. Ron On Sat, 2006-01-21 at 23:47 -0500, [EMAIL PROTECTED] wrote: Try: ?php mysql_query(INSERT INTO table VALUES ('$variable_1', '$variable_2');); $auto_increment_variable = mysql_insert_id(); ? -TG = = = Original message = = = I have various tables where a column is set to auto_increment in my table structure. I have been using the following INSERT query format: INSERT INTO table VALUES ('$auto_increment_variable','$variable_1', '$variable_2') and then in applications where I have needed to know the value of the $auto_increment_variable I have immediately queried the table for $variable_1 and $variable_2 and used $reference = mysql_result($result,$i,reference); to determine what numeric value was assigned. Is there a way I may find out what value was assigned to the $auto_increment_variable when the INSERT INTO query is issued? Thanks. Ron ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SELECT
Yesterday I asked how to get the date time 90 minutes ago and I received several responses. Thanks. I don't think this select statement is working correctly. (Correctly being what I am intending it to do) I took a look at the table this morning. One record remains that was created 2006-01-19 at 23:55:37. These are the values of date_created and time_created. The current values are approximately 2006-01-20 and 05:50:00 This is the select statement I am writing about: SELECT * FROM `table` WHERE `date_created` = '$date_90_minutes_ago' AND `time_created` = '$time_90_minutes_ago' Intellectually I know the problem: 05:50:00 is much earlier than 23:55:37 ... thus my AND is not allowing both conditions to exist together. Is there a way that I may modify this SELECT statement so the present conditions continue to exist and add a second part to the SELECT statement that if the time is 01:30:00 or higher that records from the previous day are selected? This continues to allow the 90 minute time frame for users logged into my web site ... I am not sure how you would add an OR function to the above without messing up what presently works :) (I am writing a SESSION function for my web site using mySQL and a cron. The select statement I quoted above is part of the cron.) Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Storing money values in MySQL
Thanks Balazs and David.. I think that's exactly what I was looking for. I searched for hours (and I consider myself a fairly decent researcher) and was just getting frustrated..hah.. I think my problem was I was searching for money and float problems and such and not monetary. I think that's the keyword that would have done it for me. I appreciate the help guys! Best of luck to both of you (and anyone else I inadvertantly missed who may have responded). -TG = = = Original message = = = Me again, Sorry for the rtfm stuff, I googled around and found this: http://bugs.mysql.com/bug.php?id=10719 and another thing, maybe worth a try; MySQL stores decimal numbers as strings...did you try to input decimals as string? I mean not: UPDATE SomeTable SET AmtOwed = 10.74 but: UPDATE SomeTable SET AmtOwed = '10.74' Bye, Balazs ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Length of variable
Is there a way I may find out how many characters $variable is long after it has been submitted through a web form? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Date Time 90 minutes ago
Would someone be able to help me with the DATE command syntax to know what the date and time was 90 minutes ago? I am trying to assign these values into two variables: $date_90_minutes_ago $time_90_minutes_ago I am not sure how to handle midnight where if the time is 00:10:00 ninety minutes earlier is a day before. Thanks. Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Date Time 90 minutes ago
Bastien's example is probably the quickest and easiest. I just wanted to point out that you can use math within the mktime() function as well in case the relative date/time you need isn't right now. $month = 1; $day = 19; $year = 2006; $hour = 17; $minute = 08; $second = 05; echo date(Y-m-d H:i:s, mktime($hour, $minute - 90, $second, $month, $day, $year)); It will even adjust for leap years I believe. You can add/subtract/etc any of those items and it's smart enough to figure out what the correct resulting date/time would be. -TG = = = Original message = = = ?php echo date(Y-m-d H:i:s,strtotime(90 minutes ago)); ? bastien From: Ron Piggott (PHP) [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: PHP DB php-db@lists.php.net Subject: [PHP-DB] Date Time 90 minutes ago Date: Thu, 19 Jan 2006 16:57:33 -0500 Would someone be able to help me with the DATE command syntax to know what the date and time was 90 minutes ago? I am trying to assign these values into two variables: $date_90_minutes_ago $time_90_minutes_ago I am not sure how to handle midnight where if the time is 00:10:00 ninety minutes earlier is a day before. Thanks. Ron -- 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 ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Storing money values in MySQL
Again.. your forgiveness. This is a MySQL question. If the MySQL mailing lists would include a [MySQL Help] tag in their subject lines, I'd use them. What I receive from them is difficult to distinguish from spam half the time so I gave up. We had a problem a few months ago and now I can't find my notes relating to it. The problem we had involved storing money data as either float or decimal and having the 'cents' round improperly. And it wasn't just a matter of 10.05 becoming 10.06, it was something along the lines of 10.05 becoming 10.12. This was when just a straight UPDATE was performed. I remember doing it manually, not even through PHP, using absolutely no math functions, just a totally straight: UPDATE SomeTable SET AmtOwed = 10.74 Someone made a recommendation of never use SOMETYPE for money.. you should use SOMEOTHERTYPE instead. I've spent the better part of the afternoon trying to find my notes, recreate the bug in our database, search online for the discussion I had then or other information about this. So far I'm coming up empty. We're retooling some of our database and trying to make it more efficient and accurate and this is on the list of things to doublecheck. If anyone has any comments, criticisms, information, etc... I'd love to hear them. We're running MySQL 4.1.11-standard. Thanks! -TG ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Refreshing text question!
Two ways I can think of to update part of a page without doing a full refresh: 1. Use an IFRAME so you're technically updating a page, but it's the page within the frame (not my favorite but works ok) 2. Or you can use asynchronous javascript (AJAX) to update just that one section of the page without doing a refresh. Here's Rasmus' great primer on AJAX, should be easy enough to follow: http://www.time.gov/timezone.cgi?Eastern/d/-5/java One note I'd like to make that doesn't seem to be mentioned in a lot of AJAX tutorials. If the page your AJAX is calling doesn't have the standard do not cache tags, you sometimes won't get the results you want.. especially with Internet Explorer (in my experience). Here's a block I copy/pasted from somewhere that seems to work fine (covers most of the bases and all): header(Expires: Mon, 26 Jul 1997 05:00:00 GMT); // Date in the past header(Last-Modified: . gmdate(D, d M Y H:i:s) . GMT); // always modified header(Cache-Control: no-store, no-cache, must-revalidate); // HTTP/1.1 header(Cache-Control: post-check=0, pre-check=0, false); // HTTP/1.1 header(Pragma: no-cache); // HTTP/1.0 good luck! -TG = = = Original message = = = Hi, No, no that is not what i am after, I know how to do that but it's not what I want. I wrote some code a year or so ago with words, they refreshed every 5 or so seconds WITHOUT REFRESHING THE PAGE. It was written in JavaScript as i can remember. But I can't find where I did it. I want to have the code or a similar one without the need to re-write it. The code does not require the page refreshing at all, just loops in a script and outputs. I might have to do some web surfing on it, pity I can't remeber where it is. If anyone could help that would be great. It's for a PHP site using MySQL. I am considering having the slogans in a database this time rather than just a text file. J Julien Bonastre [EMAIL PROTECTED] wrote: Yes I can help you there.. There is a technique you can use which is actually more browser friendly then the Javascript alternative you mentioned.. You can use the META tags in your page as such: will refresh page in 10 seconds CONTENT=10;url=http://www.operation-scifi.com; will reload page in 10 seconds and direct browser to one of my first highschool webpages.. For a quick reference I found this via the I'm Feeling Lucky of Google: http://webdesign.about.com/cs/metatags/a/aa080300a.htm Otherwise the good ole' W3C at www.w3c.org will have some great doco's on it too enjoy ;-) ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] FTPing within PHP
I am wondering if I may delete a file by FTPing within PHP. I found the followed on the PHP web site: fopen(ftp://user:[EMAIL PROTECTED]/somefile.txt, w); Is there a way for me to delete somefile.txt ? The FTP program on my computer gives the command DELE /path/somefile.txt Is there a way for me to send this command through? I also need to know the command to disconnect --- and wonder if someone could tell me it. Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL date casting..
Unfortunately, no. The dates and times are stored as text. So here's what I get: 2006-01-10 07:00 PM 2006-01-10 08:00 PM 2006-01-10 09:00 AM 2006-01-10 09:00 PM (notice the AM out of order) For anyone interested, here's the big ugly version.. if anyone knows of a function that I can use instead of all this garbage, let me know: select ApptDate, ApptTime, CONCAT(ApptDate, ' ', IF(SUBSTRING(ApptTime, 7, 2) = 'PM', CONCAT(SUBSTRING(ApptTime, 1, 2) + 12, ':', SUBSTRING(ApptTime, 4, 2), ':00'), IF(SUBSTRING(ApptTime, 7, 2) = 'AM', CONCAT(SUBSTRING(ApptTime, 1, 2), ':', SUBSTRING(ApptTime, 4, 2), ':00'), '00:00:00'))) AS ProperDateTime from SomeTable I'm not worried about blank or -00-00 type dates in this case so don't really account for them. And again, this is meant to work on separate date and time fields in the following formats: ApptDate: -MM-DD (we at least did that part 'normal') ApptTime: HH:MM [AM|PM] Thanks for the response though Stephen... always worth going over the simple stuff first. :) -TG = = = Original message = = = Could you not just add: ORDER BY ApptDate, ApptTime To the end of your SQL - this will order the set by date then time. You can also add ASC or DESC for Ascending or Dscending as desired. N.B. the ORDER BY statement must be the last part of you query! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 17 January 2006 16:42 To: php-db@lists.php.net Subject: [PHP-DB] MySQL date casting.. Forgive me that this isn't really PHP related, but solely MySQL.. but the MySQL mailing lists drive me nuts and figured someone here would have a quick answer. I'm trying to sort by a date and time field(s) (two separate fields). It's a dumb system but until we do the next revision, it's going to stay the way it is (boss' orders) so bear with me. Example: ApptDate~ApptTime 2005-11-02~01:00 PM 2005-10-27~07:00 PM 2005-06-25~10:30 AM -00-00~N/A -00-00~N/A -00-00~N/A -00-00~06:30 PM See? Dumb.. hah.. So I thought I could do something like this: select ApptDate, ApptTime, DATE_FORMAT(CONCAT(ApptDate, ' ', ApptTime), '%Y-%m-%d %H:%i:%s') from Table But it doesn't like 06:00 PM.. returns null on the items that have a valid date and time because the time format isn't what it wants. If I try it with a 06:00:00 PM time, it makes it 6am. Using STR_TO_DATE() does exactly the same thing. You'd think STR_TO_DATE() would behave more like PHP's strtotime() but apparently not. I can code a big complicated conditional SQL statement, but I'm hoping there's a way to convert at least the valid date/time pairs into a happily ORDER BY'd column. I can handle the -00-00 and N/A entries with exceptions if I need to. And I would really like to do this without pre-loading the data into PHP and sorting it with PHP's sort functions. Any MySQL gurus who can show me what I'm missing here? Thanks in advance! -TG ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL date casting..
Ahh! Thank you Philip! That's what I was looking for! I see what I did wrong now. I was using the date format strings wrong. I was using it like I'd use it for DATE_FORMAT() instead of as an input filter. This is what I was trying to do: select STR_TO_DATE('2003-11-05 06:00 PM', '%Y-%m-%d %H:%i:%s') duh... hah. Thanks! I knew it was something simple. -TG -- What's wrong with [using] this? mysql select str_to_date('2005-10-27 07:00 PM', '%Y-%m-%d %l:%i %p'); +-+ | str_to_date('2005-10-27 07:00 PM', '%Y-%m-%d %l:%i %p') | +-+ | 2005-10-27 19:00:00 | +-+ 1 row in set (0.04 sec) ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Formatting a form box
What? Nobody said This has nothing to do with PHP and databases? Sheesh... someone must be sleeping. :) Ok, so it sorta does relate.. But yeah... no2br() will do it for you. Textarea input types DO send a newline and/or carriage return (didn't test and might be system specific), so if you just take your form $_POST data and use nl2br() before you store it in the database (or probably after... should be able to store a newline/carriage return in the database) it should produce the results you desire. test.php: form action=test.php method=post textarea name=testarea /textarea input type=submit /form ?php if (isset($_POST['testarea'])) { echo nl2br($_POST['testarea']); } ? Look at the source code after you submit if you have any doubts/questions. -TG = = = Original message = = = use the nl2br() function to convert the newlines to br bastien From: Alex Major [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Formatting a form box Date: Thu, 12 Jan 2006 16:33:01 + Hi there, On one of my forms, there is a section where users can put images etc..and then it is displayed on my php pages. My question is how do I make it so that the html formatting is automatically done. For example when someone is typing something, and wants to start a new paragraph although they press return when typing when the data is displayed from the MySQL database on a website it's just continuous text. For it to start a new paragraph they have to put p in when they are typing in this box. They do not know all the html formatting codes, and so I need someway of making so that it is easy for them to have formatted text without doing all the html. Also things like changing colours, bold, italic and things would be good. Something like on forums, where when you enter a new post you have all the formatting options. Hope this makes sense, Regards, Alex. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Scrolling News
Hi, just to tell you scrolling text boxes are javascript, PHP is server side not client side, PHP can only get the data from the table and javascript will display it On 12/22/05, Alex Major [EMAIL PROTECTED] wrote: Hi there. I'm trying to make a scrolling news box for my website. Basically I would like this news box to get information from a column in my database called 'news_title' and display it in a scrolling news box. The reason I'd like it to do this is because there is already a news page on my website, which stores 'news_date' , 'news_poster' , 'news_title' , 'news_description' , 'news_content' in a table on my database. I'd just like to increase the functionality of this by having this news box on my front page, which scrolls the 'news_title'. Any suggestions for how to go about doing this? I'm still very new to php. Regards, Alex. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Hi Everyone, I am running PHP 5 on Windosws XP SP2 with MySQL5, Bye Now!
[PHP-DB] CLOSE button or a href link
I am building a Christian ministry web site. One of the things we are establishing is an online offering basket to receive donations. One of our disbursements is a benevolent fund to help others. I have a 'how we operate our benevolent fund' web page online at http://www.actsministrieschristianevangelism.org/financial/how_we_operate_our_benevolent_fund.html I also have this file set to load from our online offering basket web page at http://www.actsministrieschristianevangelism.org/financial/online_offering_basket.html as a pop up window by clicking a submit button. What I really want to have happen is for the CLOSE WINDOW button to appear when this is loaded as a pop up window from our online_offering_basket.html file and if the web page is loaded directly then the link to our Online Offering Basket appear for the user to get back into our web site. Do you know how to do this? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date Formatting Question
You got the right idea, but you're making it more complicated than it needs to be. your $sDate after using explode() is going to contain an array. strtotime doesn't take an array, it takes a string. $monthName = date(F, strtotime($row_events['Sdate'])); $monthNumber = date(m, strtotime($row_events['Sdate'])); // or n if you want 1 instead of 01 for January echo select name='sMonth'\n; for ($i = 1; $i = 12; $i++) // using date() below to get month name, day and year irrelevant $selectMonthText = date(F, mktime(0, 0, 0, $i, 1, 2000)); if ($i == $monthNumber) $selected = SELECTED; else $selected = ; echo option value='$i'$selected$selectMonthText/option\n; echo /select\n; -TG = = = Original message = = = I am trying to format the month portion of a date that I am trying to pull from MySQL to be placed into a drop down menu to modify the date. I have tried several ways and none seem to be working. I am pulling the date out of MySQL with: $sDate = explode(-, $row_events['Sdate']); And then attempting to insert each portion of the array into a drop down menu with: echo select name=Smonth; echo option selected$sDate[1]/option; which is where I am running into the problem. I pull out the month as 2 digit numeric 01, 02, 03 etc., but I want it displayed as January, February, March, etc., I have tried the following with no success: Date(F,strtotime($sDate)); Strftime(%B:,$sDate); Date(F,$sDate); I would use MySQL to format the date, but I have three date fields to modify and it would be easier to do it in PHP Any pointers would be appreciated. Mark Bomgardner Technology Specialist KLETC ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Minor Change
This isn't really a MySQL error (sorta), it's a PHP error. You probably forgot to update a variable name when you updated everything else. Here's an example sequence for querying using PHP/MySQL: $TestQY = SELECT * from SomeTable; $TestRS = mysql_query($TestQY) or die(Error executing query); while ($TestRW = mysql_fetch_assoc($TestRS)) { $somearr[] = $TestRW; // do something with data } Since you're getting a Not a valid MySQL result resouce error with the mysql_fetch_assoc() function, I'd search for all your mysql_fetch_assoc() statements and double check their $TestRS. That error is saying that your $TestRS isn't a valid MySQL result set. That could mean that $TestRS isn't defined (maybe you're still using $TestOldRS and forgot to change a variable name) or possibly that $TestQY is empty or bad somehow so mysql_query() isn't generating a proper MySQL result set (try echoing out your $TestQY to see what it is.. then try executing it manually on the MySQL server and see if you get an error). You can try the or die() syntax I use above to see if mysql_query() is bombing out so you'll get notice before it even gets to the mysql_fetch_assoc(). Lastly.. someone recommended echoing out mysql_error(). Your response makes it sound like you think that this fixes your problem. It's not going to fix anything, just possibly give you some information about what failed. If you get a MySQL error message from mysql_error(), please post it. It might help us determine what the problem is. It may not contain anything (under certain failing circumstances) so I'd step through the things I've listed above. They may shed some light on where the error is and then we can figure out how to fix it. Probably a typo in a query, variable name or table name I'm guessing. Let us know if you find anything else out. -TG = = = Original message = = = After adding echo mysql_error(); I get the same result. I tried changing the query to include 109fh7 (a table which doesn't exist) and got the same result as with 109fh6. Changing to 109fh5 does pull up that table. The line to which the error message refers is while ($row = mysql_fetch_assoc ($data_set)) That is what always come up when there is an error in the query. ** On Mon, 12 Dec 2005 14:13:10 -0500, Micah Stevens [EMAIL PROTECTED] wrote: You're getting an error, after the query, put: echo mysql_error(); to find out what's happening. On Monday 12 December 2005 11:05 am, [EMAIL PROTECTED] wrote: I made tiny changes to my php file and sql table and the table won't come up. I updated the table name (and php file name) from 109fh5 to 109fh6. In the table, I changed 6 cells, leaving a couple blank. Then I changed only the digit 5 to make it a 6 (109fh6) in the following: $get_data_query = select rep, party, state, cd, minority, afr_am, asian, am_indian, hispanic, med_hsehold_income, poverty from 109fh6 order by $sort_field $sort_order; Now I get Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in etc. I've done this many times without a problem (this is the 6th time in this sequence). What could be wrong after such a minor change? Ken ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Need a Help!
Couple of things you can do: 1. Drop the song ID and only get the artist information SELECT distinct(Artist) from songtable. It doesn't look like your SELECT statement needs a song, but you include the song ID as $id anyway. Any reason for that or can you drop it so you only get artist? 2. Pre-parse the results of your current query so you only get one artist and/or compile a list of song ID's while you're at it. Instead of doing your option in the database query result WHILE statement, do it outside: while (results) { $artistinfo[$artist][] = $id; } Then: echo select name='blah'; foreach ($artistinfo as $artist = $songsarr) { echo optgroup label='$artist'; foreach ($songsarr as $songid) { echo option value='$id'$id or whatever/option; } echo /optgroup; } echo /select; 3. Use a different DB structure. I prefer this structure myself: Table ARTISTS: ArtistID ArtistName OtherArtistInfo Table SONGS: SongID ArtistID OtherSongInfo Or, instead of having ArtistID, if more than one artist may be linked to a song, you can do: Table xrefArtistsSongs: ArtistID SongID Not sure why you'd want to do that for a song unless you're counting covers of songs and want all artists who've covered it to point to the same SongID data. This way you can: SELECT * from ARTISTS for your ARTISTS select box Then once an artist is selected, do a: SELECT * from SONGS where ARTISTID = $artistid Just some ideas. Forgive the pseudo-code and mixed capitalizations.. I think you get the idea I'm trying to convey. -TG = = = Original message = = = I have table and insert data using song_id, that means one artist can have many song_ids. my question is how can I query distinct artist with his/her song_id while I will not get duplicate data like duplicate artist? my code is like this $content .=form id=\form1\ method=\post\ action=\\ select name=\Quick\ onchange=\MM_jumpMenu('parent',this,0)\ option value=\#\Select Artist/option; $result= $db-sql_query(SELECT distinct(artist), id FROM .$prefix._lyrics order by artist asc); if ($db-sql_numrows($result)) while($row = $db-sql_fetchrow($result)) extract($row); $content .=option value='modules.php ?name=$module_nameamp;file=artistamp;c_id=$id'$artist/option; $content .=/select /form; that code is fine except it gives me duplicate artist, so I want get rid off that duplicate. any help ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Garbage collection (my session files)
I have specified a directory for the session files to be stored in. But by doing so the garbage collection function isn't automatically deleting them. Is there a way I can do so --- Either with a cron or something like this? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SELECT
I am trying to put together a SELECT syntax. I am querying a response database and I only want to obtain each user's name once even if they have given more than 1 response. $query=SELECT * FROM conversation_table WHERE conversation_reference = $conversation_currently_displayed; $response_created_by = mysql_result($result,$i,response_created_by); My ideal is that if users 1, 2, 4 5 are in dialogue with each other the above SELECT $query will only give the results of their identity once with the mysql_request() function Thanks for your help. Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Ending session
How do you actually end $_session variables so the session actually ends? I found the session_write_close() command. I am not sure if this is the correct command or not. One prime example I am using is a $_session variable to track which user account is active. I want to have a log off button which closes the session off. Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php