Re: [PHP-DB] Date problem
At 12:26 PM 1/21/2007, Denis L. Menezes wrote: Dear friends. I have a date field in mysql called event_end . I want to run a query to find all records where the event_and is greater than today's date. I have written the following code. It does not work. Please point out the mistake. $today = getdate(); $sql=select * from events where event_end'.$today.' order by event_start Asc ; Thanks denis How is your date formatted in the database. Compare that to the format returned by getdate(), then consider using date('Y-m-d'). That's assuming your MySQL date is stored as -mm-dd. Nonetheless, this should set you on the right road. It would also have helped your diagnosis if you echoed your SQL statement. Cheers - Miles Thompson -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.410 / Virus Database: 268.17.3/642 - Release Date: 1/20/2007 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Login script help
When user has authenticated successfully, start a session with an authentication key - almost anything you want. After that, any page you want to protect you just put one line at the top to check for the presence of this value; redirect to login page if it's not there. Regards - Miles At 11:19 PM 12/21/2006, Haig Dedeyan wrote: Thanks. If I do it that way, can't someone get into the index page if they link directly to it without having to log in? -Original Message- From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: Thursday, December 21, 2006 7:36 PM To: Haig Dedeyan; php-db@lists.php.net Subject: RE: [PHP-DB] Login script help why not just create a simple single logon page and not include itthen on sucessful login, redirect the user to the index page? bastien From: Haig Dedeyan [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Login script help Date: Thu, 21 Dec 2006 16:36:11 -0500 Hi everyone, My 1st attempt at creating a login script isn't going so good, so hopefully someone can help me out. The login script itself works fine but when I include it into a web page, the login.php script shows up but the entire index.html page also shows up. I just want people to log in before they get to index.html. Index.html starts off with: ?php session_start(); include(database.php); include(login.php); ? I'm using php5. Thanks Haig -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Off to school, going on a trip, or moving? Windows Live (MSN) Messenger lets you stay in touch with friends and family wherever you go. Click here to find out how to sign up! http://www.telusmobility.com/msnxbox/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.26/594 - Release Date: 12/20/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Can't Connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
At 05:15 PM 10/24/2006, ROGER DEBRY wrote: I know that this is a common problem, and I have honestly searched though many forums, faqs, and mailing list archives for an answer. I get this message when trying to connect to a local MySQL database with the statement $db = mysql_connect('localhost', 'myUserID', 'myPassword') or die(Could not connect to mysql); I know that the MySQL server is running, I can connect to it on the command line with the MySQL client, using the same user name and password as in the mysql_connect statement. I know that the socket is there where it is supposed to be, and that everyone has read and execute privileges to it. localhost is defined correctly in my hosts file. I have tried this with both the defaults for the socket 's path in php.in, and by explicitly typing in the path to the socket. The statement fails with the same error message no matter which I do. I have tried everything that I have found to look at on the many forums, etc. that I have looked at. I am at a loss as what to do next. Any suggestions would be helpful. Thank you Roger deBry Well, we don't really have any useful information. A couple of things: 1. Echo the error number and error message which PHP returns. Your die() message masks the error. 2. Use phpinfo() to check that MySQL is enabled in PHP. 3. Check the synatx/parameters for mysql_connect() at http://www.php.ca/mysql_connect 4. You could force a TVP/IP connection by replacing lacalhost with 127.0.0.1 HTH - Miles -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.408 / Virus Database: 268.13.11/493 - Release Date: 10/23/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Displaying a PDF file
At 09:33 AM 9/14/2006, Ron Piggott (PHP) wrote: 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 So Ron, why not just ... a href=http:scripture/psalm91.pdf target=_blank as the action triggered on the button. (Unless you're storing the .pdf in the database.) Miles -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.3/447 - Release Date: 9/13/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Can you recommend Australian LAMP web hosting service?
At 04:42 AM 8/10/2006, Jeffrey wrote: Sorry, this is a bit off topic, but you are the best people to ask. I am looking for a web hosting service based in Australia (and with servers in Australia). Need Linux+Apache+MySQL+PHP and dedicated server hosting. Importantly, they must provide a very high level of security (especially security), reliability and customer service as sensitive corporate data would be saved on the application(s) hosted by them. Feel free to e-mail me off-list. Many thanks, Jeffrey Jeffrey, This is the web - the words web hosting service and sensitive corporate data do not belong in the same paragraph. I know you had security in there, but security is not the first concern of most hosting services. The first place this can break down is the server - you are usually one of scores of virtual hosts. A misconfiguration, and your files are are exposed. The second place is the database - usually one database engine hosts scores, if not hundreds of databases. If the database is not correctly configured, your data is exposed. If there is a real concern about security, your client should establish its own server and database, and engage appropriate security consultants to ensure that it is secure, and to do periodic audits checks to make certain it stays that way. Next step, would be a dedicated server at a company like Rackspace - I know they're not Australian, but it was the name that popped up in my mind. After that, a virtual machine within the computer, as hub.org, among others, provides. Shared hosting - not if security is important. Anything on the web is much more exposed than it is on a WAN or LAN. So, it doesn't matter much right now who you pick, work up some budget figures, go to your client, and find out just how important security is to them. Unfortunately it's frequently seen as more important after the breach, rather than before. Sorry for rabbiting on, and if this is all basic stuff which you have already discussed with your client, well maybe some reinforcement will help. Regards - Miles -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.10.8/413 - Release Date: 8/8/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Parse Problem
At 06:03 AM 5/9/2006, Andy Rolls-Drew wrote: All, I am fairly new to parsing XML using PHP and wonder if anyone has a solution to the following. I have a file eg:- ?xml version=1.0 ? STOREITEMS CREATED value=Wed Mar 15 8:07:27 GMT 2006 CATEGORY id='67' name='Herbal Pharmacy' PRODUCT ITEM='603' NAME/NAME MODEL/MODEL PRICE/PRICE PRODUCT ITEM='608' NAME/NAME MODEL/MODEL PRICE/PRICE CATEGORY id='69' name='Extras' PRODUCT ITEM='1123' NAME/NAME MODEL/MODEL PRICE/PRICE PRODUCT ITEM='2034' NAME/NAME MODEL/MODEL PRICE/PRICE And so on. I have managed to parse a little of it using Magic Parser but I still cant manage to split the products and categories correctly. If there weren't multiple products for each category I think I would have it. Any help would be a start. Thanks in advance Andy I don't know much about XML, but CATEGORY is not closed in you example, neither is PRODUCT ITEM ... are you sure the XML is well-formed? And now we don't want a sig like yours. Could you please shorten it? Regards - Miles Thompson -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.392 / Virus Database: 268.5.5/334 - Release Date: 5/8/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] optimizing indexes -mysql
At 08:44 AM 5/4/2006, blackwater dev wrote: I just doubled the size of my MySQL db, is there a command I should run to re-index everything or is that automatic? Thanks! Well, it is automatic and MySQL does not need a lot of attention. Having said that, what table type(s) are you using, and what version of MySQL? And in the process of doubling were there a lot of deletions? If you have a lot of DELETEs in a MyISAM table, for instance, that space is maintained as a linked list until it can be re-used. Running OPTIMIZE TABLE against that will reclaim the space. This is really a question that should be asked on a list dedicated to MySQL. Regards - Miles Thompson -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.392 / Virus Database: 268.5.3/331 - Release Date: 5/3/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Using OR in a SELECT statement
At 02:40 AM 3/28/2006, Arno Kuhl wrote: Newbie MySQL question... I have a situation where if I don't have a custom value then I must use the default value. There will always be a default value but there may also be a custom value. I could do this with: select value where id and custom condition if (EOF) { select value where id and default condition if (EOF) { // no value found for this id - error, return false } } // return value If I change this to: select value where id and (custom condition or default condition) ... will I always get the custom value if there is one, or do I have to have 2 selects to be sure that I always get the custom value if there is one? IE does MySQL consistently read and process the OR statement from left to right or does it change depending on what's most optimal? Cheers Arno This is really a MySQL question, but check section 12 of the MySQL manual. Here's the link for operator precedence http://dev.mysql.com/doc/refman/4.1/en/operator-precedence.html I'd run some simple tests, just on the OR to see how it behaves. I usually have to make at least two passes on logical conditions to get them right. Where is your EOF() coming from? If you are cascading the statements, use mysql_num_rows() or just test for the value returned from mysql_query(). Hope this has been helpful - Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.385 / Virus Database: 268.3.2/294 - Release Date: 3/27/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Remove newlines from field
tops snipped At 04:00 PM 3/20/2006, you wrote: I am using a PHP script to pull information from a FoxPro database via ODBC. One of the fields is a memo field (large text) that contains newline characters. Displaying this info to the web page is fine as the newlines are ignored. The challenge is when I combine user entered text with the existing info and try to update the database. It fails with an unrecognized command because the end of field delimiter is on a different line. We're running on PHP 4.2.7 and I have tried using various combinations of str_replace to eliminate the newline characters, but I have been unsuccessful. Any suggestions? Giff Giff Hammar IT Director Certified Parts Warehouse http://www.certifiedparts.com http://www.certifiedparts.com/ http://www.certifiedparts.com/ http://www.certifiedparts.com/ mailto: [EMAIL PROTECTED] V: 603.516.1707 F: 603.516.1702 M: 603.490.7163 Giff, Are you inserting back into the FoxPro table? I had to use the following to clean up text, cut and pasted from WPfor Windows 5.2, into a textarea. Immediately before the INSERT I also used PHP's addslashes(). The database is MySQL. // have to clean up the extraneous CR/LF combos $trupara= .\r\n; // period+CR+LF $dblquotpara= ''.\r\n; // double quote+CR+LF $sglquotpara= '.\r\n; // single quote+CR+LF $questnpara = ?\r\n; // question+CR+LF $exclampara = !\r\n; // exclamation+CR+LF $colonpara = :\r\n; // exclamation+CR+LF $dudspc = . \r\n; // period+spc+CR+LF $flspara= \r\n; //CR+LF $truflag= ***; //something unique $txtBody = str_replace ( $trupara, $truflag, $txtBody); $txtBody = str_replace ( $dblquotpara, $$$, $txtBody); $txtBody = str_replace ( $sglquotpara, %%%, $txtBody); $txtBody = str_replace ( $questnpara, +++, $txtBody); $txtBody = str_replace ( $exclampara, !!!, $txtBody); $txtBody = str_replace ( $colonpara, :::, $txtBody); $txtBody = str_replace ( $dudspc, ###, $txtBody); $txtBody = str_replace ( $flspara, , $txtBody); $txtBody = str_replace ( $truflag, .\n\n, $txtBody); ///double quote $txtBody = str_replace ( $$$, '\n', $txtBody); ///single quote $txtBody = str_replace ( %%%, '\n, $txtBody); ///question mark $txtBody = str_replace ( +++, '?\n', $txtBody); ///exclamation mark $txtBody = str_replace ( !!!, '!\n', $txtBody); ///colon $txtBody = str_replace ( :::, ':\n', $txtBody); ///dudspace $txtBody = str_replace ( ###, '.\n\n', $txtBody); $txtBody = str_replace ( \n , \n, $txtBody); Hope this is helpful - Miles PS Policy on this list is to bottom post. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.385 / Virus Database: 268.2.5/284 - Release Date: 3/17/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Remove newlines from field
At 07:17 PM 3/20/2006, Miles Thompson wrote: tops snipped Forgot to add that the writers work in WP 5.2 for Windows, because it has an excellent indexing function which enables them to locate back stories v. quickly. That text is cut and pasted into an HTML textarea, which is saved to a MySQL database. nl2br() is also applied to the text before saving. The idea is to get straight HTML into the database. For display the text is fetched, stripslash()'d and fed as an XML stream to an HTMLText control in a Flash movie. Quirks in how the movie displayed the text, resulted in some of the constructs that had to be detected and removed. Same thing, occasionally, in the textarea. So this may not be the ideal solution, but it works for us. Cheers - Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.385 / Virus Database: 268.2.5/284 - Release Date: 3/17/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] WAMP
No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 268.2.1/279 - Release Date: 3/10/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re:
At 11:43 PM 3/10/2006, Ron Piggott (PHP) wrote: X-Spam-Scan: YES X-Spam-Flag: NO X-Spam-Level: / X-Spam-Score: 0.0 (0) X-Spam-Report: score=0.0 stars= tests=UNPARSEABLE_RELAY=0.001 X-Virus-Scan: YES X-Headers-End: 1FHupX-MO-JB X-Delivered-To: [EMAIL PROTECTED] Subject: [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 Just stash it in another var before running the function. $var_b4_esx = $variable; mysql_real_escape_string( $variable ); Curious about why you are doing this for screen display. Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 268.2.1/279 - Release Date: 3/10/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Help needed creating a social network
My first thought was recursion - repeat the call for each element of the result set, numbering each so you can find each level, until nothing is returned. That would probably work, but oh, what a mess. That triggered something ... off to consult Joe Celko's SQL for Smarties. He has a whole chapter on Trees, and guess what: they're not easily done in relational databases. To try and condense it here would be, shall we say, impractical. Check with a library, or try googling for trees -- hey, look what turned up: http://www.dbmsmag.com/9603d06.html by JC himself. Have fun - Miles Thompson At 03:19 PM 3/7/2006, Daevid Vincent wrote: Thanks for the reply. However, that only gives me a single degree. I'm looking for the way to traverse a 'tree' to see who is in your extended networks, so I can do things like: You are 4 degrees away from Sam: You know bob who knows john who knows carrol who knows Sam. Sam - carrol - john - bob - you Etc. -Original Message- From: Micah Stevens [mailto:[EMAIL PROTECTED] Sent: Monday, March 06, 2006 10:28 PM To: php-db@lists.php.net Subject: Re: [PHP-DB] Help needed creating a social network CREATE TABLE `users` (userID int(11) not null auto_increment, primary key(userID), name tinytext not null, email tinytext not null); CREATE TABLE `links` (userID int(11), key (userID), friendID int(11), key(friendID)); ?php $friends = mysql_query(select users.name, users.userID from users left join links on links.friendID = users.userID where links.userID = {$_GET['userID']}); echo h1You have friends!!/h1; while ($f = mysql_fetch_assoc($friends)) { echo a href='socialnetwork.php?userID={$f['userID']}'{$f['name']}/a br\n; } publish(); profit($greatly); do (!$use) { coldfusion('Cause it sucks'); } ? (har har) On Monday 06 March 2006 9:47 pm, Daevid Vincent wrote: Anyone have some pointers at a HowTo on creating a social network? Basically I need to show people in your immediate network, and also friends of your friends, etc... Like the whole 'six degrees of separation' thing. Ala: myspace, friendster, etc. ad nauseum. I prefer mySQL and PHP, but I could port from most any code. I guess I'm mostly interested in the theory of this an how do I set up the tables properly and what is the magic incantation (JOIN) to get this chain of people. -- 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 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 268.2.0/275 - Release Date: 3/6/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Data split: web local machine
I have to generate a comma-separated(CSV) file of amounts and credit card numbers for secure transmittal to the bank. The CSV file is read by a bank-endorsed program, encrypted and transmitted. Most of the billing information: amount, period date, name, billing number is stored on the web server. The billing number and credit card type and credit card number are stored locally, call it the cc_file. The local storage format has not been decided on, the client is leaning towards Excel, but is well aware of how easily data can be damaged or destroyed in a spreadsheet. The procedure I initially thought of, was generating a file on the web side, emailing it to the client, then merging it with the cc_file to generate the payment file for the bank. I foresee a very messy, and fragile, macro in Excel to generate the merge. Now I'm thinking more along the lines of having a local MySQL database. The web side file will be created using SELECT fields INTO OUTFILE filename, and that would be mailed to the client. That file would be imported into the local MySQL database. A script / function would then generate the payment file. This local app I would write in PHP, using the PHP-GTK toolkit. The other possibility would be to access the web database from the local app, fetch the data directly and generate the file. That would involve having two databases open at the same time, but should be ok - $db_local and $db_remote. Opinions and suggestions will be welcomed. Regards - Miles Thompson -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 267.15.11/264 - Release Date: 2/17/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] generating random id's
At 03:26 AM 2/9/2006, JeRRy wrote: Just to let you all know I used PHP's unique ID generator to generate a unique id for tracking purposes. I than md5 it hide the format a bit, would this be enough? Or can be easily worked out also? Need it pretty tight and keeping the likelyhood down of having multiple listings of id's. It's using 32 chars. Jerry Yes, I've done something similar. Used the random number generator and chr()'d anything that's printable ascii, looping until I have the desired length, then md5'd it. It works and generates a peculiar value. Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 267.15.3/254 - Release Date: 2/8/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Performance question
Don't cross post!! MT At 11:46 AM 2/1/2006, Mathieu Dumoulin wrote: This is more a How would you do it than a How can i do it question. Didn't have time to try it, but i want to know how mysql_seek_row acts with large result sets. For example im thinking of building a node tree application that can have dual direction links to nodes attached to different places. I was wondering if i could actually have two result sets that query everything sorted by ID (Links and Nodes) then just seek the rows i need instead of dumping everything in php memory. When i mean large i mean really large, more than the standard possible 2 mbs of data allowed by most php servers. That's where the how you'd do it comes into play. I think i'd just query my tables, loop them but keep only the line (to do a data_seek later on) and ID in some kind of an hash table or simply an array. This would make it relatively fast without taking too much memory. This is my solution, how do you people see it without dumping everything to memory or by making recursive SQL calls (which will obviously slow everything down i'm pretty sure) Mathieu Dumoulin Programmer analyst in web solutions [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 267.14.25/247 - Release Date: 1/31/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] general rule for when to perform an operation in either Mysql or php
At 12:20 PM 1/29/2006, daniel smith wrote: I am playing around with Mysql and php and I am not sure about when it is best do something in mysql or php when BOTH can perform the operation. Example, date formating can be performed by Mysql during the query DATE_FORMAT(blah, blah...) or by php with date(blah, blah..). What are the upsides/downsides of doing something like this in Mysql/php. My current (though limited) thinking is not much improvement in either approach over the other in both operations are performed by the same server. I can only see a difference when using huge databases and the database is on a different machine. What is considered to be Best practise when Mysql and php can perform the same operation? Thinking about it, if you're retrieving data, manipulating it during the fetch makes more sense than retrieving it, then manipulating it afterwards. Other than that, all you can do is run some tests - reformatting dates, or string replacements, are not operations which are among the primary functions of database engines. So there's no best practise, except to normalize your data, optimize your database, and use appropriate indexes. Most likely, processing differences are insignificant. In that case the best practice would be whatever results in clearer code, code you can come back to in six months and quickly grasp its sense. Cheers - Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 1/27/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Table sorting problem - further thought
At 10:16 PM 1/12/2006, Miles Thompson wrote: At 05:51 PM 1/12/2006, Charles River wrote: I am a novice in both PHP and MySQL, otherwise I would be able to do this myself. :-) A non-profit I assist has a table (http://www.lbc4cc.org/04-05board.php) that is displayed by a simple PHP script. That was fine last year, but now we have some new officers and some new board members and I have no idea how to change the script so that Officers and Members table is presented officers first (Pres, Vice-pres, Sec and Treas) and then an alpha listing of board members who are not officers. The existing script looks like this: ?php $sql = SELECT * FROM members; $result=mysql_query($sql); if (!$result) { echo Could not successfully run query ($sql) from DB: . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo No rows found, nothing to print so am exiting; exit; } echo table cellspacing='0' border='1' cellpadding='2' bgcolor='#CC' width='100%'; echo tr\n; echo thOffice/td\n; echo thName/td\n; echo thAddress/td\n; echo thPhones/td\n; echo thChurch/td\n; echo thEmail/td\n; echo thTermbrEnds/td\n; echo /tr\n; while ( $row = mysql_fetch_array($result,MYSQL_ASSOC) ) { echo tr\n; if ($row['Office'] == ) { echo tdnbsp;/td\n; } else { echo tdb{$row['Office']}/b/td\n; } echo td{$row['Name']}/td\n; echo td{$row['Address']}/td\n; echo td{$row['Phone']}/td\n; if ($row['Church'] == ) { echo tdnbsp;/td\n; } else { echo td{$row['Church']}/td\n; } if ($row['Email'] == ) { echo tdnbsp;/td\n; } else { echo td{$row['Email']}/td\n; } echo td{$row['Term']}/td\n; echo /tr\n; } echo /table\n; ? Can some kind soul bang out the code I need? Thanks. I'd cheat and add a numeric field, let's call it num_rank, ranking the offices in the order you want them displayed, e.g. President 10 Vice-President 20 . . . Board Member50 Board Member50 Board Member50 and change the query to SELECT * from members order by num_rank, last_name which would provide officers and board member in the order you want them, automatically sorted by name. Incidentally, why do you have a separate table for officers and directors? Maybe the answer is because it was cheap and easy, but is there a separate listing for all members who are not on the Board? In that case, you would be better off with two tables: 1. Add a logical lBoardMbr field to your general list of members, and this general list of members also has to have a unique primary key. MySQL will do that for you with an autoincrement field, with a table type of MyISAM. That table type ensures no re-use of deleted keys. 2. Your BoardMbr table then consists of fields like this: nMbrId - primary key of the person in the general list cOffice - text, President, Vice-President Board Member etc. num_rank - as discussed above cTerm - text field describing term. When a member becomes an officer you do four things: a) set the lBoardMbr field to true in the general table b) enter the member's primary key value in nMbrId field in BoardMbr table c) enter correct value cTerm in the same table d) set the lBoardMbr field to false in the general members table for those members who are leaving the board. The query to select the officers and directors would then change to SELECT general.nMbrdID as nGenId, BoardMbr.nMbrID as nBrdId, * from general, BoardMbr WHERE nGenID = nBrdID AND lBoardMbr != 0 ORDER BY num_rank, last_name Advantage? Data more closely approaches 3rd normal form, no redundancy, no errors when retyping, etc. Long answer - hope it's been helpful. Regards - Miles Thompson PS If this is pedantic, and you know how to do all this stuff, pls forgive. PPS Note I've assumed you have first_name and last_name fields /mt And when I was lying bed this morning, in that half-state between full wakefulness and sleep, I thought, WHY BOTHER WITH THE lBoardMbr FIELD? AN ENTRY AND LINK IN THE BoardMbr TABLE IS ENOUGH!!! Good example of why one should sleep on solutions. Which changes the SELECT to SELECT general.nMbrdID as nGenId, BoardMbr.nMbrID as nBrdId, * from general, BoardMbr WHERE nGenID = nBrdID ORDER BY num_rank, last_name Cheers - Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.371 / Virus Database: 267.14.17/228 - Release Date: 1/12/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Table sorting problem
At 05:51 PM 1/12/2006, Charles River wrote: I am a novice in both PHP and MySQL, otherwise I would be able to do this myself. :-) A non-profit I assist has a table (http://www.lbc4cc.org/04-05board.php) that is displayed by a simple PHP script. That was fine last year, but now we have some new officers and some new board members and I have no idea how to change the script so that Officers and Members table is presented officers first (Pres, Vice-pres, Sec and Treas) and then an alpha listing of board members who are not officers. The existing script looks like this: ?php $sql = SELECT * FROM members; $result=mysql_query($sql); if (!$result) { echo Could not successfully run query ($sql) from DB: . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo No rows found, nothing to print so am exiting; exit; } echo table cellspacing='0' border='1' cellpadding='2' bgcolor='#CC' width='100%'; echo tr\n; echo thOffice/td\n; echo thName/td\n; echo thAddress/td\n; echo thPhones/td\n; echo thChurch/td\n; echo thEmail/td\n; echo thTermbrEnds/td\n; echo /tr\n; while ( $row = mysql_fetch_array($result,MYSQL_ASSOC) ) { echo tr\n; if ($row['Office'] == ) { echo tdnbsp;/td\n; } else { echo tdb{$row['Office']}/b/td\n; } echo td{$row['Name']}/td\n; echo td{$row['Address']}/td\n; echo td{$row['Phone']}/td\n; if ($row['Church'] == ) { echo tdnbsp;/td\n; } else { echo td{$row['Church']}/td\n; } if ($row['Email'] == ) { echo tdnbsp;/td\n; } else { echo td{$row['Email']}/td\n; } echo td{$row['Term']}/td\n; echo /tr\n; } echo /table\n; ? Can some kind soul bang out the code I need? Thanks. I'd cheat and add a numeric field, let's call it num_rank, ranking the offices in the order you want them displayed, e.g. President 10 Vice-President 20 . . . Board Member50 Board Member50 Board Member50 and change the query to SELECT * from members order by num_rank, last_name which would provide officers and board member in the order you want them, automatically sorted by name. Incidentally, why do you have a separate table for officers and directors? Maybe the answer is because it was cheap and easy, but is there a separate listing for all members who are not on the Board? In that case, you would be better off with two tables: 1. Add a logical lBoardMbr field to your general list of members, and this general list of members also has to have a unique primary key. MySQL will do that for you with an autoincrement field, with a table type of MyISAM. That table type ensures no re-use of deleted keys. 2. Your BoardMbr table then consists of fields like this: nMbrId - primary key of the person in the general list cOffice - text, President, Vice-President Board Member etc. num_rank - as discussed above cTerm - text field describing term. When a member becomes an officer you do four things: a) set the lBoardMbr field to true in the general table b) enter the member's primary key value in nMbrId field in BoardMbr table c) enter correct value cTerm in the same table d) set the lBoardMbr field to false in the general members table for those members who are leaving the board. The query to select the officers and directors would then change to SELECT general.nMbrdID as nGenId, BoardMbr.nMbrID as nBrdId, * from general, BoardMbr WHERE nGenID = nBrdID AND lBoardMbr != 0 ORDER BY num_rank, last_name Advantage? Data more closely approaches 3rd normal form, no redundancy, no errors when retyping, etc. Long answer - hope it's been helpful. Regards - Miles Thompson PS If this is pedantic, and you know how to do all this stuff, pls forgive. PPS Note I've assumed you have first_name and last_name fields /mt -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.371 / Virus Database: 267.14.17/227 - Release Date: 1/11/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] inserting due date into database
At 08:34 AM 1/4/2006, Amos Glenn wrote: php.net says: date ( string format [, int timestamp] ) To turn a php timestamp into something that will be recognized by the mysql DATE type, you might try this: ?php $due_date= //however you set up you invoice+14days timestamp $mysql_date = date(Y-m-d,$due_date);// makes a string like -MM-DD ? The php date() function can form just about any string you want to make from a date if you've got a timestamp, which you do. What formate is your original date in? There may be an even simpler way of doing it. -Amos Ruprecht Helms wrote: Hi, how can I calculate the due date from the date of an invoice and insert the result into a mysql-database. The daydifference is 14 days. Actualy I have tried something with mktimes, but I only get the timestamp of the due date. I have troubles to write that into a dabasefield that was set to datetype. Regards, Ruprecht And to add to the discussion, why would you want to do such a thing? Calculate it when retrieving the data. It's similar to storing a person's age when you have the date of birth. Regards - Miles Thompson -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.371 / Virus Database: 267.14.12/220 - Release Date: 1/3/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Ending session
At 05:30 PM 12/9/2005, Ron Piggott (PHP) wrote: 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 Ron, This may be overkill, but on a failed login I did not want the ckval variable hanging around in any form, hence: session_unregister( ckval ); unset($_SESSION[ckval]); unset( $ckval ); session_destroy(); Hope this helps - Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] connect vs pconnect
Read the comments following the formal description at http://www.php.ca/mysql_pconnect They're pretty illuminating, and probably resulted from hard-earned experience. Miles At 11:47 AM 12/8/2005, Benjamin Adams wrote: I'm trying to figure out if running mysql_connect or mysql_pconnect would be faster. Can someone explain the difference? Picking one for a very high traffic website with a 10 G database. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Sending multiple items via a single form field
At 04:40 PM 11/14/2005, Chris Payne wrote: Hi there everyon, I have a set of form fields dynamically generated but each item must contain 2 pieces of data - the input from the field AND the id that the input represents from the DB. I had this info a while back but had a major HD crash and lost the info I had, how can I do this easily in PHP? Hopefully an easier to understand scenario: I have a form with - example - 5 items listed, each item from the DB and you select ONE item only out of the list, when you submit the form it sends the input from the field you select BUT I also need it to send an addition bit of info in the form of $id so that on the processing page, I can extract both the ID and the data entered from a single field. Obviously I can't use a hidden field for this so the data has to be tacked-on to the input field somehow? Any help would save my life :-) Chris You mean like this: In the display area of the script, using the ubiquitous while $myrow = mysql_fetch_array($result), sub_key being the SUBscriber_KEY : print( 'input type=checkbox name=chkdelete[] value=' . $myrow['sub_key'] . ''); // rest of record - name, etc., then repeat and as I was using this for a bulk delete, up top in the processing section: // // Bulk Delete // if ($chkdelete $bulkdelete){ foreach ($chkdelete as $value){ $sql = delete from subscriber where sub_key = '$value'; $result = mysql_query($sql); } echo centeremSelected Records deleted!/emp; } HTH -Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] text with html tags apeared in text area.
At 07:03 PM 10/28/2005, Mohamed Yusuf wrote: hi I have php form. one of my textarea gets data with html tags from database, so I would like to remove those html tags like br /, therefore is there anyway that i can remove those tags in the data and then the data can appear as text in the textarea. Mohamed, PHP has a really rich set of string processing functions. Have a look at: strip_tags(), see http://ca3.php.net/manual/en/function.strip-tags.php You may also want to look at: htmlentities() stripslashes() addslashes() It all depends, of course, on what you want to do with the content. The br / - you retrieving XML? Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Convert String to Array
At 12:22 AM 9/30/2005, Ng Hwee Hwee wrote: Hi guys, this looks like a very simple problem but i really have no idea how to do it.. please help me! thanks! my MySQL database has a table of which 2 fields are as follow T100FieldNmT100Value == = vehMdlCd[0] MER vehMdlCd[1] LEX vehMdlCd[2] TOY and I need to echo out the value for $vehMdlCd[0]...[2]. but when I retrieve T100FieldNm from the database, PHP recognises it only as a string. Thus, in order to get the value of $vehMdlCd[0], I need to do the following. for($i=0; $i$numOfRows; $i++) { $tmpVehMdlCd = vehMdlCd[$i]; $vehMdlCd[$i] = $$tmpVehMdlCd; } where $numOfRows has been calculated by doing a count of all T100FieldNm like vehMdlCd%. Can someone enlighten me with a simpler way?! Potentially I can have a 100 over different T100FieldNm! =( I tried using settype and type-casting but still don't get the respective T100Value! *sob* Thanks sooo much! Best regards, Hwee Hwee Look to your data - why are you storing an array element name matched with a vehicle line? The T100Value appears to be the key field, retrieve it and build your array within your script. Think hard about why we have relational databases -- you are tying a value to a position with this structure. If ever something has to be inserted in the middle everything that follows will be broken, or you will be driven into v. peculiar constructs to solve a problem which could have been avoided up front. On the other hand, I know nothing about your data or your application, o maybe I'm blowing smoke. Regards - Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] joining tables in postgres
At 04:13 PM 9/29/2005, redhat wrote: anyone know of any good tutorials on simple joining of tables in Postgres using PHP? I did some Googling and didn't find anything satisfactory. thanks, Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You mean like this, after establishing the connection ... $sql = SELECT childname, childinitial, surname FROM children, parent WHERE children.familykey = parent.familykey; $result = pg_query( $sql); and then process the results using the appropriate pg_ commands. See the manual. But the join is done with the SQL. Regards - Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] A question with php.ini
At 03:31 PM 9/21/2005, Daryl Booth wrote: Hi, How does the php.ini need to be setup for SMTP or how do I find it out? Thank-You very much Daryl Booth Google didn't take long . http://www.phplivesupport.com/documentation/viewarticle.php?uid=1aid=70pid=3 and that's pretty clear. It depends on whether you're installing on Linux/BSD or Windows. Somewhere in the online manual there's a parallel example. Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting Started..
People don't like top posting, but I'm doing it for a reason. See what's at the end 1. Clint - Don't hijack threads. Some people use threaded mail clients, and your getting started will end up under Yui's thread. 2. Is it *necessary* to have a confidentiality notice that's just about equal in bulk to your message? If it's part of a canned sig, why not create a little simple one for this list. On to your question. Since you don't have all the code posted here, I suspect something is going on earlier in the file. Maybe you have an opening PHP tag, and a line without a semi-colon to terminate it. Why not try again, with just a single line file: ? phpinfo(); ? Once that works, then expand it. Regards - Miles Thompson At 08:37 PM 9/19/2005, Clint Lovell wrote: I'm just getting started here and I'm working with PHP MySQL for Dummies. The book says to write a simple file called test.php with the following entries in it: This is an HTML line ?php echo This is a PHP line; phpinfo(); ? When I run http://localhost/test.php, this is the error I got: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\apachefriends\xampp\htdocs\test.php on line 9. Can someone tell me what's wrong and what I need to do to get things squared away? Thank you... Respectfully, Clinton E. Lovell Principal Rainmaker Marketing Corporation 15519 Dawnbrook Drive Houston, Texas 77068 (281) 537-1200 (206) 203-1229 (eFax) CONFIDENTIALITY NOTICE: This communication and any documents, or files, attached to it, constitute an electronic communication within the scope of the Electronic Communication Privacy Act, 18 USCA 2510. This communication may contain non-public, confidential, or legally privileged information intended for the consideration of the designated recipients(s). The unlawful interception, use, or disclosure of such information is strictly prohibited by 18 USCA 2511 and any applicable laws. If you have received this e-mail in error, please immediately notify us at (281) 537-1200 or via reply email and permanently delete the original and any copy of any e-mail, file or attachment and destroy any printout thereof. Thank you for your assistance. -Original Message- From: Norland, Martin [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 2:04 PM To: php-db@lists.php.net Subject: RE: [PHP-DB] insert error for mysql One of the strings you're inserting has an quotation mark (apostrophe). You're going to have to do some more careful data scrubbing on the incoming data. E.G. one of the strings says it's used in the retail, banking, and insurance industries, among ... And it's breaking the containing ' - insert into foo (bar) values ('this isn't going to work.'); might I suggest starting with addslashes() Cheers, - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -Original Message- From: Yui Hiroaki [mailto:[EMAIL PROTECTED] Sent: Monday, September 19, 2005 1:26 PM To: php-db@lists.php.net Subject: [PHP-DB] insert error for mysql. . hi! I have an error message to try to insert character into table. But I have an error messages like below. When I try to insert $strbuf, I got error. Could not perform INSERT to table 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 's used in the retail, banking, and insurance industries, among I publish SQL; mysql create table view(b_col_id mediumint(255) NOT NULL AUTO_INCREMENT, b_col longblob NOT NULL,file_name varchar(255) NOT NULL,file_size varchar(255) NOT NULL,file_type varchar(255) NOT NULL,file_date time,vtext longtext,PRIMARY KEY(b_col_id))TYPE=MyISAM; mysql alter tablev view add fulltext (vtext); The code-- $handle = popen(/usr/bin/pdftotext \$original_tmp\ - -layout 21, 'r'); $strbuf = fread($handle, 2048000); echo $strbuf; pclose($handle); $sql_insert = INSERT INTO view(b_col,file_name,file_size,file_type,file_date,vtext) VALUES ('$binaryContent','$original_name','$original_size','$original_type',CUR TIME(),'$strbuf'); mysql_query($sql_insert) or DIE (Could not perform INSERT to table .mysql_errno().: .mysql_error()); mysql_close($db); Please do help me! Yui -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Highlighting data selected from one table that appear in another
At 08:50 AM 9/1/2005, boclair wrote: Content-Type: multipart/alternative; boundary=070700030402040702060708 X-Authentication-Info: Submitted using SMTP AUTH PLAIN at omta05ps.mx.bigpond.com from [138.130.220.111] using ID boclair at Thu, 1 Sep 2005 11:49:59 + This is a multi-part message in MIME format. --070700030402040702060708 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit mysql 4.0.25 php 4.3.1 I seem to be unable to solve this problem without some help. A webpage is to list all the clients in a mysql Client table. Each client has an an allocated clid. Those clients who are listed, identified by their allocated clid, in a Transactions are to be highlighted in different ways according to progress of the transaction, the progress being determined on whether date values have been inserted into various fields. Since mysql select joining the tables lists only the clients whose appear in both tables. I have been attempting to create a temporary table inserting the data from Client and Transactions and selecting from that but not successfully yet. But is this the way to go about it. The scale is an anticipated 1000 clients per month of which an anticipated 800 will involve transactions Louise It sounds like you need an OUTER JOIN, which lets you fetch all the records from table A and table B that match, as well as the non-matching records from table B. The MySQL documents are a little confusing, here's a good article: http://www.onlamp.com/pub/a/onlamp/2001/06/27/aboutSQL.html HTH - Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] maximum number of records in a db?
At 12:11 PM 8/26/2005, Jordan Miller wrote: I was just wondering what is the maximum number of records that can be successfully handled with a db. any db will do. it doesn't have to be the fastest or best, just one that can hold the maximum number of records and still be able to interact well with php. any ideas? thanks, Jordan This is a useless question. Here's the matching answer: The number of records any database can hold matches the length of a piece of string. Seriously - do some homework, visit the host sites and read the specs. A lot depends on what you intend to store. As for interacting well - push the string. MT -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] load data infile -- problem
I could be 100% wrong on this, but I do not think that a command line statement can be executed through mysql_query() - try exec(). If I remember correctly mysql load data infile ... is not executed from within mysql, but at the command line. (Hint: look at the source for phpMyAdmin and copy how it is done.) Regards - Miles At 08:30 AM 8/18/2005, select.now wrote: Helo everyone ! I find this problem and I think I am close to the solution but ... The question: I need to import a few thousand of record storee in a *.csv file on my local harddisk, with my php application, managing my mysql engine. So, in command line, all works fine, all records are correctly imported. command line code - mysql load data infile 'c:\\datastream\\import\import -into table iport - fields terminated by ';' - ignore 9 lines; - /command line code But in my php app, because I am confuse a bit (use of ['], [] and the definition of variables in mysql_query), I don't make this import. -- php code --- $a = 'c:\\\datastream\\\import\\\import'; $extra_arg = 'fields terminated by \';\' ignore 9 lines;'; $query = 'load data infile \''.$a.'\' into table import '.$extra_arg.''; $result = mysql_query ($query) or die_mysql (brExecutia comenzii i$query/i a esuat.br); -- /php code -- I get this output-error: === load data infile 'c:\\datastream\\import\\import' into table import fields terminated by ';' ignore 9 lines; === and the import doesn't occured. Where is located my mistake ? Thanks in advance. -- cu respect, [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: oci_bind_by_name, 'Unknown or unsupported datatype given'
Anton, This seems so fundamental I hesitate to suggest it. Have you run a script with phpinfo() in it? Or apache or httpd with the -l, -V or -t switches? Miles At 06:59 AM 8/10/2005, Anton Channing wrote: Okay, its seems my problem is actually more fundamental. I've just tried to run the example from the oci_bind_by_name documentation on php.net, and get the same error! The example doesn't work for me. I think at this point I need to assume there is something wrong with the server settings? Maybe Apache needs certain configurations in order for this to work? Anyone have any idea whats causing this? This is the page with the example I tried to run: http://uk.php.net/manual/en/function.oci-bind-by-name.php And this is the output from it: Warning: oci_bind_by_name() [function.oci-bind-by-name]: Unknown or unsupported datatype given: 1 in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 28 Warning: oci_bind_by_name() [function.oci-bind-by-name]: Unknown or unsupported datatype given: 1 in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 29 Warning: oci_bind_by_name() [function.oci-bind-by-name]: Unknown or unsupported datatype given: 1 in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 41 Warning: oci_execute() [function.oci-execute]: OCIStmtExecute: ORA-01008: not all variables bound in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 46 Warning: oci_execute() [function.oci-execute]: OCIStmtExecute: ORA-01008: not all variables bound in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 47 Warning: oci_execute() [function.oci-execute]: OCIStmtExecute: ORA-01008: not all variables bound in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 46 Warning: oci_execute() [function.oci-execute]: OCIStmtExecute: ORA-01008: not all variables bound in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 47 Warning: oci_execute() [function.oci-execute]: OCIStmtExecute: ORA-01008: not all variables bound in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 46 Warning: oci_execute() [function.oci-execute]: OCIStmtExecute: ORA-01008: not all variables bound in D:\Apache Group\Apache2\htdocs\test\oci_bind_by_name.php on line 47 On 8/9/05, Anton Channing [EMAIL PROTECTED] wrote: I am currently building a php-oracle application for the college I work for, and as part of that application I have cause to to create some insert/update procedures. My best solution for this is to have an input/output parameter representing the id of the field that needs to updated. This works fine. ... And finally, this is the error I get (including a stack trace): An error has occurred and the page has not loaded correctly. Please try and refresh/reload the page. If the error persists, then please contact MIS and we will look into the problem. errno: 2 errstr: oci_bind_by_name() [a href='function.oci-bind-by-name'function.oci-bind-by-name/a]: Unknown or unsupported datatype given: 1 errfile: D:\Apache Group\Apache2\htdocs\Learner_Support_Fund\update_equipment.php errline: 77 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: oci_bind_by_name, 'Unknown or unsupported datatype given'
At 11:32 AM 8/10/2005, Anton Channing wrote: On 8/10/05, Miles Thompson [EMAIL PROTECTED] wrote: Anton, This seems so fundamental I hesitate to suggest it. Have you run a script with phpinfo() in it? Or apache or httpd with the -l, -V or -t switches? Miles Okay, have just run phpinfo, obviously it prints out a whole load of stuff, what am I looking for? I hesitate to do anything with the server. Unfortunately my colleague that deals with the server is on holiday, so if the phpinfo output can help, it would be good if I can work something out from that. Also, we are lacking a test server at the moment, so the only changes I can make are to the live one... :) Anton Please reply to the list ... Well, it tells you what PHP has been compiled with, Apache configuration, and further down what database support is available. The reason for running phpinfo() and Apache or httpd with those command line switches is that it tells you what support for Oracle is available from the web server side. Presumably there are similar functions built into Oracle. Never having used Oracle, I cannot tell you what to look for, but there is some basic information here which should help with your diagnosis. Regards - Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: printing errors
David, Amen to that! Vowels do help, don't they? Started to read this thread, then thought Bah, if he doesn't care enough to help us understand his problem, why bother straining to understand this crap? Miles At 09:27 AM 8/2/2005, David Robley wrote: (umeed wrote: most of the time wen dealing with mysql, i get error bt i want to exactly know wt the error is due to. how can i print specific error tht wil make it easy to know u cn us mysql_error() n prnt ur qry as well And perhaps if you write properly your questions may be better understood Cheers -- David Robley Change is inevitable, except from a vending machine. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate record
Do a seek on the fields which cannot be duplicated; if there's a hit reload the page with the appropriate error message, otherwise reload the page with a success message. Although I have not worked with AJAX, this would appear to be an excellent spot to use it. Silently check after focus has left the final field which must be unique, doing nothing if data is OK, putting up a flag if there was duplication. As for a unique ID for each record, i.e. one that autoincrements, that's almost always a good idea. Regards - Miles Thompson At 07:17 AM 7/30/2005, Hallvard wrote: I have a page that posts data from a form to a mysql database. The problem is that if the user hits the reload button on the browser, the data will be posted again, resulting in a duplicate record. How can I avoid that? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] auto-generating next id (in order) for an add script
Depending on your version of MySQL, table type should be MyISAM so that numbers for deleted articles do not get reused. Miles Thompson At 02:33 PM 6/20/2005, [EMAIL PROTECTED] wrote: Thanks Bastien, I am off to try the auto increment. I will post back if I cannot get it to work properly. Again, thanks everyone. -Original Message- From: Bastien Koert [EMAIL PROTECTED] To: [EMAIL PROTECTED]; php-db@lists.php.net Sent: Mon, 20 Jun 2005 13:30:13 -0400 Subject: RE: [PHP-DB] auto-generating next id (in order) for an add script post your code and db structure, it might be simpler to use an auto increment value and let the db do the work in assigning the next number... bastien From: [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] auto-generating next id (in order) for an add script Date: Mon, 20 Jun 2005 12:54:20 -0400 Hello, I have a site that allows reporters to enter their articles into a forum. I am then spilling their articles onto the main page from a MySQL dbase via a php script, read LATEST ARTICLES. I am now entering the data myself after they email it to me, however this is becoming more of a task I dont' have time for as the number of articles increase per day. Right now, I have an addarticle.php page where they can enter their information. I have ran a test of this script, and it works great. However, I have been entering the PHP IDs myself in ascending order (i.e. 0005, 0006, 0007) because I can see all of the articles. The reporters however are not able to see these articles, and instead of having them enter a random php ID, I'd like my add script to check for the last ID entered and then enter the number above (i.e add row to table, check PHP ID, if 0007 is last row entered, enter 0008 for php ID for new article). Does anyone know how to add this particular command to a page, and if so, where? Thank you in advance. -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mysql: LOCK TABLES
At 09:01 PM 5/1/2005, Chris wrote: Hi, I've got question on using LOCK TABLES with MySQL and PHP. I don't have a great understanding of LOCK TABLES, but I'll lay out my situation: I've got a table and a PHP function to rebuild several columns in this table. I need to read these columns from the database (all of them) and recalculate the proper values, then UPDATE the rows with the new values. So, two queries, a read query, then a write query. This is a recurisve function in PHP, so it can't be done in one MySQL query unfortunately. I need to keep the values of these columns from changing in-between the read and write queries. As I understand it this is exactly what a WRITE lock is for. Now, to my question. What does my PHP function see if it goes to lock a table, and fails? Does the query itself fail, requiring me to Loop+sleep my application until it doesn't? Or does mysqli_query() not return until it has successfully locked the table? If it's one of these, can I force it to act like the other? Another thing, This table could possibly get *huge* in the future, if so I would probably need to loop through the results of the read query and RUN the UPDATEs as soon as my PHP app knows it to save on memory usage. Thanks in advance, Chris Chris, So your user LOCKS the table and then power fails, browser crashes, someone else tries to run same function ... etc. MySQL is so fast on indexed queries, are you certain this is information that has to be calculated and stored, rather than fetched and displayed? Of course you've not described the data or the calculation, so my question may be out of line. Generally speaking, though, it's not a good idea to lock either rows or tables in Internet apps. Regards - Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] 'OR' logic in mySQL query
No - OR and AND tests work like this: (first conditional test) OR (second conditional test) therefore ((date_received LIKE '$todays_date) OR (date_received LIKE '$yesterdays_date')) And of course you will check the MySQL docs to confirm that OR does work in the WHERE clause, won't you? Another way of handling the query is to ask for anything less than two days old, sort of like this: where date_received = $today - 2. (And no, that's not accurate syntax.) Regards - Miles At 05:04 PM 4/17/2005, Ron Piggott wrote: Am I able to use the OR logic in mySQL queries? $query = SELECT * FROM table WHERE date_received LIKE '$todays_date' OR '$yesterdays_date' ORDER BY prayer_request_reference ASC; In this above example will the OR '$yesterdays_date' work? In reality I am wanting to preview new entries to the database within the past 2 days 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
Re: [PHP-DB] comprehensive sql tutorial
Yemi, Well, Joe Celko is a recognized expert; Googling for Joe Celko tutorial turned up 8,900 hits, but this link was found on the first page: http://www.codebox.8m.com/sql.htm Lots of stuff there. If you want books, The Practical SQL Handbook Bowman, Emerson and Darnovsky ISBN 0-201-44787-8 SQL for Smarties: Advanced SQL Programming Joe Celko ISBN 1-55860-323-9 Keep in mind that one of the WONDERFUL things about SQL is that a lot of the plumbing is hidden. Determine what information you need returned, what inputs you have, normalize your data (with sufficient keys to ensure uniqueness for each and every row) and go for it. Don't tie yourself in knots wondering if any product meets all of Codd Date's criteria - to the best of my knowledge none do, nor do many meet the SQL-2 standard. (SQL-92? I'm relying on memory here.) The most widely used almost-but-not-quite-yet-evidently-good-enough relational database on the Internet is MySQL. Some of the exercises in the aforementioned books could not be done with MySQL - doesn't mean it's not useful. Tens and tens of thousands have found it is. Give PostgresSQL a serious look - v. impressive. Ditto Firebird. Have fun - Miles At 08:00 AM 3/28/2005, Yemi Obembe wrote: Does anyone please know where i can get a comprehensive SQL tutorial as in one that contains stuffs on engines, data structures, table types, etc NOT JUST the basic query commands CREATE, SELECT, UPDATE, DELETE, INSERT... their syntax(es). - A passion till tomorrow, Opeyemi Obembe | ng.clawz.com - Do you Yahoo!? Yahoo! Small Business - Try our new resources site! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Handling database calculations with a php page
That's the convention. You HAVE TO: - read and use the manual, the rest of us do - dig out and follow a tutorial on working with PHP and databases If you do not, you will have no real knowledge of what you're doing, only a piecemeal Someone said to do it this way. Do this BEFORE you get too deeply into your project. I'd also recommend that you Google for tutorial database normalization and take to heart what you read on normalization. It is v. simple, usually one of the early chapters of almost any book on databases, but will keep your project and structure on focus. Future queries of this nature will be answered: RTFM, 'cause you have to. If you are just starting in on this, and about to say But I don't know what questions to ask, or how to ask, that's why it is strongly recommended you dig out a tutorial and work through it, break the provided code and see what happens - error codes, etc., how fixing it works, and so forth. These are NECESSARY first steps. You *cannot* skip the basics. I can *promise* you these results: 1. The fuzzy maze of functions, use of symbols, obscurity, and the seeming magic will disappear and be replaced by confidence and the ability to ask sound questions. 2. You will point to your completed pages glowing on on monitor and proudly proclaim I did that! Wanna know how it works? (At which point your companion's eyes will glaze over and you will look like the magic-wielding wizard.) Cheers - Miles At 04:46 AM 3/14/2005, JeRRy wrote: Hi, So in other words when we are talking queries anything before a . for SELECT etc means table name and after the . means column name within that table? So... (table_name).(Column_name) ? Is that right? J Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Handling database calculations with a php page
First of all, check the SELECT statement in your database documentation, because you do this within your select. It is important you that you inform yourself about this, because you will use it a lot. So this is not really a PHP question. The statement is written something like this: SELECT a.currency + b.currency + c. currency curr_total from a, b, c WHERE a.cust_id = b.cust_id AND b.cust_id = c.cust_id AND c.cust_id = '$customer_id'; (or cust_id and some kind of transaction identifier) ( Tables are named a, b and c for convenience. Those who prefer JOIN syntax would write it differently) Secondly, unless you are having problems with rounding errors or must preserve the state of an issued document, like an invoice or purchase order, why write to a 4th table? Your data is contained in a, b, and c, and queries are v. fast, so what advantage or benefit is derived from storing the results in d? If you must do it, then you use either an INSERT or UPDATE statement, with appropriate customer and transaction IDs to keep things straight. If you do not know how to use/write the PHP code to execute this, examine the mysql functions in the PHP docs and avail yourself of the numerous tutorials on the Web. Google for something like tutorial PHP MySQL. As much as possible, do the work within the database. Hope this is helpful. Regards - Miles At 07:38 AM 3/13/2005, JeRRy wrote: snip What is the best PHP code to use for this inside a PHP code? /snip I meant ... What is the best PHP code to use for this inside a PHP page/file. (e.g. calculate.php) Also the total of the 3 tables should than be updated to a 4th table which I did not mention. So the total of table 1, 2 and 3 should than be updated to a 4th table. I want to keep it all seperated like this (in different tables) so it's easier to manage and learn from. Thanks! Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Cannot connect to local server
New version of MySQL, old PHP? possible password encryption mis-match? Check out: http://dev.mysql.com/doc/mysql/en/old-client.html Regards - Miles At 06:33 AM 2/10/2005, Denis Gerasimov wrote: Hello, I am trying to connect to MySQL using $mysqli = new mysqli(example.com, user, pass, db); And access is ALWAYS denied (I played around changing user name/pass/host - didn't help me at all) The thing is that I CAN connect to the db server using this user name and password with my DB administration tool. Some background 1. MySQL and Apache + PHP are running on the same machine. 2. The user is allowed to connect from '%' (everywhere) 3. Connecting to localhost fails too (saying cannot connect to socket...) What is going on? Best regards, Denis Gerasimov Outsourcing Services Manager, VEKOS, Ltd. www.vekos.ru -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Programmer required
This is waaay off topic, but: I hope you mean retired, who will presumably work for less. Why would you want one who's not current? Just wondering - Miles At 09:47 AM 2/2/2005, ioannes wrote: I'm looking for a programmer, preferably in London or UK, who has been maybe out of work for a few years, to discuss an easy project with. Pass the request on to your friends. John -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Programmer required
At 11:10 AM 2/2/2005, Martin Norland wrote: Miles Thompson wrote: This is waaay off topic, but: I hope you mean retired, who will presumably work for less. Why would you want one who's not current? Just wondering - Miles At 09:47 AM 2/2/2005, ioannes wrote: I'm looking for a programmer, preferably in London or UK, who has been maybe out of work for a few years, to discuss an easy project with. Pass the request on to your friends. John -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I believe the intention of asking for someone who's been out of work for a few years, was to find someone desperate - perhaps they've proposed this project multiple times and nobody wants to touch it :) I didn't know you could say off topic on this list... guess you just can't say its abbreviated form in the subject or - ah heck, who knows. Cheers, -- - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. Martin, a) Never thought of the nobody wants to touch angle -- seen some of those. b) Maybe there's also a won't pay properly aspect at work here. Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Any recomendations on a report writer to use with MY-SQL
Any report writer that supports ODBC. As far as I know, there are no open source report writers like CR. (Gawd, I'd hope they'd be better; my relationship with CR is sort of love-hate.) Love it when the job's done, hate having to touch a working report because everything's binary when it breaks, that's it. I also hate upgrades (think 9.0) that break or no longer support earlier methods. I feel better now, having go that off my chest. So, how complex is the report, and would it be that difficult to code? Then you can take it to any machine. Miles At 01:20 PM 1/25/2005, [EMAIL PROTECTED] wrote: Does Crystal Reports work with MY-SQL? Are there any open source tools that are like Crystal Reports? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] is this a problem ?
There are scores of examples / tutorials on this. Google turned up 6,070 hits on this expression: add user php mysql example Here's one of them, although it assumes register globals is on http://www.php-scripts.com/php_diary/072000.php3 Why don't you pick one, work with it and adapt it to your needs. However, why is your form's action parameter set to a string of hyphens? Regards - Miles Thompson At 09:25 AM 12/28/2004, amol patil wrote: hallo, i have changed file signup1.php with login1.php, in action fied of form form name=form1 method=POST action=-- and saved . but when i run this file and click on submit button, it still shows old sighnup1.php. and data is also not entering in database. while it data was entering in databse before this. but not now with this change. no error shown. only shows previous page and no data entry __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MYSQL
Balwant, Right now this is an algorithm question, not a PHP or MySQL problem. Define exactly what you want to see as output, what you have as inputs, and what process you would have to follow to achieve the output. But don't suppose - be specific. Then it's possible to fit it to a language: maybe all the processing could be done in the SELECT statement, maybe some will have to be done after the results are returned. Regards - Miles Thompson At 12:42 AM 12/22/2004, Balwant Singh wrote: hi to all, may somebody guide me on the following: I want to retrieve data from MYSQL and then want that PHP do calculation - substract a particular field from its previous row. i.e. suppose i have two field named DATE, STOCK and have 10 rows. Now i want that STOCK on the 10th row should be substracted from 9th and so on. May pls. help me. with best wishes balwant -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql to access
Use ODBC to use MySQL from either Access or VB (or any other language!) MT At 12:25 PM 12/17/2004, Perry, Matthew (Fire Marshal's Office) wrote: Here is the problem: I am currently using MySQL and PHP for this application but have realized recently that the bulk of my work is setting up three forms (add, view, modify) for each table I create. It takes hours for each table with MySQL and PHP but takes only minutes with Access. Also, other office administrators have been trained in Access instead of MySQL and will not be able to update my tables directly or set up new forms if I only use MySQL and PHP. On the other hand, PHP and ASP are easier and more flexible with user control options. Also, directly entering SQL can be much more efficient than using Access's embedded SQL applications. I really would like to exploit the advantages of both databases but do not know the best means by which to do this. We are creating a standard that will be followed by everyone in our department and need the best and most efficient solution possible. People move around from different positions constantly and it seems we are making radical changes to our system every year. Here are three questions with which I still need help: 1) Would it really make sense to split the data management between two linked databases (Access and MySQL) or would this just cause problems? 2) If I must use Access, should I use ASP(grrr) instead of PHP? 3) If I must use Access, should I use MS SQL Server(grrr) instead of MySQL? Thank you all for your time and patience. - Matthew -Original Message- From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: Friday, December 17, 2004 10:01 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql to access it would depend on what you need the app to do...if you are looking to use access to do reporting and/ or act as a front end, then it may be feasible... more details, if you care to share them, may help in this consideration bastien From: Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] To: Bastien Koert [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql to access Date: Fri, 17 Dec 2004 09:59:25 -0600 You mean link the tables? I haven't yet considered this. - Matthew -Original Message- From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: Friday, December 17, 2004 9:42 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql to access why not just link the mysql to access? bastien From: Perry, Matthew (Fire Marshal's Office) [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql to access Date: Fri, 17 Dec 2004 09:33:39 -0600 Does anyone know of a FREE program that exports MySQL to access? The trial versions of the ones I have downloaded do not export all the records of the database. - Matthew -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] PHP-HTML-select deny
Good suggestion Anna, that's what we do for AllNovaScotia.com, plus we add this bit of .css @media print { body { display: none; } } Then viewer can't print the page. We do this because only certain subscribers have printing privileges. Regards - Miles Thompson At 03:31 PM 12/1/2004, aNNa wrote: Hi, what can i do, where users can't select and copy my text from web-page. Not that I've ever seen the need but this would deter casual copying: Make a Flash movie with a dynamic, non-selectable text field. The movie can load the text (actionscript command is loadVariables) from a database or a text file via php (or other server side language), or directly from a text file (but beware of the text file being directly accessible to a browser). It's crackable but depends on whether it's worth the effort. Overkill? Quite probably! anna -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Database Design Recommendations
Eric, Your second approach is fine. It's denormalized, extensible, and can be manipulated using tools you put in place. You may want to consider groups as well, thus people belonging to a group could view/edit pages, that has the potential to save a lot of administrative scut work. A table of permissions will also be required so that the various codes used for differing levels of permission are consistent. Suggest that when a user logs in the appropriate permission levels etc. should be fetched and stored in a session to save on some trips to the server. This session data, creatively used, could mean that only the files/pages that user is authorized for will be displayed. Miles At 06:36 PM 11/1/2004, Eric Cranley wrote: I tried to find this in the archives. If I missed it, my apologies in advance. I'm developing an intranet for my company, and we are planning on putting sensitive information on it. I've already setup a login system using sessions, but I'm not sure how to manage and store permissions, such as who can view commissions, reset user passwords, etc. I've devised two methods, but I have a feeling there's a better way to do this that I'm not thinking of. I'll be storing these permissions in a MySQL database. My first idea was a single field with the SET datatype. This allows for a user to have multiple permissions, but makes it hard for other employees to add permissions later, if they decide to restrict a previously open access page. (I should mention that I'm the only person here who knows how to adjust a table in MySQL, and I won't be around forever.) My other idea solved the previously mentioned problem. I could create a second table with employee permissions. It would have two fields, employee_id and permission. Every employee would have one row for every permission they had. I could also create a third table of page names and required permission to view it, so if someone later decides that only certain people should view a page, they can change it without coming to me. What do people think of these ideas, and is there a better way to do this? Thanks in advance. Eric Cranley IT Specialist Willis Music Company -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] which DB to use?
Check the MySQL docs - I *think* subqueries are supported in the latest version, but not triggers or stored procedures. But as I say, check. Alternatives? PostgreSQL or Firebird. HTH - Miles Thompson At 11:07 AM 10/1/2004, Matthew Perry wrote: Thank you very much for your help. If I had to choose between MS SQL Server or or mysql, which would you recommend? I prefer nested subqueries, triggers, procedures etc supported by SQL Server but am completely unfamiliar with any problems that may be accociated with using Microsoft's product and PHP. Ideally, I would use Oracle but it is probably outside of our budget. - matt previous message snipped - looked like thread hijacked. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mass mail
Yes - we're doing 900 per night. It's a one page letter providing the day's headlines with a link to where subscribers can view it. Viewing is done through a Flash movie so as to provide as secure an environment as possible. But now we're digressing into digital rights management. Code itself is nothing special; fetch names and heads from the database, build the list of heads, then run down the returned set of names and email addresses, creating the To; portion of the header, then bung the whole thing into the mail() function. Set the appropriate field in the database with whateer mail() returns, same info name, email result of mail() is fed to a browser for user feedback. Whole thing takes about 4 min to run. After each message is sent set_time_limit(20) is called so whole thing doesn't time out. You may also want to look at the mailing functions which Manuel Lemos has on his site. HTH - Miles Thompson At 10:18 AM 9/20/2004, nikos wrote: Hello list A client of mine sends thousands of mails as newsletters and wants as to make an Interface to admin this list. Its easy to put this mail list in a MySQL table and make the interface on PHP language and with mail() function to send a newsletter. The question is that if this function can handle a thousand mail or more or there is a most appropriate way Thank you -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Bug with assignment operator ( := )
Ross, That's correct. From the MyQL manual: Begin quote .. In a SELECT statement, each expression is evaluated only when sent to the client. This means that in a HAVING, GROUP BY, or ORDER BY clause, you cannot refer to an expression that involves variables that are set in the SELECT list. For example, the following statement will not work as expected: mysql SELECT (@aa:=id) AS a, (@aa+3) AS b FROM tbl_name HAVING b=5; The reference to b in the HAVING clause refers to an alias for an expression in the SELECT list that uses @aa. This does not work as expected: @aa will not contain the value of the current row, but the value of id from the previous selected row. The general rule is to never assign and use the same variable in the same statement. ... end quote There's more at http://dev.mysql.com/doc/mysql/en/Variables.html So why not: select *, (StkhistMonthqty06 + StkhistMonthqty07 + StkhistMonthqty08) as total . . rest of statement ... . and total 0 Regards - Miles Thompson At 10:10 PM 8/28/2004, Ross Honniball wrote: SQL Statement: select *,@xtotal := StkhistMonthqty06 + StkhistMonthqty07 + StkhistMonthqty08 as total from StkMast as sm inner join StkHist as sh using (STkCode) where (StkAuthor like 'keller%') and (sh.StkhistYear='2004') and (@xtotal0); Notice the use of @xtotal. I have saved some output from an instance where I ran this query and it worked as expected. Subsequently it has stopped finding any results. (the table has definitly NOT changed). If I take out the and (@xtotal0) clause, it finds records (and, whatsmore, I can see that xtotal is indeed greater than zero. Does anyone know of any erratic behaviour when using the assignment operator? Or am I doing something wrong? (Note that this is actually the first time I have ever used the assignment operator, so I'm pretty green really) . . Ross Honniball. JCU Bookshop Cairns, Qld, Australia. . -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Help! WINXP/Apache2.0/PHP4.3.8 - Can't run PHP
This ain't exactly db related, but if you do a View Source on your page what do you see for the button's submit? If it's PHP script then you have a configuration problem. You should not see PHP in the browser. Set up a file called phpinfo.php which contains one line: ? phpinfo(); ? and call it from your browser. If your configuration is correct you will see pages of information on your setup and configuration. If not, then it's back to the installation section of the fine manual. Regards - Miles Thompson PS Remember, PHP executes SERVER side, not client side. Don't treat it like JavaScript. /mt At 03:05 PM 8/20/2004, Jasper Howard wrote: yeah, sounds like you aren't setting anything in the apache config to pharse the php script with the php engine. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] When I have a html page with an embedded php method behind a button, when I click the button I can't run the PHP, instead my browser pops up a dialog box with a request a file download of my PHP script. Also, when I run a php in my browser either nothing happens or I get the file load. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Lock Record on Postgresql
Norma, Generally speaking issuing locks on records across the internet is not a good idea. Too many things can happen that could result in the record never being unlocked. Recognize the HTTP is stateless, that's one of its limitations, and work around that. Regards - Miles At 11:30 AM 8/13/2004, Norma Ramirez wrote: I need to lock a record in a postgresql table, how can I send the lock query in a script and after in other script send the unlock instruction? Is this possible? Thanks Norma R -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Lock Record on Postgresql
Torsten, Elegant! Miles At 02:03 PM 8/13/2004, Torsten Roehr wrote: Norma Ramirez [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thanks for answer Miles, I'm aware of what you wrote but have a little hope to find some way, and Robby what I'm trying to do is avoid the user for update or delete a record that other user has been already selected, so I cant tell something like: This record is locked by another user, try later, currently I'm doing this by code but like to do by Postgres directly. Thanks in advance. Hi Norma, you can achieve this in a much more comfortable and elegant way: Create an integer column named oca (stands for Optimistic Concurrency Control Attribute). When you load the data to show them in the editing form store the value in a hidden field or in the session (if you are using sessions). Then when you update the data use the following statement: UPDATE table SET column = '$value' ..., oca = oca + 1 WHERE user_id = $user_id AND oca = $value_from_hidden_field After performing the query check the affected rows. If there is one affected row the update was succesful. If there are no affected rows it means that someone else updated this row in the meantime (thereby incrementing oca) and you can show a message like: Since the start of your editing process someone else updated this record set. Please cancel and edit the record again. This way you will never lock out a record set forever like Miles wrote and the user will at least be able to open the record set and see all data - even if sometimes (should be very seldom) he has to cancel and start again. I hope you get my point - it's a bit difficult to explain. Best regards, Torsten Roehr -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Good books on sql / mysql
Interesting v. practical absolutely great ... Joe Celko SQL for Smarties :Advanced SQL Programming ISBN 1-55860-323-9 (or almost anything by him on SQL.) A little more basic Bowman, Emerson DarnovskyThe Practical SQL Handbook ISBN 0-201-44787-8 I don't know whether these are still in print; they are both v. good and quite product-neutral references. Joe Celko also had a web site with a collection of articles he'd written for various magazines, don't know if it's still up.. Regards - Miles Thompson At 08:46 PM 8/10/2004, Ross Honniball wrote: Anyone recommend any really good books for beginner/intermediate using sql hoping to improve sql skills? . . Ross Honniball. JCU Bookshop Cairns, Qld, Australia. . -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Exporting Data From MySQL Using PHP
Yep - lots of tutorials out there, some even on the php.net! Hint, try the Getting Help link, then look for samples/tutorials. So, do what the rest of us have done educate yourself, play a bit, find out how things work what they look like when they break. Then you're ready to ask questions, but this one you'll have dealt with by then. Regards - Miles Thompson At 11:01 PM 8/6/2004, Ron Piggott wrote: I have created a MySQL database. The table I am creating is a subscriptions database. I want to be able to export all e-mail addresses stored in the e_mail column into a plain text file on the web server (1 e-mail address per row) where the discipleship_mailing_list_e_mail_subscription equals on. I am new at PHP and I am not sure how to do this yet. My idea is that the user would click an UPDATE button and this action would be performed. Are any of you able to help me with this? 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
RE: [PHP-DB] SQL Insert problem
1. echo your $sql to make certain it's as sound as you think. 2. i don't see execution of the query: mysql_query( $sql) - you'll have to put the die() error after this function. Hth - mthompson At 12:05 PM 8/5/2004, Vincent Jordan wrote: I have inserted '$address2', correctly in the row however it is still not putting the data in the table. I am not getting an error but I do believe I have correct syntax set to display problems. -Original Message- From: Hutchins, Richard [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 10:26 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] SQL Insert problem You're missing address2 in your list of values. This means that you have an unmatching number of column names and values in your query and that'll make the query bomb. Rich -Original Message- From: Vincent Jordan [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 10:25 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] SQL Insert problem Im having a problem inserting data. Ive looked over this again and again and can not find what ive missed. Everything else works besides the db insert. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; ?php ini_set ('display_errors', 1); error_reporting (E_ALL ~E_NOTICE); // Define $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $phone = $_POST['phone']; $email = $_POST['email']; $serial = $_POST['serial']; $product = $_POST['product']; $reason = $_POST['reason']; $gold = $_POST['gold_button_y']; $goldaccount = $_POST['goldaccount']; $rmanumber = $lastname{0}.date(ndyGi); $connect = mysql_connect(SERVER , USER, PASSWORD) or die (mysql_error()); $select = mysql_select_db (spdata) or die (mysql_error()); $sql = INSERT INTO rmarequest (firstname, lastname, address, address2, city, state, zip, phone, email, serial, product, reason, rmanumber)VALUES ('$firstname', '$lastname', '$address', '$city', '$state', '$zip', '$phone', '$email', '$serial', '$product', '$reason', '$rmanumber') or die (mysql_error()); if (isset($_POST['submit'])) { $sql; } // Send and put in email message $htmlheader = Content-Type: text/html; charset=us-ascii\n; $htmlheader .= Content-Transfer-Encoding: 7bit; $header = $from; // set the from field in the header $header .= \n; // add a line feed $header .= MIME-version: 1.0\n; //add the mime-version header $header .= $htmlheader.\n; $from = From: RMA Request [EMAIL PROTECTED]; $message = $firstname $lastname $address $address2 $city $state $zip $phone $email $product $serial $gold $goldaccount $reason $rmanumber; // Send email to support mail([EMAIL PROTECTED], RMA Request, $message, $header); ? html xmlns=http://www.w3.org/1999/xhtml; head titleUntitled Document/title /head body pstrongRMA Request Sent/strong/p pYour RMA Number is strong ? echo $rmanumber ? /strong /p pPlease include a note within your package with your shipping address, phone number and discription of the problem.br /When shipping Smart Parts reccomends insuring your package for the full replacment cost. We also advise purchasing tracking services if using the postal service./p pstrongShip your return to: /strong/p pSmart Parts, Incbr / ATTN ? echo $rmanumber ?br / Loyanhanna Business Complexbr / 100 Station St.br / Loyalhanna Pa. 15661/p pbr / Please allow up to one week for package delivery. For status information please call 800-992-2147 and ask for the returns department./p a href=# onClick=window.print();Click Here to print this page/abr / a href=form.htmClick here to return to RMA Request form/a /body /html -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Restrict account access to single user
They are all good suggestions, Tim's is probably the most sophisticated, but it's inevitable that usernames and passwords will escape. On top of this I'd add a weekly count of user logins, so that the users in effect buy a given amount of accesses each week. If you're really serious, you will have to be somewhat brutal with your users - change the password, make it a difficult to remember combination, and do it often enough that they know you mean business. We've been fighting with this for four years, and there's no perfect solution. If it's a site where you are distributing published materials (.pdf's) you may take a good look at what Adobe calls, or used to call, Web Merchant, bite the bullet on the licensing and royalty fees, and reconcile yourself to a Windows / IIS solution. Cheers - Miles Thompson At 02:23 PM 7/15/2004, Tim Van Wassenhove wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: Because this is a revenue-based site, and users buy a password for access, we're wondering what the best php/mysql mechanism would be to allow only one person to access their account at a time. In other words, how do we prevent two users from using the same password to access the same account at the same time? If a user logs in: store the login timestamp in the database store the uid and timestamp in a session variable. If a user requests a page: compare the uid and timestamp in the session with the ones in the database. This way: Every user that tries to login with a valid uid/pwd gets access. Every session with the same uid but older timestamp expires. Don't applaud, just throw money :D -- Tim Van Wassenhove http://home.mysth.be/~timvw -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Best table structure
Tom, For a start, this is off-topic, and you also cross-posted - please don't do so. Have a look at this article: http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html I prefer simpler tables, so I would use the structure you have suggested, with the possible addition of a date field and a field to indicate the source of the ranking. With the proper use of indexes, the fetching of results is extremely fast; you don't have to worry about table size. Figure out the questions you have to ask of the information, and then decide what inputs you need to answer them. Regards - Miles Thompson At 07:53 AM 6/30/2004, Tom Chubb wrote: Please can someone let me know their opinion on the following: I have written some code for submitting a top 20 music chart online. I use the following to insert into mysql: INSERT INTO chart (name, chartpos, artist, title, label) VALUES ('$name', '1', '$artist', '$title', '$label'), ('$name', '2', '$artist2', '$title2', '$label2'), ('$name', '3', '$artist3', '$title3', '$label3'), -- repeat til - ('$name', '20', '$artist20', '$title20', '$label20'), Another page queries the table and sorts by name (multiple people submit charts) and latest date. My question is this: Would I be better keeping this format and inserting multiple rows on each submit, or to have one row for all 81 variables ($name, 20 x Position, 20 x Artists, 20 x Titles, 20 x Labels.) I know that the latter will be easier to query. Also, without maintenance, the size of the table for the current method will get extremely large. Will that affect server performance? I am still a newbie, so plain explanations would be most appreciated. Thanks very much in advance. Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Using Cursors
At 11:12 AM 6/1/2004, Gerard Samuel wrote: A bit off topic, but lately I've been running into situations, where I have to know about using cursors with databases, like sql server, ibm db2 Can anyone point me to online resources that explains (to a practical newbie) cursors Thanks Gerard, Think of it as a scrollable result set on which you can do row by row processing. I've not worked with SQL Server for sometime, but my dusty copy of SQL Server 6 Unleashed (SAMS) advises as follows on pp 186-187: ANSI-SQL provides the capability of addressing a set of rows individually, one row at a time, by a cursor. A cursor is a pointer that identifies a specific working row within a set. ... ... Before looking at how to use a cursor, you need to understand what cursors can do for your application. Most SQL operations are set operations: a where clause defines the set of rows to address and the rest of the statement provides definitive instructions on what to do with the rows. This NOTE follows: NOTE It's extremely difficult to come up with compelling examples ff cursor programming. The problem is that cursors introduce a fantastic performance problem ... and nearly always need to be avoided. Maybe cursor performance has been improved since then. I suppose the $result we refer to when processing the results of a MySQL query is a cursor as it is possible to reposition within it. Regards - Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Remove white space?
1. Don't cross-post! 2. Read the string functions in the php manual. You probably don't want to remove all white space, just trim. Have a look at http://ca3.php.net/manual/en/function.trim.php 3. You will find a function to do exactly what you want. Regards - Miles Thompson At 10:51 AM 4/22/2004 -0400, Robert Sossomon wrote: I am pulling data from a MySQL DB and I need to remove the whitespace on the variable and turn it to lowercase. ! Code Snippet $get_items = select * from PFS_items; $get_items_res = mysql_query($get_items) or die(mysql_error()); while ($items = mysql_fetch_array($get_items_res)) { $item_id = $items[id]; $item_num = $items[item_num]; ! End Code Snippet Overtime I need to rewrite my DB loading script to handle this for me, but right now I need to band-aid it so that I can auto-generate pages and get them loaded into a catalog. Thanks! Robert -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mssql insert
$query = INSERT INTO myTable VALUES ('.$myVar.');'; Check the commas? Miles At 05:50 PM 3/28/2004 +1200, Martin Ryan wrote: Got a dumb-ass question for you all. I have got insert queries working with mssql_query($query); except if any of the variables have two or more words. For example: $myVar = Two or more words; $query = INSERT INTO myTable VALUES ('.$myVar.');'; mssql_query($query,$db); The query will only insert Two. I know the query is correct, because I've echoed it, cut it, and pasted it directly into Query Analyzer and it comes up roses. Cheers muchly, Marty -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Impact of MySQL Queries
Think of bandwidth as the volume of data returned by the web server to the browser, not machine cycles. MySQL will use machine cycles, but there's more to it than that. For fastest response the fields you are running the query against should be indexed. What pushes you to 20 queries per page? That seems a little excessive, as each of those is a hit to the database. Are the fields indexed? Are they cascading queries, the second depending on results returned by the first, the third upon the second, and so forth? Could you handle your returned result set by getting more data and grouping it? More information is needed to answer your question properly. Regards - Miles Thompson At 11:16 AM 3/11/2004 -0800, Marcjon Louwersheimer wrote: I have IIS 4.x and MySQL running on the same machine. So do queries use up bandwidth? Does it matter if I have 20 queries per page? Will that slow it down if many people started using my site? Currently only I, and some friends for testing, use it. -- Marcjon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Sending variables to Flash from php
At 08:59 PM 3/3/2004 +, Donovan Hutchinson wrote: Hi, I'm working on a simple bit of flash that should display some text passed into it from PHP. I'm using the FlashVars as following (trimmed for brevity): object ... PARAM NAME=FlashVars VALUE=name=?php echo $firstname.'+'.$lastname; ? embed src=images/intro.swf quality=high FlashVars=name=?php echo $firstname.'+'.$lastname; ?... ../object In flash, i've set up a dynamic text block called nametext, and added the following actionscript to the frame: nametext = name; I'm sure that should be setting the variable, but I can't seem to get it to work. Any suggestions appreciated :) Donovan Hutchinson Donovan, Have you tried refreshing the page with a Ctrl+R? Flash can be so dumb some times; try calling both the dynamic text block and the var nametext. You many have to declare the var in the first frame as a global. Does it work if you use a literal value, i.e. try without the PHP echo, just use Donovan Hutchinson. What does the page's source look like? Nothing definitive here, I'm afraid, and maybe you've done all that. Good luck - Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Cookies ?
Did you refresh the page after setting the cookie? mt At 05:00 PM 2/9/2004 -0800, Omelin Morelos wrote: I have already tried it , It's not working. Thanks -Mensaje original- De: Chris Wright [mailto:[EMAIL PROTECTED] Enviado el: Monday, February 09, 2004 5:09 PM Para: Omelin Morelos; [EMAIL PROTECTED] Asunto: Re: [PHP-DB] Cookies ? Try using $_COOKIE['cookie_name'] - Original Message - From: Omelin Morelos [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 10, 2004 12:55 AM Subject: [PHP-DB] Cookies ? Friends Is there a way to read a cookie's with php , that were generated with javascript ? I am now usign : $xidp=$_COOKIE; print Xidp $xidp; Thank you for your help in advanced. -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_connect problem
At 03:42 PM 2/2/2004 +0100, DiZEM PGC wrote: I try connecting to an existing mysql DB. The first time I directly called mysql_connect with all required params (Path/Database,User,Password) and established a connection without problems. Second time I have used a script that includes a self-written class containing a few Database functions. One of these functions, named 'db_login', does exactly the same as mysql_connect (w. the same params). First case (directly calling) works fine. The second case doesn't report any error and doesn't establish a connection. What could be the reason for this strange behavior ? DiZEM promo crap snipped Echo the mysql_error and mysql_errno as found here: http://www.php.ca/mysql_error Also echo the connect string so you can see exactly what's being sent. I'd bet on a misplaced quotation mark. Cheers - Miles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] getting font size from browser
PHP is SERVER side, not browser side. That's a Javascript question. Miles At 11:14 AM 1/30/2004 +0100, Roy G. Vervoort wrote: Is it possible to retreive the font size or view size from the browser. In the browser it is possible to change the screenview (make it larger or smaller for people with a visual aid). I would like to ineract my stylesheet with these default settings. thans Roy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP/DB speed
At 03:15 PM 12/21/2003 -0700, Robin Kopetzky wrote: Good afternoon! I am writing a project and have a speed concern... The code I am using is thus and is retrieving around 2,500 records: $result = mysql_query($sql) while ($row = mysql_fetch_array($result)) { build OPTION stmt } Is there a faster method? Timed this with microtime and .9 seconds to retrieve the data and output the web page seems REAL slow. Now this is on a T-Base-100 network but I imagine it would be like watching paint dry in a 56K modem. Any thoughts, ideas on accelerating this? I did try ob_start() and ob_end_flush() and no help... Thank for any help in advance. Robin 'Sparky' Kopetzky Black Mesa Computers/Internet Service Grants, NM 87020 Robin, That's a huge option list. Just from the point of view of the user it is too large. Is there any way you can pare it down? MySQL will select those records really quickly, but then the HTML has to be generated and the broser has to render the list. Try and rethink this if you can. Regards - Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] User defined function in a mysql query
1. Is the function allowed by MySQL? 2. Can you execute the function before the query, assign what it returns to a var, then place the var in your query? Miles At 04:43 PM 12/10/2003 +0100, antonio bernabei wrote: Hi, I need to make a join between two tables. And I can use the mysql_query function: this is ok. The problem arises because I need to apply a user defined function to a field of one of the two tables and the rule for the join is WHERE table1.filed1=function(table2.field2). But I receive a lot of errors: it seems like is not allowed to put such a function in the text of the query. Or there is a possibility? Thanks Antonio Bernabei -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] transaction locking
Aleks, Many programmers learned the hard way that the scheme you are proposing did not work when they went from a single user to a networked environment. You've not said what database you are using. If MySQL you can let it's autoincrement increase your key automatically, perhaps feed it back as confirmation of completion. Using this you will not get duplicates as the insert is unique per connection. Check the MySQL docs for the last insert id. Try this - it works and takes a load off your code. Alternately, if you want to use your own scheme, establish a lookup table with two fields: keyvalue and tablename. Write a function that with the table name as a parameter, locks the table, retrieves the keyvalue, adds one to it, updates and exits. You will have to test for locks, you may end up with gaps in your key numbers. If possible, let the database do the work for you. Regards - Miles Thompson At 06:11 AM 12/5/2003 -0700, Aleks Kalynovych wrote: Good morning all, I have a couple forms that generate a unique ID based on taking the highest number in the ID column adding 1 to its value. The problem is that I don’t save that number until the form is submitted. If 2 or more persons fill out the form at the same time they all get the same ID number. I hope that there are some suggestions on how to accomplish this with a better method TIA for your help Aleks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] transaction locking
Aleks, Every time I've dumped and moved a database with autoincrement fields the numbering has picked up where it left off. Dump the database, including the data, adjust the field type in the database schema, and reload. Regards - Miles At 09:36 AM 12/5/2003 -0500, Aleks K wrote: Thanks Miles and John for you answers... Yes I am using MySQL. I think I can work it to use the dB to generate these. I ran into The problem originally because this dB was taking up where a different Tool was ending and I needed to start with a specific number scheme. Here Is a though... If I have a field in MySQL that had numbers already populated Along with an auto incremental column... Can I remove this auto column and Change the properties of the already populated column to auto generate? Will It accept the numbers already there or will I have to start from scratch? In other words I know that in the dB if you setup a new table and set a column\ To auto increment, it starts a the number 1. Can this be set to a higher number Say 5454 ?? TIA Aleks -Original Message- From: Miles Thompson [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 8:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] transaction locking Aleks, Many programmers learned the hard way that the scheme you are proposing did not work when they went from a single user to a networked environment. You've not said what database you are using. If MySQL you can let it's autoincrement increase your key automatically, perhaps feed it back as confirmation of completion. Using this you will not get duplicates as the insert is unique per connection. Check the MySQL docs for the last insert id. Try this - it works and takes a load off your code. Alternately, if you want to use your own scheme, establish a lookup table with two fields: keyvalue and tablename. Write a function that with the table name as a parameter, locks the table, retrieves the keyvalue, adds one to it, updates and exits. You will have to test for locks, you may end up with gaps in your key numbers. If possible, let the database do the work for you. Regards - Miles Thompson At 06:11 AM 12/5/2003 -0700, Aleks Kalynovych wrote: Good morning all, I have a couple forms that generate a unique ID based on taking the highest number in the ID column adding 1 to its value. The problem is that I don’t save that number until the form is submitted. If 2 or more persons fill out the form at the same time they all get the same ID number. I hope that there are some suggestions on how to accomplish this with a better method TIA for your help Aleks -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Updating multilple tables?
If you are searching in the same field (column) in each table, and the key field has the same name in all tables, build an array of table names and loop through it, executing your update on each iteration. Regards - Miles Thompson PS From your description it sounds as if you have a database design problem - common blocks of text are normally stored in some type of lookup table. At 02:31 PM 11/27/2003 +, [EMAIL PROTECTED] wrote: I have scattered around about 100 tables a block of text... I wasn to serach through ALL my tables, and ALL my rows for this text, adn repalce it with another block of text. I've searched n google for mysql multiple table update But have yet to find an answer.. anyone know an easy way to do this? All the tables are on the same database, so I just need to say, search ALL tables within database Tris...? long conditional snipped -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] 'while' not picking up on first DB record
Please don't cross-post. See below - M. At 10:17 AM 9/17/2003 -0400, Roger Spears wrote: Hello, Can anyone from the lists please tell me why this bit of code is not picking up on the first record in the database? If the 'id' I'm looking for is '1' it doesn't populate the _SESSION variables. Any 'id' greater then '1' will populate the _SESSION variables. $q = SELECT * FROM employee; $r = mysql_query($q); You're picking up first line here, but doing nothing with it. $row = mysql_fetch_array($r); So delete it or comment it out. while ($row = mysql_fetch_array($r)) { if ($employee == $row[id]) { $_SESSION['dear'] = $row[last_name]; $_SESSION['to_email'] = $row[email]; } } Thanks, Roger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] What happens when the database is down?
C'mon, think about it. Connect to the database at the top of your page - if you can't connect either error out and die, or branch to alternate output. As far as lack of error reporting is concerned, check and see what level of error reporting is set on the server; the manual has a helpful section on this as well as how to set up and configure .htacess if your ISP has all error reporting turned off. If you are running locally, you can adjust the level of error reporting. There are lots of examples in the PHP manual. Couple of things: I know PHP and Apache 2 are not a recommended combination on LInux, you may be better off with 1.3.x. Aren't you also running a beta or rc version of MySQL - stable is still 3.x, isn't it? You may have two alternate sources of breakage there. Cheers - Miles Thompson At 12:00 AM 7/20/2003 +1000, Hanxue Lee wrote: Hi, I am using PHP 4.3.1, Apache 2.0.46 and MySQL 4.0.12 on Windows 2000 Processional Edition. All the code are working fine, with only one exception. When I shut down the database, the PHP script will continue running normally until it reaches the part where information is retrieved from the database. Then, the HTML output just hangs there. No error, nothing. How can I detect this type of error? Any way I can set some timeout limit, etc? Thank you in advance. Yours truly, Hanxue -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Undefined Index error when trying to insert data from a form into a db
1. Check the manual on use of $_POST and notch down your error reporting level. As these vars have not been defined PHP is throwing an error. 2. While you are at it, and assuming that your variables are all received correctly, why not simplify your sql? insert into test_scores set field_one = '$field_one', field_two = ''$field_two ... and so forth. It makes debugging INFINITELY easier and gives you more control. 3. Not related to your question at all, what's the type of your first field? Does it allow NULL's? If so then default it to NULL. (Something tugging at the back of my mind says that a NULL should not be assignable, but that's another issue.) HTH - Mlies Thompson At 12:53 PM 6/26/2003 -0400, Christopher McCourt wrote: Hello to all: I am getting the following error message when trying to insert data from an html form into a MYSQL database that I recently created. Can someone take a look at the errors and corresponding code and suggest some alternatives? Thank you very much in advance for your assistance. Regards, Chris McCourt Error Message: Notice: Undefined index: Store_ID in c:\program files\apache group\apache\htdocs\insertdata.php on line 9 Notice: Undefined index: Postal_Code in c:\program files\apache group\apache\htdocs\insertdata.php on line 14 Notice: Undefined index: Cert_Org in c:\program files\apache group\apache\htdocs\insertdata.php on line 17 Notice: Undefined index: Cert_Level_ID in c:\program files\apache group\apache\htdocs\insertdata.php on line 18 Notice: Undefined index: Cert_Date in c:\program files\apache group\apache\htdocs\insertdata.php on line 19 Notice: Undefined index: Emerg_Contact_Name in c:\program files\apache group\apache\htdocs\insertdata.php on line 20 Notice: Undefined index: Emerg_Contact_Phone in c:\program files\apache group\apache\htdocs\insertdata.php on line 21 Error: Unable to execute insertion query. +++ Original PHP Code: ?php /* This page receives and handles the data generated by the form Insert_Table_Form.html*/ $Store = ($_POST['Store_ID']); $Users = ($_POST['User_Name']); $Pass = ($_POST['Password']); $Addr = ($_POST['Address']); $State = ($_POST['State']); $Post = ($_POST['Postal_Code']); $Phone = ($_POST['Phone']); $Email = ($_POST['EMail']); $Certor = ($_POST['Cert_Org']); $Certl = ($_POST['Cert_Level_ID']); $Certd = ($_POST['Cert_Date']); $Emergn = ($_POST['Emerg_Contact_Name']); $Emergp = ($_POST['Emerg_Contact_Phone']); //Set the variables for the database access: $Host = localhost; $User = root; $Password = ; $Link = mysql_connect($Host, $User, $Password) or die(Could not connect: . mysql_error()); mysql_select_db('dive_store') or die(could not select database); $sql = mysql_query(INSERT INTO test_scores VALUES (NULL, '$Store', '$Users', '$Pass', '$Addr', '$State', '$Post', '$Phone', '$Email', '$Certor', '$Certd', '$Certl', '$Emergn', '$Emergp')) or die('Error: Unable to execute insertion query.'); $Result = mysql_query($sql)or die(mysql_error()); if ($Result){ echo(Table Created successfully); }else{ echo(error when creating table); } mysql_close($Link); ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Accessing MySql using Flash while using PHP as the middleware
Adam made a good suggestion - but using LoadVars is better, and if you are retrieving text it's easier to bring it back as an xml file, otherwise an ampersand stops you cold. Here's my call to the login script to authenticate users for a news site when the login button is clicked. The varSender and varReceiver are recommended by Colin Moock to avoid caching. His ActionScript for Flash MX The Definitive Guide, O'Reilly, ISBN 0-596-00396-X is worth every penny. Also visit www.moock.org Values in first_txt.text, last_txt.text, and pass_txt.text come from those text boxes. The variable host is retrieved from a settings.as file in the first frame of the movie. ckval is stored in a shared object so that subsequent logins are automatic. autologin = true is the key which unlocks the rest of the movie read is the frame where another script loads the day's news stories, also stored in a MySQL database. frame 7 is for login failed - when I added it I had no space to name it. So, what does the php script return? Exactly this, with no leading space or empty line, and on one line: ValidLogin=trueckval=some32bitkeyiwonttypeout (I was tearing my hair out - everything looked RIGHT, yet the movie kept failing, dumbly. Then I realized there was a blank like ahead of the returned values. Removed it and magic happened.) Flash is alternately exasperating and wonderful. HTH - Miles --- flash code calling PHP script function onLogin(){ if(first_txt.length 0 last_txt.length 0 pass_txt.length 0) { varSender = new LoadVars(); varReceiver = new LoadVars(); varSender.first_name = first_txt.text; varSender.last_name = last_txt.text; varSender.password = pass_txt.text; varSender.action = 'login'; varSender.sendAndLoad(http://+ host + user_logon.php, varReceiver, 'GET'); varReceiver.onLoad = function() { if(!this.error this.CkVal != ){ subs_so.data.ckVal = this.CkVal; } if(!this.error this.ValidLogin == true) { _root.ValidLogin = this.ValidLogin; _root.gotoAndStop('read'); } else { _root.gotoAndStop(7); } first_txt.selectable = true; last_txt.selectable = true; pass_txt.selectable = true; loginButton.enabled = true; } } } //end of function onLogin end of Flash code --- At 05:15 PM 6/25/2003 +0200, Ron Allen wrote: Does anybody have an idea how-to use Flash and PHP to access a MySql database. I know how to use PHP and mysql with no problem to pull info, but with Flash I am struggling. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Apache to compile PHP and Ruby languages in the same document?
Don't know, but it doesn't make sense to me -- Apache executes scripts based on the file extension, how can it process both languages? A possible work around would be to have the Ruby program exec()'d within PHP. Alternately, do Ruby pages, but embed PHP as PHP is presently embedded in HTML with opening closing tags. How you tell Ruby to exec the PHP I don't know. Miles At 12:19 PM 6/11/2003 -0500, you wrote: Hello, I'm trying to create one document with PHP and Ruby scripts in the same document. Is this possible? I've tried to configure mod_ruby to compile php documents as well but when I do that PHP doesn't work. Is it possible to have 2 languages in the same document? -- Keith -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Apache to compile PHP and Ruby languages in the same document?
Yes, I understand about PHP, and I would assume Ruby also executes on the server - thus you would have primarily one or the other generating the page. I don't see how both can execute simultaneously, without one of them calling the other. Miles At 02:15 PM 6/11/2003 -0400, John R Wunderly wrote: At 02:56 PM 6/11/2003 -0300, Miles Thompson wrote: Don't know, but it doesn't make sense to me -- Apache executes scripts based on the file extension, how can it process both languages? A possible work around would be to have the Ruby program exec()'d within PHP. Alternately, do Ruby pages, but embed PHP as PHP is presently embedded in HTML with opening closing tags. How you tell Ruby to exec the PHP I don't know. The PHP is executed on the server before the HTML is sent to the browser. A possible difficulty is if the PHP is being executed in *SAFE* mode. Miles At 12:19 PM 6/11/2003 -0500, you wrote: Hello, I'm trying to create one document with PHP and Ruby scripts in the same document. Is this possible? I've tried to configure mod_ruby to compile php documents as well but when I do that PHP doesn't work. Is it possible to have 2 languages in the same document? -- Keith -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] while - if problem
The closing else is not bracketed. Have you echoed the vars confirmed values therein? It's amazing how often that will catch you. Otherwise simplicate: comment out a bunch of stuff and build it up bit by bit, echoing all the while. Miles Thompson At 02:07 PM 6/4/2003 -0600, Earl wrote: Sorry about that I did not get the closing tag when i copied the code. I did as you said and it still gave the same problem. below is the complete code $eventQuery=ifx_query('select * from event' .' where e_date = today ' .' and e_status in (O,C) ' .' and out_id is not null ' .' order by s_acro, e_acro ',$db) or die (ifx_error()); while($cols=ifx_fetch_row($eventQuery)) { if ($cols['out_type']=='0') { $r_away['linetype']='L'; $r_home['linetype']='L'; } elseif ($cols['out_type']=='1') { $r_away['linetype']='H'; $r_home['linetype']='H'; } if (($cols['s_acro']=='CF') || ($cols[s_acro]=='PF')) { $r_away['sport']='1'; $r_home['sport']='1'; $s_lt='PS'; $t_lt='TP'; } elseif (($cols['s_acro']=='PB') || ($cols['s_acro']=='CB')) { $r_away['sport']='2'; $r_home['sport']='2'; $s_lt='PS'; $t_lt='TP'; } elseif ($cols['s_acro']=='B') { $r_away['sport']='3'; $r_home['sport']='3'; $s_lt='ML'; $t_lt='TM'; } else $r_away['sport']='4'; $r_home['sport']='4'; $s_lt='ML'; $t_lt='TM'; $r_away['rotation']=$cols['out_id']; $r_home['rotation']=($r_away['rotation'] + 1); echo .$r_away['rotation']. , .$r_home['rotation']. , .$r_away['linetype']. , .$r_home['linetype']. , .$r_away['sport']. , .$r_home['sport'].\n; } - - Original Message - From: Becoming Digital [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 1:52 PM Subject: Re: [PHP-DB] while - if problem You don't have a closing bracket on your while() loop and you should not have the else comments bracketed. Try this: while($cols=ifx_fetch_row($eventQuery)) { if (($cols['s_acro']=='CF') || ($cols[s_acro]=='PF')) { $r_away['sport']='1'; $r_home['sport']='1'; $s_lt='PS'; $t_lt='TP'; } elseif (($cols['s_acro']=='PB') || ($cols['s_acro']=='CB')) { $r_away['sport']='2'; $r_home['sport']='2'; $s_lt='PS'; $t_lt='TP'; } elseif ($cols['s_acro']=='B') { $r_away['sport']='3'; $r_home['sport']='3'; $s_lt='ML'; $t_lt='TM'; } else $r_away['sport']='4'; $r_home['sport']='4'; $s_lt='ML'; $t_lt='TM'; } Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: Earl [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Wednesday, 04 June, 2003 15:44 Subject: [PHP-DB] while - if problem Hey guys, I've got a problem with this piece of code it is skipping the contents of the if and elseif statements and only printing the else values, even though the if or one of the elseif statements might be true. what could possibly be the problem?? -- -- $eventQuery=ifx_query('select * from eventtable' .' where e_date = today ' .' and e_status in (O,C) ' .' and out_id is not null ' .' order by s_acro, e_acro ',$db) or die (ifx_error()); while($cols=ifx_fetch_row($eventQuery)) { if (($cols['s_acro']=='CF') || ($cols[s_acro]=='PF')) { $r_away['sport']='1'; $r_home['sport']='1'; $s_lt='PS'; $t_lt='TP'; } elseif (($cols['s_acro']=='PB') || ($cols['s_acro']=='CB')) { $r_away['sport']='2'; $r_home['sport']='2'; $s_lt='PS'; $t_lt='TP'; } elseif ($cols['s_acro']=='B') { $r_away['sport']='3'; $r_home['sport']='3'; $s_lt='ML'; $t_lt='TM'; } else { $r_away['sport']='4'; $r_home['sport']='4'; $s_lt='ML'; $t_lt='TM'; } -- -- output is always: 4, ML, TM thanks in advance -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] address info, forms, maintanance
Chip, Given that you have duplicate entries, then one field, or a combination of several fields, will probably be unique. Before adding a record execute a SELECT, using the values from the form against that combination. If the number of records returned is greater than 0, then execute an UPDATE query, otherwise an INSERT. Now, that information is so vague to be almost useless, for it begs a number of other questions, such as How many questions are end users allowed to ask? How are questions flagged for expiration or completion/solution? What kind of mix of questions do you allow? Cookies only store a bit of information on the user's browser. There's nothing magic about them - google for netscape cookies. I don't think they'd be much help to you here. HTH - Miles Thompson At 01:13 PM 6/4/2003 -0700, [EMAIL PROTECTED] wrote: I need to modify some company web pages that include a form for asking the company departments questions, such as service dept, etc. As the forms are currently built there is some field validation but no cookies. This info is saved in a mysql database, problem is, there are duplicate entries, every time an end-user posts a question. What kind of code do I need to add to these existing pages to prevent duplicate entries in the database? (Manually scanning through and deleting dupes is a real drag.) And what about cookies? Could I make use of these on these pages? I haven't worked with cookies yet, so am not sure where to start with that part. Thanks, -- Chip -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] address info, forms, maintanance
Chip, What's the database being used for then, if not to store and track questions and replies? If only as a repository of addresses that 's rather useless. Unless you want to track the frequency of user's questions, then you could update a counter field for their email address. If you've not gone down the road too far with this, there are some help desk type PHP solutions out there. Miles At 01:30 PM 6/4/2003 -0700, [EMAIL PROTECTED] wrote: Dan Brunner [EMAIL PROTECTED] wrote on 06/04/2003 01:24:13 PM: Hello!! Are talking about the same Post Question??? On another words, what is being duplicated?? If not, you can use auto_increment. Dan This pertains to every time a person visits the page and fills in the form - today, tommorrow, next week, next month, whenever. The address info is being written to the database each time they send the form. The message body itself isn't saved to the database, only the name and address info. -- Chip On Wednesday, June 4, 2003, at 03:13 PM, [EMAIL PROTECTED] wrote: I need to modify some company web pages that include a form for asking the company departments questions, such as service dept, etc. As the forms are currently built there is some field validation but no cookies. This info is saved in a mysql database, problem is, there are duplicate entries, every time an end-user posts a question. What kind of code do I need to add to these existing pages to prevent duplicate entries in the database? (Manually scanning through and deleting dupes is a real drag.) And what about cookies? Could I make use of these on these pages? I haven't worked with cookies yet, so am not sure where to start with that part. Thanks, -- Chip -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] newsletter optimization help needed
I've been doing that with a much smaller list, and we periodically run into problems with subscribers SPAM filter, double-propagation of some addresses, etc. I think the days of bcc: are numbered. The approach we're working on now is to send an URL to subscribers. They click on that and view the newsletter through Flash player. As for Chris's problem, I don't know. I'd be tempted to have the PHP script pass a set of parameters to a Python script and then end. When the Python script completes have that email the results to the user. A friend of mine used a similar process to handle requests for huge amounts of geological data. The parameters were passed to the database which generated the file and called a script to mail them. The original page was long since gone. Miles At 09:56 AM 3/12/2003 -0800, SELPH,JASON (HP-Richardson,ex1) wrote: You could change the TO: to something generic like Email List Subscriber then add everyone to the BCC field and then generate 1 email with 9000 people in the BCC field. Let sendmail do the rest. It should take less time to send the emails and only a few seconds to generate your page. Cheers Jason -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 11:41 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] newsletter optimization help needed Hi there Everyone, Below is some code I use to send a newsletter to clients subscribed on my mailing list. The problem is I have over 9000+ email addresses in the DB and it takes around 30-45 minutes to send them with the below code. Can anyone see someway I can optimize it so it sends out the newsletter any faster? I've probably gone about this system the long way, but it works - I just need to find a way to make it faster :-( Thanks everyone All the best Chris --- ? $connection = mysql_connect(localhost,Username,Password) or die(Couldn't make a connection.); $db = mysql_select_db(WhateverDB, $connection) or die(Couldn't select database.); $sql = SELECT * FROM emailtest; $sql_result = mysql_query($sql,$connection) or die(Couldn't execute query.); while ($row = mysql_fetch_array($sql_result)) { $emailadd = $row[EMail]; $emailname = $row[emailname]; $emailphone = $row[emailphone]; $emailaddress = $row[emailaddress]; $MP = sendmail -t; $HT = htmlbody; $HT = /body/html; $subject = $subject; $NOTE = $emailtests; $NOTE = str_replace(*email*, $emailadd, $NOTE); $NOTE = str_replace(*name*, $emailname, $NOTE); $NOTE = str_replace(*phone*, $emailphone, $NOTE); $NOTE = str_replace(*address*, $emailaddress, $NOTE); $TO = $emailadd; $fd = popen($MP,w); fputs($fd,MIME-Version: 1.0\r\n); fputs($fd,Content-type: text/html; charset=iso-8859-1\r\n); fputs($fd, To: $TO\n); fputs($fd, From: [EMAIL PROTECTED]); fputs($fd, Subject: $subject\n); fputs($fd, X-Mailer: PHP3\n); fputs($fd, Email: $email\n); fputs($fd, $HT); fputs($fd, $NOTE); fputs($fd, $EHT); } pclose($fd); exit; mysql_free_result($sql_result); mysql_close($connection); ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] table relationship
Three tables seems wasteful, and could mean that you have to do three queries when looking for someone. Why not approach it this way. Users table - info on all users, regardless of category Levels table - sets different access levels, e.g. clients, staff, administrators User_levels table - assigns levels to user id's This would give you more long-term flexibility as you would only have to extend the levels table to add granularity of access or control levels. I'd also have a look at various network permission schemes, because there are subtleties that are not immediately apparent when working up an access scheme. Cheers - Miles Thompson At 09:35 AM 3/10/2003 +, shaun wrote: Hi, I am creating a web site which will have different types of users: Administrators, clients and staff. Is it possible/good practice to have 3 tables related to one table i.e. USER user_id (PK) | | | || | || AdministratorClient Staff admin_id(PK) client_id(PK) staff_id(PK) user_id(FK) user_id(FK)user_id(FK) Thanks in advance for any advice offered. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] VFP 6 via ODBC and data integrity questions
There's an alternate route, but I've used it only over a network, not across the internet. Create a keys table which has two fields - tablename and keyvalue. Create a Get_VFP_Key function with one parameter, the tablename, which returns the keyvalue for that table name. Get_VFP_Key gets a lock on the row containing the tablename, grabs the value, increments it according to whatever scheme you are using, writes the new value and releases the lock. A friend of mine used the ascii table and generated base 256 keys, rather an exceptional fellow. The problem I see here is latency and a locking problem. Alternately, if the machine you are hitting is running VFP, why not use its native sys(2015) (or 2017 - can't remember just now) to generate a random key. HTH - Miles Thompson BTW Character-based primary keys are quite common in the VFP world because FoxPro did not cleanly handle a mix of numeric and character fields in the WHERE portion of a SELECT. It wanted all character values, so don't be too hard on the morons. How are they handling the generation of primary keys? At 09:43 AM 2/3/2003 -0500, Brian Evans wrote: Good day all, I have just began work on a project to let users subscribe to a service and place orders into a database that is VFP 6 based. Using PHP4, I am able to interface with their program (that also uses ODBC locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT). My worries come when inserting a new user/order from the web. The morons who designed the database made the Primary Key as character and NULLable (once only of course), but I have to deal with that. My question is this... How can I know the new user I INSERT will be unique? (the field is character, but counts like a number field) This especially holds true since I have to deal with local users possibly adding at the exact same moment as PHP (ie. a racing issue). Can anyone tell me how to avoid problems? Would odbc_prepare() reserve a new key for me? Thanks. Brian PJC Services P.S. Kudos to all of the developers. This is a great job you guys are doing. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] VFP 6 via ODBC and data integrity questions
At 06:25 PM 2/3/2003 -0500, Brian Evans wrote: Currently they are using a VFP client app, the actual program is not installed. I just discovered that the suggestion you offered (about a key table) is being used by this client. Would the sys() function work through ODBC w/o the full VFP install? No, I wouldn't think so, it's a native VFP function. I'm wondering if you could clone something, by using rand(), seeded with the unix time and client's IP number. Don't take me too seriously, I'm just musing here. How do I lock the database through PHP and ODBC for a moment?? I cannot find any information on this. Probably you can't. but I'm wondering if you could SELECT the keyvalue you need, then immediately execute an update, setting keyvalue to keyvalue + 1, assuming it's numeric. What would that be like, something along the lines of update keys ( keyvalue), ( str( val(keyvalue) + ) ) where tablename = 'var_tablename' The val expression converts the existing keyvalue to a numeric which allows a numeric one to be added, returning that expression as a string. (Unless I have their functionality reversed, but I hope you get the idea.) With his you don't have to worry about the lock and the value will be appropriately updated. Again the question is what kind of functions can you use through ODBC; I've not ever had to work with it. HTH - Miles Thompson Thanks for your help. Brian PJC Services At 03:13 PM 2/3/2003, you wrote: There's an alternate route, but I've used it only over a network, not across the internet. Create a keys table which has two fields - tablename and keyvalue. Create a Get_VFP_Key function with one parameter, the tablename, which returns the keyvalue for that table name. Get_VFP_Key gets a lock on the row containing the tablename, grabs the value, increments it according to whatever scheme you are using, writes the new value and releases the lock. A friend of mine used the ascii table and generated base 256 keys, rather an exceptional fellow. The problem I see here is latency and a locking problem. Alternately, if the machine you are hitting is running VFP, why not use its native sys(2015) (or 2017 - can't remember just now) to generate a random key. HTH - Miles Thompson BTW Character-based primary keys are quite common in the VFP world because FoxPro did not cleanly handle a mix of numeric and character fields in the WHERE portion of a SELECT. It wanted all character values, so don't be too hard on the morons. How are they handling the generation of primary keys? At 09:43 AM 2/3/2003 -0500, Brian Evans wrote: Good day all, I have just began work on a project to let users subscribe to a service and place orders into a database that is VFP 6 based. Using PHP4, I am able to interface with their program (that also uses ODBC locally) in all aspects (INSERT, UPDATE, DELETE, and SELECT). My worries come when inserting a new user/order from the web. The morons who designed the database made the Primary Key as character and NULLable (once only of course), but I have to deal with that. My question is this... How can I know the new user I INSERT will be unique? (the field is character, but counts like a number field) This especially holds true since I have to deal with local users possibly adding at the exact same moment as PHP (ie. a racing issue). Can anyone tell me how to avoid problems? Would odbc_prepare() reserve a new key for me? Thanks. Brian PJC Services P.S. Kudos to all of the developers. This is a great job you guys are doing. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.449 / Virus Database: 251 - Release Date: 1/27/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Adding Record to database
Matt, Check a couple of things: 1. Do you have a primary key with unique id? You could be getting a key violation. 2. Echo $query and confirm that it is as you expect. 3. Add code to trap for, or at least display any generated error. 4. Are you able to test this INSERT at the MySQL console? If so, and it works, compare what works in 4. with what you have at 2. HTH -Miles At 08:41 PM 2/2/2003 -0500, Matt wrote: Hi. I am having a problem with adding a record into a table of a database. I have attached the code I am using to accomplish this. It works if the table is empty, but if there is already a record in the table, it won't add anything. Could anyone help me out with this? Here is the code I am using: $query = INSERT INTO TableName (SID,StudentLastName,StudentFirstName,StudentEmail,StudentLoginName,StudentP assword) VALUES ('$SID','$StudentLastName','$StudentFirstName','$StudentEmail','$StudentLogi nName','$StudentLoginPassword'); $results = mysql_query($query); Like I said, this works if the table is totally empty, but if there is already an entry in there, it does nothing. Please help if you can. Thanks. Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LEFT JOIN not working
For a start simplify the query, so that you are returning only one field until you get it right, say ads_displayrate.name. Second, echo the SQL statement so you can see what has been generated. Third, check the datatypes returned for YEAR(), MOTN() and DAYOFMONTH() functions in MySQL. As part of your diagnosis you may want to include the generated output from these functions so you see what they are returning. Fourth, if you have access to the MySQL console, try this interactively. HTH - Miles Thompson At 07:46 PM 1/14/2003 +0200, Lisi wrote: Still not working. I made the change, and I'm still getting all results. I even tried it without the leading '0' in front of the 1, no good. Here's my current query, with suggested changes: SELECT ads_displayrate.name, SUM(ads_displayrate.count) as display, SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name AND YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) = '01' AND DAYOFMONTH(ads_displayrate.date) = '05' GROUP BY ads_displayrate.name ORDER BY ads_displayrate.name ads_displayrate.date is a column of date type, so as far as I understand this should work. Is there some typo I'm missing? At 07:15 PM 1/9/03 +0100, you wrote: Oops! I missed again. If you specify conditions pertaining to the right-hand table, such as: ads_clickrate.date = '2001', Then you will lose all result rows for which the right-hand data is NULL. Not the expected result. So your restricting WHERE clauses must apply to the left-hand table only. Therefore: WHERE YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) = '01' (if your table ads_displayrate has such date fields). HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 6:54 PM Subject: Re: [PHP-DB] LEFT JOIN not working Cool! It's mostly working now, the only problem is it's ignoring the other clauses in the ON clause that select the desired date. Perhaps it's not supposed to be connected this way? How would I select specific dates? Thanks again, -Lisi At 01:20 PM 1/9/03 +0100, you wrote: Oops! Sorry, I missed it the first time. Your query should start as: SELECT ads_displayrate.name instead of SELECT ads_clickrate.name then you will always have a non-NULL name (coming from the table on the left of the LEFT JOIN). HTH Ignatius, from Brussels Where the fuck is Belgium? D. Ivester, CEO, Coca Cola - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 1:11 PM Subject: Re: [PHP-DB] LEFT JOIN not working Exactly my question - why does it not have a name? How would I modify my query to get a row with a name but null value for date? I thought the join would take care of this, but I'm obviously not doing it right. You mention a unique identifier, there is a separate table with a row for each ad, containing name, URL, and a unique ID number (autoincrement). Should this table be included somehow in the query? How would this help? Thanks, -Lisi At 12:45 PM 1/9/03 +0100, Ignatius Reilly wrote: Your 4th row ought to have an identifier of some sort. From your SELECT statement, this seems to be the name. Why does it not have a name? Probably what you want is a row with a name but a NULL value for ads_clickrate.date. (by the way it is EXTREMELY advisable to use an abstract identifier, such as an id, unique and required, instead of name) Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 12:18 PM Subject: Re: [PHP-DB] LEFT JOIN not working OK, this helped a bit. Now I have, in addition to the three rows of ads that have ben clicked on, a fourth row with no ad name, 0 clickthroughs, and 24 displays. That plus the other three account for all the displayed ads. However, since it is returning a null value for any ad name that has not been clicked on, and then it's grouped by ad name, it lumps all non-clicked ads into one row. What I need is to see each ad on a separate row, which is what I thought a LEFT JOIN was supposed to do. Any suggestions? Thanks, -Lisi At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote: problem 1: move the WHERE clauses to the ON clauses problem 2: Obviously your intent with COUNT(ads_clickrate.date) is to count the number of non-null occurences of click. But COUNT() is not the appropriate
Re: [PHP-DB] How to return records in _random_ order ???
I dunno - why does this topic pop up periodically. Anyway, here are two suggestions: 1. Add a field to the table, called rand_order. Whenever you update the table insert a random number in it and when fetching records order by Rand_order. 2. Generate an array of 20 random numbers and use it to index the returned records. Neither of these are though out -- sort of 1:00 in the morning inspiration? Why do you want them in random order? Cheers - Miles At 11:10 PM 12/16/2002 -0500, tmb wrote: I need to... 1 - Select a set of records from a db 2 - Return a list of one or two fields from the selected record set in random order on a web page. Once I have my selected records fields... say I end up with 20 records after my select query... How can I return the selected records in _random_ order ?? Hopefully I have made the question clear... thanks for any help. tmb -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] how to update a text BLOB in ODBC?
Jeff, Check your SQL. Shouldn't $sql = insert into note_tbl (note) values ('${note}') where pkey = '45'; be UPDATE where pkey = '45' ? Or, do a delete where pkey = '45' followed by an insert. In that case check the synatx of your insert 'cause it doesn't look correct. HTH - Miles Thompson At 04:42 PM 11/19/2002 -0800, Jeff Stern wrote: hi, i am having the devil of a time with this. have been researching it for 3 weeks. have posted to php.faqts.com (no answer), looked a million times on php.net, and www.borland.com/interbase, written people email (no response!) and even tried to get the people at easysoft to answer (they are working on it).. but it's been 3 weeks now and i cannot seem to get this question answered, and our project is waiting.. the question simply is: how to write a BLOB (sub-typwith ODBC in PHP? fyi, it shouldn't make a difference, but i am using interbase 6.0 as the back end, and the blob is SUB-TYPE 1 (text). *reading* the blob is trivial with php Unified ODBC. I just use a normal SQL select statement: == $sql = select note from note_tbl where pkey = '45'; # get result $result = @odbc_exec($conn, $sql); # assign values if ( @odbc_fetch_into($result, $row)) { $note = $row[0]; } == (where notes is the BLOB field). pretty simple. however, when i try to *write* it back: == $sql = insert into note_tbl (note) values ('${note}') where pkey = '45'; $result = odbc_exec($conn, $sql); == i get an error message: == Invalid modify request. Conversion error from string BLOB == .. so apparently i cannot simply write the string back out to the BLOB. (tho' IMHO if i can read in a SUB-TYPE 1 (text) BLOB that easily, then i should be able to write it back out that easily). apparently this is not just at the PHP Unified ODBC level.. if i run easysoft's isql program at the command prompt and try to run the same commands, while i don't get as specific an error message, it does return an error: == SQL update notes_tbl set note = 'hello there' where pkey = '16784' [ISQL]ERROR: Could not SQLExecute SQL _ == does anyone have some example code for how to do this (in PHP)? i'd be most grateful.. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Having more than one id in the same field
I can't remember CD's 12 rules regarding relational databases, but a rough paraphrase of one of them is that you do not need to know anything about how data is stored to manipulate it, the database schema should provide all that information. Another one is that you never repeat information that can be broken out and stored in another table. You have to normalize your data, so in this case you would add a field, call it EventHost with fields PriKey EventId RspOrg EventId is a foreign key, referencing the field in the Event table which identifies the event, and RspOrg is a foreign key which references the key values in the, lets call it Organization (or Host) table. (PriKey is the primary key for the table, a field which hard experience has convinced me to have in all database tables, though in this case it may not be needed.) Indexes on these fields will assure that your queries will be optimized and you won't be condemned to sequential reads of the database while fields are evaluated by expressions like ...where '$id' in (events.ids)... . The Event table no longer needs a RspOrg field, and you can determine additional information about the host organization or the event through this table. You may also add fields such as HostLevel which indicates whether the RspOrg is a primary or secondary host, and so forth. It's time to Google for a primer on SQL databases and normalization, work through a couple, and to ask yourself what kind of questions you will be asking of your database. Regards - Miles Thompson At 12:41 PM 11/10/2002 +0200, you wrote: Hi. I have a database designing question to ask. I want to build a table of events. Among the other fields there must be a field that holds the 'responsible organization' of the event. This organization of course will be responsible for other events as well so I have to create another table that holds the organizations (id, name, phones, director etc) and then just pull the organization id to the events table. The problem is that it happens too often to have 2 organizations responsible for the same event so I'll have to add them both to the events table in the same record. How do you advice me to do that? I thought that I could use a text field to hold the ids and then when searching the database just change the MySQL command from ...where events.id='$id'... (As it would be if only one id was going to be used) to ...where '$id' in (events.ids)... or maybe something using LIKE. Do you think it can be done this way? Apart from the responsible organization I may have other fields in the same table having the same problem (for example: the event visitors are staying in one hotel and I want to hold control of the hotels as well. Maybe 2 hotels are used instead of one). If I solve my problem this way, do you think that it will be too difficult or 'heavy' to have more than one condition like this in my queries? Do you think of any other way? Thanx in advance Achilles -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Structure Question...
Third choice, definitely. And aren't you glad your data is sufficiently normalized that this is a no-brainer! Cheers - Miles Thompson At 12:51 PM 11/7/2002 -0600, Doug Coning wrote: Hi everyone, I'd like to know how you would set up the following: I've set up a MySQL database with 600 products. I set it up where each product belongs to a category. However, now we want to take it further where different products can now belong to more than 1 category. How would you create this? 1. Would you duplicate the records for items that belong to more than 1 category and change the categories in those duplicated records? 2. Would you enter multiple categories into 1 column? 3. Would you create a different database that tracks categories and creat a many to many relationship? Thanks, Doug Coning -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] [PHP-MySQL] lock a record of MySQL from PHP
1. Check MySQL syntax for locking a record 2. Build the query to do that, assigning it to something like $qry 3. mysql_query( $qry ) 4. Check for results HOWEVER - given that the web is a stateless environment, and a user can just close a browser, or walk away, or whatever, are you SURE you want to lock a record? An awful lot of db work can be done w/o express locking of records. You get an implicit lock on an UPDATE or INSERT. I've not checked the MySLQ docs, but the classic way to see if a record is locked is to attempt a lock. I'd suggest reading up on the pro's and con's of locking, either in the MySQL docs or in a general book on SQL. Hope this helps - Miles Thompson At 12:11 PM 9/27/2002 +1000, Michael Wai wrote: I'm a newbie of PHP and MySQL. Would anyone tell me that how to lock and unlock a record of MySQL from PHP? And how other can detect whether this record is locked or not? Thanks for your help. Regards, Michael Wai -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CONNECT BY in mysql.
Go to http://www.thickbook.com and have a look at Julie Meloni's excellent tutorials. She uses MySQL and the whole process is documented and explained. There are also tutorials at www.php.net, and on WebMonkey, WeberDev, Zend ,etc. HTH - Miles Thompson At 05:23 PM 9/24/2002 +, Smita Manohar wrote: hii all... being new to php and mysql, i dont know can we use CONNECT BY in mysql. can anyone pls explain with example? thnx and regds, smita. _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] advise needed for 'authorized only' site
At the top of every page ... ? session_start();session_register( origin );$origin=$PHP_SELF; if( $HTTP_SERVER_VARS[ PHP_AUTH_USER ] !=lancelot $HTTP_SERVER_VARS[ PHP_AUTH_PW ] !=grail ) { if( !session_is_registered( member_id ) ) { header(Location: user_logon2.php\n); } }? The lancelot and grail were used only so that ht:dig could index the site, so they can be chopped out. The member_id flag was set in user_logon2.php. User_logon2.php was a little more complex. The goal was to allow only one user in from one browser on one machine, thus a series of checks was followed ... 1. If there was no cookie, then a regular login was displayed 2. If there was a cookie, its value was checked against the database, and if everything was OK (user wasn't blocked, etc.) then member_id was set. Member_id was only a semaphore and contained no value. 3. If there was a cookie, but it didn't validate correctly, access was denied and the user was asked to contact the office. 4. If there was no cookie, but the login values (user/pass) showed that one had been set from another machine or browser, access was denied and a message displayed to that effect, again with an invitation to contact the office. If I remember correctly, the origin var was set so that after the login check a valid user was returned to that page. All this complexity was an attempt to solve a bad pass-around problem for a daily business newsletter. Yes it was very restrictive, but that one line, at the top, protected every page so no one could blast in from Google, etc. In the same way, it let the owners of the site do their editing in Front Page, and everything was OK, so long as they didn't touch it. How did we use it? An email was sent each day to subscribers with an embedded link to the current day's news page. If the above check passed, then the newsletter, a PDF file, began downloading to their browser. Yes, IE 5.5 gave us a BUNCH of trouble, but that's another issue. When it worked, it was seamless - all the subscriber got was the news, which if they then wanted to pass around they had to save, write up an email and attach the pdf. A little more bother than simply forwarding a pdf sent to them directly. Regards - Miles Thompson At 10:22 AM 9/23/2002 -0500, Bryan McLemore wrote: you could make them log in once per session and just have every page check and see if they already have logged in and if they have not then trigger the login mechanism. Not sure exactly how to implement but I've read on the practice before. -Bryan - Original Message - From: [EMAIL PROTECTED] To: PHP_DB [EMAIL PROTECTED] Sent: Monday, September 23, 2002 10:14 AM Subject: [PHP-DB] advise needed for 'authorized only' site I have set up a section of my company site for use by authorized dealers only. I am currently using mysql authorization, which works for the first page, but if someone were to type in the url of an underlying page they would be able to get in without authorization. I know I could use .htaccess for handling this but with a minimum of 350 -400 users to keep track of that would be unwieldly to say the least, especially for my boss who doesn't have a clue about *nix and has never even heard of .htaccess. What other options do I have to keep the underlying pages from being accessed without the user being forced to go through the logon screen? Thanks, -- Chip Wiegand Computer Services Simrad, Inc www.simradusa.com [EMAIL PROTECTED] There is no reason anyone would want a computer in their home. --Ken Olson, president, chairman and founder of Digital Equipment Corporation, 1977 (They why do I have 9? Somebody help me!) -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] extracting unique entries from mysql dbase
What you want to do is common, everyday stuff. There are lots of examples. There's a fine manual at www.php.net, fully commented. If you have a look at mysql_query() I believe there is an example in the explanatory text / comments on how to use the returned results. There are also lots of tutorials and examples, key words would be php, database web site. And, as always, Juli Meloni's www.thickbook.com, which has some really well-developed tutorials. Hope this points you in the right direction - Miles Thompson At 08:49 PM 9/12/2002 -0700, Godzilla wrote: Hi everyone, I have a mysql row similar to the list below. What I need to do is have php output a link list from this. I'm new to php but in my head I picture something like: ? foreach unique entry in $row_links['dbase'] { echo a href=$PHP_SELF?catagory=Wind Chimes - Classic Hand-Tuned Collection - SongbirdsLINK TEXT/a; } ? The links will be on the same page thus the $php_self. The script will take a GET variable called category to display the proper items from the dbase. It's the foreach statment or whatever it should be that I need a bit of help with. Any ideas would be greatly appreciated! Thanks, Tim Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Constellations Wind Chimes - Constellations Wind Chimes - Constellations Wind Chimes - Constellations Wind Chimes - Duets Wind Chimes - Duets Wind Chimes - Duets Wind Chimes - Duets Wind Chimes - Energy Chimes Wind Chimes - Energy Chimes Wind Chimes - Energy Chimes Wind Chimes - Energy Chimes Wind Chimes - Energy Chimes Wind Chimes - Geotunes Wind Chimes - Geotunes Wind Chimes - Geotunes Wind Chimes - Geotunes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] extracting unique entries from mysql dbase
Tim, In your query use SELECT DISTINCT, rather than SELECT. That way you will not get duplicates returned from the database. Miles At 08:49 PM 9/12/2002 -0700, Godzilla wrote: Hi everyone, I have a mysql row similar to the list below. What I need to do is have php output a link list from this. I'm new to php but in my head I picture something like: ? foreach unique entry in $row_links['dbase'] { echo a href=$PHP_SELF?catagory=Wind Chimes - Classic Hand-Tuned Collection - SongbirdsLINK TEXT/a; } ? The links will be on the same page thus the $php_self. The script will take a GET variable called category to display the proper items from the dbase. It's the foreach statment or whatever it should be that I need a bit of help with. Any ideas would be greatly appreciated! Thanks, Tim Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Classic Hand-Tuned Collection - Songbirds Wind Chimes - Constellations Wind Chimes - Constellations Wind Chimes - Constellations Wind Chimes - Constellations Wind Chimes - Duets Wind Chimes - Duets Wind Chimes - Duets Wind Chimes - Duets Wind Chimes - Energy Chimes Wind Chimes - Energy Chimes Wind Chimes - Energy Chimes Wind Chimes - Energy Chimes Wind Chimes - Energy Chimes Wind Chimes - Geotunes Wind Chimes - Geotunes Wind Chimes - Geotunes Wind Chimes - Geotunes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Need help getting record number off insert
Check the DataFlex docs and see if it has a function that returns this information, or if the ODBC driver has such a function. Record numbers are dangerously useless in most database operations - they get re-used and changed when records are deleted or repair/compress functions are executed. I hope you aren't planning to use this as foreign key, i.e. for referencing information in this table from another table. Miles Thompson At 08:29 AM 9/11/2002 -0400, Anthony wrote: I'm doing an insert and need to get the record number that is generated when the record in created. I'm accessing the database through ODBC. It's a DataFlex database and the driver i'm using is by Connex. I know that you can somehow insert a SQL statment inside an other statement. I was thinking if I could quesry the record inside the insert, then I could get the record number. I'm not sure how to do this though. I was also thinking that I might be able to get some info from the resourse identifier that is returned to PHP, but I don't know how to read it from an insert, odbc_result doesn't work. Anyone have any clue how I can do this? I'm kinda new to this, so please help me out. I'm running IIS/Win2k, PHP 4.2.1 using ODBC through Connex DataFlex driver 8.7. Thanks in advance for your help. - Anthony -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] POSTGRESQL PHP
1. run a script containing phpinfo() function and confirm you have support for pgsql 2. add code to display the error message generated by either php or pgsql when you try to connnect 3. (Maybe this should have been first) I don't know about Windows systems, but on *nix, PostgreSQL has to be started with the -i switch to be accessible from the Internet. Check docs. Hope this helps - Miles Thompson PS For help on the list #2 suggestion is really important. At 06:10 PM 9/9/2002 +0200, Tomator wrote: I've installed MySQL and PostgreSQL on my XP. I'd like to make an PHP script working with pgsql base. I created database (typed createdb name) but when trying execute script with pg_connect(host=localhost dbname=name); it fails. Any suggestions? -- 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