Re: [PHP-DB] Sort HTML tables...
Like to know if anybody has a script to sort data for a column over multiple tables with MySQL ? thanks on advance .. cordially.. Are you looking for the 'ORDER BY' clause? It's used something like: SELECT blah FROM blah WHERE blah = true ORDER BY column name here Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Quotes, double-quotes, and the like.
On Sun, 16 Sep 2001, Ari M. Roth wrote: I'm trying to create a web-based interface that will allow me to save essays to a mySQL database for display on a website. The problem is that it may include HTML in it, so I need to preserve double-quotes in their original context. Right now, they are not encoding correctly for some reason. An HTML link, for example, to http://www.yahoo.com would come out as this: http://localhost/http://www.yahoo.com; addslashes() accomplished nothing, and I'm at a loss. Any ideas? You should probably paste the HTML form and perhaps the PHP code which does the actual insersts -- it's completely illogical that http://localhost/; would magically appear before a field name. At least in my book. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Cookies ???
On Mon, 17 Sep 2001, Jason Caldwell wrote: I've been reading the threads under SETCOOKIE (from php.net) -- some people are saying that setcookie doesn't seem to work for all browsers all of the time. Then some others go into how it seems to actually be the TIME format (unix time vs. GMT time) -- Should I just stick to the HEADER version instead of setcookie? Take a look at the comment dates; the earliest ones date back to 1998, which IIRC was around version 3.0.12 of PHP if not earlier. Given PHPs open source nature I'd imagine any wrong-doings of setcookie() have been fixed but perhaps a PHP deveoper would be better able to comment on this. I'd try it with setcookie() first, test it out with your target browsers and only change to header() if needed. Also -- I'm not completely clear on how cookies work in the first place... Q1: When I set a cookie, is that cookie automatically called from *each* page on my website? Or, do I need to add the HEADER to each page where I want to call the cookie? Yes, the browser will shove back all cookies if they're viewable by that script. That's just how HTTP works, it shoves a request over with all supporting data, awaits the request and kills the connection(^*). Q2: The 'Cookie Path' -- is this the PATH on my websever -- someone please explain what this is exactly, and how it works. Yep, path on the webserver. If you set a cookie with domain www.yourdomain.com and path /scripts only request to www.yourdomain..com/scripts and below will see it. Q3: The scenario I would like to use cookies in is to have users automatically be logged in when they come to my home page... so I will need to store the Username and Password in the cookie... should I store these in an Array, or can I create multiple cookies -- in other words, a cookie can only store one value, correct? So, I can use Serialize / Unserialize to store Array information in my cookies? Using serialize/unserialize isn't a bad idea, but neither is setting two cookies in my opinion. I'd say take your pick, choose whatever's most comfortable for you. I'd recommend only looking at the username/password cookies if a PHP session hasn't been established though to save you from takeing a quick query to your DB for every hit on each page though. I'll skip the security mumbo-jumbo for now on passing stuff around in plaintext because I'm not sure if that's really of any concern for your project. If it is, and you're clueless as to what I'm talking about, let me know and I'll try and elaborte a bit more. [*] HTTP -used- to kill the connection after every request but now sessions can be held open to save overhead. The ramifications of this change in design have absolutely no effect on application design though because it's not guaranteed behavior. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] possible mysql_insert_id() conflicts ?
From: http://www.php.net/manual/en/function.mysql-insert-id.php xochotorena AT arista IN Spain 06-Aug-2001 03:02 From mysql's manual: The last ID that was generated is maintained in the server on a per-connection basis. It will not be changed by another client. It will not even be changed if you update another AUTO_INCREMENT column with a non-magic value (that is, a value that is not NULL and not 0). As each thread is using it's own connection there is no need to lock the table. ... that should answer your question. No need to worry, just trust that MySQL will handle it for you. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Mon, 17 Sep 2001, rene kretzschmar wrote: hi, Imagine the following php+mysql scenario: there are two tables: create table testuser(id int not null auto_increment, name varchar(255), primary key(id)); create table testaddress(id int not null auto_increment, user int not null,street varchar(255), primary key(id)); the *.php test script contains the following lines: mysql_query(insert into testuser (name) ('testname')); //--* (see below) $userid = mysql_insert_id(); mysql_query(insert into testaddress(user,street) values('$userid','teststreet')); * at this time another thread could insert another record into testuser and the logical question: Will I get the right $userid from mysql_insert_id() anyway ?? thanx - rené -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Application-based locking with PHP?
So long as you keep any referencial integrity from being broken by two nearly simultaneous updates I don't really see much of a problem. If two users update a trouble ticket what's the big issue? Perhaps a notification could be displayed on the update confirmation page letting one of the user's know that somebody else updated it while they also did. Take a look at bugzilla -- it chugs along just fine it seems w/out any bug locking mechanism. Probably not the ansewr you were looking for, however if you're still hellbent on getting a real locking mechanism in place you may wish to take a look at SysV semaphores at http://www.php.net/manual/en/ref.sem.php. Overkill solution If you're familiar with using them in C you should be able to pick right up on it; if not then you may wish to consult manpages of whatever OS you're using (I assume *nix) for the C counterparts: man 2 semget man 2 semctl man 2 semop man 5 ipc man 3 ftok Even if you use them, which should be more trustworthy than DB locking, you end up with the problem of unlocking it after the user has exited. Perhaps you could use the shared memory functions to insert a timestamp at which the semaphore expires, store that stamp in session variable, then before the update compare the session variable with the value in shared memory. If they don't match they've lost their lock because they took too long to update and somebody else now has the semaphore and is in control of the update. Rather than lock on the ablitity to update the DB though you have to lock on the ability to look at and update the shared memory segment. I don't think PHP has an application-wide variable scope, so shared memory is probably your only option. And hey, if you're dealing with SysV semaphores anyway you might as well just do the whole thing in a SysV IPC style. :) /Overkill Solution If it's really -really- important, that's the only truly solid option I see. If it's not this important the I'd dump it, let people muddle with the same ticket at once and let them sort their differences out later. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Mon, 17 Sep 2001, Barry L. Jeung wrote: Just wondering if anyone has tried doing quasi application based locking with PHP? My scenario is this. I'm constructing a database for my company to help keep track of trouble tickets, etc with a web-based frontend. I'm using PHP (obviously =]) for inputing/retrieving data and have a slight predicament. Since MySQL does table-level locking, if I put lock statements in my queries, it would cause two problems. One being the entire table being locked and two if the user just closes the webpage without exiting properly, the table would remain locked indefinately. So I'm trying to think of alternatives, one of which is using global variables to store table/record id's, and then evaluating the queries based on that information. So if John selects ticket # 5 and might be updating it, then when Bob attempts to select ticket #5, then the $id and $table variables would be checked against the variables stored when john placed his query, and bob would get a message saying that record #5 is locked or in-use by John and to try later. Is this feasible or is there a better way to do this? Thanks for your time. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] .plan (finger) scripts in PHP?
If I was looking for one that came the closest I was looking for, it would be the Webdog one. If any of you know of any scripts that will let me run a finger server on my machine with our without MySQL, then send me a holler. THX! :) -- I assume you mean a PHP based finger client, not server. Picked this out of the PHP-HOWTO on linuxdoc.org, modified it to work with php4: function finger ($host, $user) { $fp = fsockopen($host, 79, $errno, $errstr) or die($errno: $errstr); fputs($fp, $user\n); while (!feof($fp)) echo fgets($fp, 128); fclose($fp); } Usage: finger(idsoftware.com, zaphod); Original URL: http://www.linuxdoc.org/HOWTO/PHP-HOWTO-19.html, it's in Section 19.3. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Stupid question=p
Not natively ... but you can with pstgreSQL. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Sun, 16 Sep 2001, Glenn B. wrote: Am I able to make a field an array in MySQL? Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] string problem
There's an option in php.ini: magic_quotes_gpc = On/Off; If on, any GET, POST, and Cookie data will come back with \ marks before ' and marks. Guesing one server has it set to Off, and one set to On. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Fri, 14 Sep 2001, Rick Emery wrote: Don't know why you're getting problem. However, you can use stripslashes() to avoid the problem. -Original Message- From: Bruno Franx [mailto:[EMAIL PROTECTED]] Sent: Friday, September 14, 2001 10:04 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] string problem scenario: Win.nt 4.0 pach6a Workstation, IE 5.5, Apache/1.3.20, php 4.0.6 wath goes wrong: when I set a string variable containing by example : hello jack on my html page php convert it to hello \jack\ and I get no errors on another machine with same configuration I get hello jack without quoting any Ideas? TIA -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] currency out of postgresql
While the proposed solution below may very well indeed work for this situation it's a far better practice to strip the variable down to known to be good values rather than known to be bad ones. Rather than strip $ and , marks from the variable it's far better to strip out anything other than 0-9 and the '.' character. In this given situation it may or may not have any advantage -- just a different paradigm; and one that often improves application security. Rather than think of what's disallowed think only of what is allowed. A recent example of this would be to follow the BugTraq postings on the Unicode directory transversal exploits of MS IIS toward the latter end of 2000. The patch was released to prevent certain attacks from coming through but it proved to be patch developed by somebody with rather elementary security skills. They preventyed only -known- attacks from working; workarounds surfaced within a day, if not hours. Eventually they put a competent coder on the job and things were fixed. But, like I said, this probably isn't a security issue here -- just one of robustness. The two are rather similar in practice though. As I said before, the original poster's idea may very well work 100% of the time, but I thought I'd take the opportunity to point out the difference. I posted a private reply to the orignal author that went something like this: Strip out anything except 0-9 characters (after formatting), add them, divide by 100 and reformat. I don't imagine any locale settings that would cause this to error. I don't mean to nit-pick at anybody here, that's my last objective. Just something to think about when coding. Admittedly I've done the exact opposite approach (stripping known bad vs. allowing known good) many times and have been burned because of it. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Fri, 14 Sep 2001, David Balatero wrote: I suppose you could just remove the $ and/or the comma with a regexp... www.php.net/eregi_replace -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Table display Driving me Crazy!
Looking at your code for the first row (I've cleaned it up a bit to make it readable!): ?php $numcols = 5; for ($l = 1; $l = $numcols; ++$l) { ? td width=139 class=ModNo bordercolor=#00 ?php echo $db-f(product_sku); ? /td ?php } ? It should be pretty clear why you're getting the product just repeated 5 times across the row. Your statement: echo $db-f(product_sku); does not contain any reference to variables thus it's essentially a constant. As far as I can make out (your style of coding gives me a headache :)) the other loops suffer from the same problem. The whole block is wraped in a while ($db-next_record()) { ...} loop actually. Now, I'm not sure if the next_record() method is setting an internal member to the current record and returning TRUE/FALSE for success, or if it's actually supposed to be returning a row. I'm guessing the class is simply being mis-used. The code is reasonably logical assuming next_record() is setting an internal member variable to the current row... doesn't look like it is though. I know with ASP/VBScript that there's a decent performance hit when you jump from HTML to VbScript and back again... I would imagine though not as severe the same also happens in PHP. Rather than stop the parser, print out something small like a /td and start the parser back up it's probably better performance wise to just use the 'echo' function (well, keyword, I guess echo isn't a real function, print is though). Plus, it makes your code more readable without all the ?php ? marks everywhere. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Problems inserting large blob
You might want to check php.ini - if memory serves the maximum filesize you can upload over HTTP by default is 2MB. Bump that number up and restart Apache (or whatever webserver you use) and see if that fixes the problem. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Thu, 13 Sep 2001, Joao Barreto wrote: Hello all ... I'm having a problem uploading large files (3MBytes for examples) and inserting it onto a MySQL database. No problem with smaller files. The code is basically this: ?php $data = addslashes(fread(fopen($form_data, rb), filesize($form_data))); $result=MYSQL_QUERY(INSERT INTO file2download (description,bin_data,filename,filesize,filetype, filecompany) . VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data _type', '$empresa')); if (mysql_errno() != 0) echo mysql_error(); $id= mysql_insert_id(); ? When the files are the mentioned size (I checked the whole file got there on /tmp/something) I get an error message along these lines: 'MySQL Server moved away' and the fid is 0. Any ideas? Is there any limitation on the size of the 'insert into' string? If so, how can I store such a big data chunk on the database? And please, answer directly by email as well to me. Sometimes it is difficult to find a message among the ones that we get each day! Thanks for your support, João Barreto - Convex Portugal -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] sessionid
Anytime you use rand() there's a chance you'll get the same results. Question is though, why are you making your own session id and not using the one built into the PHP engine itself? Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Tue, 11 Sep 2001, J-E-N wrote: hello! i have a script below, my question is, will there be a chance that i will get thesame $sessionid. if (!$sessionid) { $sessionid = md5(uniqid(rand())); SetCookie(sessionid,$sessionid,time()+1314000); } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] imap problem
I beleive the dl() function will let you load either an .so or .dll at runtime. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Wed, 12 Sep 2001, Vipin wrote: Hi, The imap functions in my remote server are not enabled. Is there any way by which I can use the php_imap.dll. I do not have administrative rights of the server. So I cannot edit php.ini. I am using php4.04pl on linux. Please help. Vipin Missionecom. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] URL checking
You could use fopen() to retreive the HTML of the page, then parse it taking your best guess at a 404 message. Not very robust though. It'd be much better to open up a socket to the site itself, then issue a HEAD /page here request. If the page is not found you'll have a line in the return result (should be the first line) which says HTTP/1.0 404 Not Found, then your Content-type: will come across and the actual HTML for the 404 page. You'll have to parse the domain name off the entire URL that's stored in your database which could be done by chopping off a leading http://; if any is provided, then split at the first / mark. Use the experimental socket() function (http://www.php.net/manual/en/function.socket.php) to make your connection and issue the HEAD request. Hope that helps... Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Sat, 8 Sep 2001, Larry RedCobra Linthicum wrote: I have a database with lots of urls stored I would like to build a script the retrieves them ... then somehow checks each one to see if the link produces a error 404 and is no longer good, then ideally write a file of bad links for me this seems like it would be possible with PHP, could someone give me some hints on where to start? I know very little about http headers and such any information will be appreciated -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] DB design question (so maybe a little OT)
On Fri, 7 Sep 2001, Alexander Deruwe wrote: I have 4 database tables, that each describe some sort of 'person' (transporting company, truck-driver, ..) and have almost exactly the same fields. Is this the best way of storing this, Nope... or does this make more sense: One table, with all the same fields + 1 extra, noting the type of person (that could come from yet another table). Correct, and another table person_type perhaps, with an id and a description, add another field to your person table with a foreign key to something in the person_type table. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Warning: Page has Expired
POST is no more secure, realistically, than the GET method. Both pass data around in plain-text form. In a perfect world web browsers wouldn't cache pages which were POSTed to as the HTTP specification says. At least, that's my understanding of it. Browsers -are- free to cache GET'ed pages though, because logically if the URL is identical to the other one the same data will be returned. So, switching to GET makes sense, because so long as the URL is slightly different each time the browser won't cache the page. Of course, in the real world not all browsers were made to spec, and some cache POSTed pages. So, to the original poster: It seems like your page is doing the Right Thing... but your browser isn't. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Mon, 3 Sep 2001, olinux o wrote: I have the same troubles. I believe that the only solution is to use GET rather than POST as your FORM METHOD. There may be another way, but this may work fine, as long as you are not working with passwords/sensitive info. olinux --- Mad Nas [EMAIL PROTECTED] wrote: Hi All I'm using PHP 4 and MySQL in W2K . When i submit a form and call a php file, i get this message : __ Warning: Page has Expired __ Do You Yahoo!? Get email alerts NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] store an array in a mysqldb
Nothing comes to mind that isn't a bit of a hack really. You could try seperating the data with delimiters before putting it in, then splitting the data back up into an array at query time. You could setup some tables, one called 'arrays' and one called 'array_values. Arrays would pretty much be one column -- just the id. Array_values would be 4 columns (3 if order doesn't matter) with: array_value_id, array_id, value, sequence (optional). However, I should probably note last I knew PostgreSQL supports the insertion of arrays into a record natively... though I have never personally used it. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Thu, 30 Aug 2001, Jeroen van Bussel wrote: I would like to know if it is somehow possible to store an array in a mysql DB. Could somebody please help me. greetz Jeroen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Seperate Tables for Same Data?
I'd suggest only inserting data into the working table throughout the day, then on a nightly basis drop the index on the archived table, import the data from the working table into the archived one, re-create the index and clear out your working table. As time goes on that archived table is going to get huge and you don't want your DB trying to insert into something like that during production hours. Better off waiting for some downtime where you can batch the whole thing in there. Just my two cents. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Thu, 30 Aug 2001, jv wrote: Greetings, I am setting up two seperate tables that will hold identically INSERTed data. The reason for this is that one table will hold data that will expire by timestamp daily and the other will hold the very same data for later manipulation. Is sending identical data like this to two seperate tables a good practise or is there a better way? Thanks, James -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Last Modified question..
a) What kind of database is this? b) use fstat() to check the modification time on a specific file. c) You will have to modify permissions so that the user your web server runs as has 'read' permission on the file if you want to use fstat(). Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Tue, 28 Aug 2001, Jay Paulson wrote: I have a problem... I want to check the last modified time that a file was changed/updated. Actually, it's an employee database that I'm working on and I thought about just checking the last modified date on the file that the information was stored on. However, I get a permission denied error and I don't want to change the permissions of the file. Is there an easy way to check to see when the last time anyone logged in and updated their 'employee' information? Thanks, jay -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] br appear in Text file
If you're getting a literal br in the file then I'd have to say you're either typing one in the text box or have your HTML putting on in there for you w/out knowing it. If it's a new line or a carriage return in the file that's a different matter. When somebody submits data to you in a textarea or input type=text field their newline character will match that of their OS. For a Win32 computer this is a two character combination, a carraige return (ASCII #13) and a line feed (ASCII #10). For a Unix/Linux machine it's just a line feed (ASCII #10), and for a Mac computer you get just a carriage return (ASCII #13). Given that I store my data on Unix/Linux machines, no matter what language I'm using, I change all 13,10 combinations into just a 10, then all 13's into a 10, which gives me my Unix/Linux like behavior. If you don't want to store any newlines then just change all 10's at that point into nothings (or a space). FYI, a newline (10) is often represented as \n and a carriage return (13) as \r. Hope that helps. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Mon, 27 Aug 2001, Jack wrote: Dear all I'm writing a script which will greb the data from a user input form into a text file (txt file), but the problem is that when the data had passed to the txt file, there will be some thing like the br and black square appear inside the file. This is affecting to display the data from that txt file to the text box in (input box). Is there anyway that i can do to avoid grebing the br from txt file to my input box's value? or anyway that i can delete the br when the data is greb from input box to txt file?? Thanks a lot Jack [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Compiling MySQL Database on LinuxPPC
One of a few things: - Broken compiler. If it happens in the same place everytime it's in the software. - Out of memory. If you made it with something like 'make -j 200' this is likely. If you only allowed a single g++ process to run with just 'make' this likely isn't the case. - Bad memory. If you tyoe 'make' again and things keep moving along and die in a later spot, this is probably it. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Mon, 27 Aug 2001, George Pitcher wrote: Hi all, Frustrated by failing compile: This is the message I get: c++: Internal compiler eror: program cc1plus got fatal signal 15 make[3]: ***[field.o] Error 1 make[3]: Leaving directory '/usr/src/mysql-3.23.37/sql' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/usr/src/mysql-3.23.37/sql' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/usr/src/mysql-3.23.37' make: *** [all-recursive] Error 2 Any suggestions Regards George Pitcher Technical Manager HERON Project Napier University Edinburgh EH10 5DT [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] http://www.heron.ac.uk programmer - A device for transmuting caffeine into code. _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Compiling MySQL Database on LinuxPPC
If it fails, and you type 'make' again it will pick up right where it left off... which means it's bad memory or some other hardware problem usually. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Mon, 27 Aug 2001, George Pitcher wrote: Justin, Thanks. It appears to happen in the same place each time I try (4 attempts as its not that quick [about 1 hr each try]). So should I download a new compiler (is it the gcc++ or if not, what?)? George - Original Message - From: Justin Buist [EMAIL PROTECTED] To: George Pitcher [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, August 27, 2001 3:33 PM Subject: Re: [PHP-DB] Compiling MySQL Database on LinuxPPC One of a few things: - Broken compiler. If it happens in the same place everytime it's in the software. - Out of memory. If you made it with something like 'make -j 200' this is likely. If you only allowed a single g++ process to run with just 'make' this likely isn't the case. - Bad memory. If you tyoe 'make' again and things keep moving along and die in a later spot, this is probably it. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Mon, 27 Aug 2001, George Pitcher wrote: Hi all, Frustrated by failing compile: This is the message I get: c++: Internal compiler eror: program cc1plus got fatal signal 15 make[3]: ***[field.o] Error 1 make[3]: Leaving directory '/usr/src/mysql-3.23.37/sql' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/usr/src/mysql-3.23.37/sql' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/usr/src/mysql-3.23.37' make: *** [all-recursive] Error 2 Any suggestions Regards George Pitcher Technical Manager HERON Project Napier University Edinburgh EH10 5DT [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] http://www.heron.ac.uk programmer - A device for transmuting caffeine into code. _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] php doesn't work
Copied the .so file into the right location? Restarted apache? First two things I'd check. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Thu, 23 Aug 2001, [iso-8859-1] Wilmar Pérez wrote: Hello guys My server was running php4.0 just fine, but I needed to use some new features, so I decided to upgrade to the latest one (php4.06). I followed the normal procedure: ./configure \ --with-apxs=/usr/local/apache/bin/apxs --enable-ftp \ --with-mysql \ --with-dbase \ --with-imap \ --with-yp and then: make and finally: make install I didn't get any error message during the process, however my php pages don't work at all. Any idea? Thanks for your help --- Wilmar Pérez IT Manager - Central Library University of Antioquia Medellín - Colombia tel: ++57(4)2105145 --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] using A NAME ref
I'm not sure what any of the posted sample code is really trying to get at ... but from what I gather you want: a) Links at the top of the page, allowing somebody to jump to the beginning of the section of people's who's last name begins with that letter. b) The names all come from the database, ordered by last name. So, you end up with something like this: ?php // Warning: I haven't tested, debugged, or even ran this // through a syntax checker. It's completely off the cuff. for($c = 'A'; $c = 'Z'; $c++) { // This works in C... I assume PHP acts similar. echo a href=\$PHP_SELF#$c\$c/a\n; } $recordset = ... however you query your particular DB. $curr_letter = ''; $row = array_shift($recordset); while ($row != NULL) { // Making assumptions on DB fields here. $lname = $row-last_name; if (substr($lname, 0, 1) != $curr_letter) { $curr_letter = substr($lname, 0, 1); echo a name=\$curr_letter\\n; } // Print the user info now $row = array_shift($recordset); } ? If you want to get fancy you could query the recordset first, then iterate through the alphabet and for each letter scan ahead in the recordset looking for somebody w/ a last name beginning with that letter. If none found, print out a grey non-linked letter, and continue to the next one. It'd be slower... but act a lot nicer. If you're sure you'll have a last name for every letter in the alphabet... just use something like I posted. Hope that helps, Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Wed, 22 Aug 2001, Rick Emery wrote: The NAME indicator (#), must precede the data separator (?). I think what you want is: a href=\/members/members.php?$memltr=$memb\$member/a To use the NAME indicator, your line would read: a href=\/members/members.php#$memb?$memltr\$member/a which I doubt is what you want. Richard Emery -Original Message- From: Howard Picken [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 22, 2001 3:50 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] using A NAME ref Hi I'm trying to use the A NAME tag on a php4 generated page. The pages being generated are alphabetically list (e.g. Page just lists people with surname starting with A) a href=\/members/members.php?$memltr#$memb\$member/a It doesn't work of course. Anyone have any ideas? Howard Picken -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] how should i test my php program performance?
There are a few different things you can test here... I. Server Performance (overall) I don't have the name of any specific tool off hand, but basically you would request a slew of .php pages off of the server via HTTP and record how many pages/second actually are served up. This is really the only thing that matters in the Real World. II. Script Performance The replies to this thread have already mentioned functions which will help you calculate total time spent in a script. Good things to know, definately, but not the absolute answer. Quite often it's beneficial to place various outputs along your program (or script in this case) to figure out where any bottle knecks my lie. Personally, I place them just before and after a DB call to differentiate slow-downs between my actual code vs. my SQL code. This way you get to target specifically which pieces need optimization, if any. If II is plenty fast for you, but I isn't... start looking at processes running on the system which you don't need. If beyond that you want to squeak more out of the system, start optimizating your web-server config. Before anything though, a quick Big O analysis of your script could help point to performance problems before you can even see them in a benchmark. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Wed, 22 Aug 2001, haheho wrote: Dear all: I have wrote a php program and use mysql database. Is there a way to test its performance? Thanks. haheho -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Please help!
I realize this is trivial... but if you're using things like the code below alot it can clean things up a bit by using: if (($counter % 2) == 0 ($counter != 0)) echo BR; $counter++; echo img src=whatever...\n; Just reads easier... less branching, less code. In an ideal world it'd optimize into machine code better than the below snippet too -- but that's get anal retentive about the situtation :) Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Wed, 22 Aug 2001, Marios Moutzouris wrote: use that counter variable. check if its equal to 2 before incrementing, if it is then BR and reset to zero, otherwise just increment. if ($counter==2) { echo BR; $counter=0; } else { $counter++; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Photo Album Schema
Going to disagree there... I'd use a seperate dir for each user, identified by their id. You can keep the original filename then for each uploaded picture. If two users have a family.jpg then you won't end up with any collisions. Something like: photos/1/family.jpg photos/2/family.jpg Manipulating directories which have a huge number of files can be cumbersome at times... at least it has been in my experience with some Linux machines. I once threw 16,000+ .gif files into a single dir and the standard GNU tools have trouble manipulating things like that. For instance, an 'rm *' won't work.. you need to script it in some way file by file. Just my two cents. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Tue, 21 Aug 2001, Rick Emery wrote: I vote for a single directory. Then use Sheridan's naming suggestion. Richard Emery Excel Communications, Inc. IT Sr. Project Manager (972) 478-3398 (972) 944-0542 (pager) There is no trying... There is only Do or Not Do -Original Message- From: Jeff Oien [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 10:49 AM To: PHP-DB Subject: RE: [PHP-DB] Photo Album Schema I should have said photo_filename. That was what I intended to do. Would you suggest one directory for all photos or separate directories for each user? Jeff Oien Rick: I don't see any .php tags there... plus just because someone else has done it doesn't mean he can't do it as well =) Jeff: The only critique I would give from the description you have given us thus far is the fact that you appear to be storing the photo in the DB. The biggest bottleneck in a server-side script is usually the DB calls. With this in mind, you want to limit these calls as much as possible. I would suggest setting up a naming and/or directory scheme to store the pictures on the website, and then store the URL of the picture in the DB, rather than the image itself. Then when outputing the page just do something like echo Img src=\$queryresult['location']\; Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com - Original Message - From: Rick Emery [EMAIL PROTECTED] To: [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Tuesday, August 21, 2001 10:19 AM Subject: RE: [PHP-DB] Photo Album Schema This has been done. see http://www.photopoint.com This is a free service available to the public. rick Richard Emery Excel Communications, Inc. IT Sr. Project Manager (972) 478-3398 (972) 944-0542 (pager) There is no trying... There is only Do or Not Do -Original Message- From: Jeff Oien [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 10:12 AM To: PHP-DB Subject: [PHP-DB] Photo Album Schema I want to make a photo album that will have users who sign up to create an album and then have the albums open to the public. I was thinking of doing it like this but I've never done a relational database before so if anyone thinks of anything I should change please let me know. Thanks. Jeff Oien Table1: -username -password -album_title -creation_date -id Table2: -id (from Table1) -photo (jpg or gif) -date -photo_title -description (limited length) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Photo Album Schema
I'm going to play Devil's advocate a little bit more here. Lets say user #1 uploads 1family.jpg, and user 11 uploads family.jpg. 1 . 1family.jpg == 11family.jpg 11 . family.jpg == 11family.jpg You run into stuff like this anytime you let users upload files of any sort. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Tue, 21 Aug 2001, Sheridan Saint-Michel wrote: If you are going to use a single directory with a filename convention I would suggest something simple, yet unique like id . filename Where id is the unique userid from the DB and filename is the original name of the file. This would avoid conflicts (which is the point of a naming convention) and be fairly easy to implement. Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com - Original Message - From: Anthony Carlos [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Tuesday, August 21, 2001 11:47 AM Subject: RE: [PHP-DB] Photo Album Schema I vote for one directory to simplify the programming side of things. What do you guys recommend for the filename convention? Would you let users determine it or would you force them into something like a primary key? Anthony Carlos -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 11:55 AM To: PHP-DB Subject: RE: [PHP-DB] Photo Album Schema I vote for a single directory. Then use Sheridan's naming suggestion. Richard Emery Excel Communications, Inc. IT Sr. Project Manager (972) 478-3398 (972) 944-0542 (pager) There is no trying... There is only Do or Not Do -Original Message- From: Jeff Oien [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 10:49 AM To: PHP-DB Subject: RE: [PHP-DB] Photo Album Schema I should have said photo_filename. That was what I intended to do. Would you suggest one directory for all photos or separate directories for each user? Jeff Oien Rick: I don't see any .php tags there... plus just because someone else has done it doesn't mean he can't do it as well =) Jeff: The only critique I would give from the description you have given us thus far is the fact that you appear to be storing the photo in the DB. The biggest bottleneck in a server-side script is usually the DB calls. With this in mind, you want to limit these calls as much as possible. I would suggest setting up a naming and/or directory scheme to store the pictures on the website, and then store the URL of the picture in the DB, rather than the image itself. Then when outputing the page just do something like echo Img src=\$queryresult['location']\; Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com - Original Message - From: Rick Emery [EMAIL PROTECTED] To: [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Tuesday, August 21, 2001 10:19 AM Subject: RE: [PHP-DB] Photo Album Schema This has been done. see http://www.photopoint.com This is a free service available to the public. rick Richard Emery Excel Communications, Inc. IT Sr. Project Manager (972) 478-3398 (972) 944-0542 (pager) There is no trying... There is only Do or Not Do -Original Message- From: Jeff Oien [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 21, 2001 10:12 AM To: PHP-DB Subject: [PHP-DB] Photo Album Schema I want to make a photo album that will have users who sign up to create an album and then have the albums open to the public. I was thinking of doing it like this but I've never done a relational database before so if anyone thinks of anything I should change please let me know. Thanks. Jeff Oien Table1: -username -password -album_title -creation_date -id Table2: -id (from Table1) -photo (jpg or gif) -date -photo_title -description (limited length) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED
Re: [PHP-DB] E-Commerce - Integrating Sessions With Charging ProcessesThat rePOST
On Sun, 19 Aug 2001, Fotwun wrote: My questions are how do you securly, reliably, and seemlessly integrate sessions within that type of gateway. Because once the form data is posted to the credit card gateway, it redirects (posts response data) back to the script of your choice. However, in my experience, the sessions are not restored/recognized until the browser is refreshed on the client side (through the use of JavaScript) to get the server to recognize the request as coming from your user, rather than the as a post from the gateway. I don't want to have to deal with getting sloppy and adding additional refreshes/java script if thats the only way to do it. If I were to merely have the code generate a form based on hidden tags and have javascript auto-form submit, then I would open to security problems, because I could no longer restrict the script the gateway respondes to by an HTTP_REFFER. Whoa there buddy. HTTP_REFERER is supplied by the client's browser... and therefore should be untrusted. If you think it's secure because of what HTTP_REFERER says, you're mistaken. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 Because the clients order id that is generated will be stored as a session, I need a way to reference the order ID and confirmation code that is returned by the posted data from the gateway, against the session data to start inserting the data into the DB if it was a successful charge. Any ideas...? Maybe there's a quick solution out there I am just overlooking. The solution would be easy if I wasn't inserting all of my data at the end of the process based on the session data. But this is how the code is has to work, so what do you all think, how should I deal with this? Thanks, FT -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] simple odbc insert problem
On Mon, 20 Aug 2001, LondonVibe wrote: new to php so be nice :) win2k iis5.ms access.. what is the order for adding var's to a access DB ?? code i tried... with data from form don't work... // connect to system dsn odbc name login and password or die $connect = odbc_connect(DB,name,pword) or die ( not connected); $sql=INSERT INTO basket (Item,Amount,Price) Values ('$id','$amount','$price'); Don't put single ticks around a field which holds numerical data... unless you defined your primary ID as a text field (hope not) that's probably why the query is bombing out. // prepare SQL statement //$sql_prepare = odbc_prepare($connect,$sql) or die(Couldn't prepare query.); // prepare SQL statement $sql_result = odbc_prepare($connect,$sql) or die(Couldn't prepare query.); Okay, I've never written PHP to ODBC but making the same call twice and assigning the values to different variables? One of us is confused... // execute SQL statement and get results odbc_execute($sql_result) or die(Couldn't execute statement1.); odbc_free_result($sql_result); odbc_close($connect); Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] includes and filenames
So you want the footer to link to the page that called it? echo a href=\$SCRIPT_NAME\text/a or echo a href=\$PHP_SCRIPT\text/a Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Tue, 14 Aug 2001, travis forden wrote: Hi. This is my setup. I have a PHP file that pulls in two includes - content and footer. content is done with readfile() since no processing done (in most cases). footer in done with include() - or will be once i find an answer to my question. currently the footer is exactly the same for each page. i want to add a dynamic link that uses the filename of the includer file. in effect i want a function that will find the filename of the includer file and past it into a link. something like this would appear in the include file. $path = filename [this is a function or functions that find the filename of the file accessing the include file, footer.txt] text text text A href=http://validator.w3.org/check?uri=.$pathtext/a I want to tack the value of $path onto the end of the first part of the HREF. How can I do this? travis -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] PostgreSQL connections within classes collisions.
I recently did a re-install of PostgreSQL and php4 on Debian, which has broken some development code here. None of the actual code has changed in days, which I can verify against the CVS tree, so I know it's one of two things: a) botched server config b) the code wasn't as robust as it should have been in the first place. What I have is a class (db_postgres) which we use for all DB access within the project. The functions relative to what are breaking are as follows: class db_postgres { var $db_name = ourdb; var $db_user = ouruserB; var $db_conn; // CORE FUNCTIONS function get_connection() { $this-db_conn = pg_connect(dbname=$this-db_name . user=$this-db_user); if ($this-db_conn == FALSE) { echo Internal warning: Db connection not established.\n; } } function execute_sql($sql) { $result = pg_exec($this-db_conn, $sql); if ($result == NULL) { echo Error executing following SQL:hrpre$sql/pre\n; } return $result; } function get_rs($sql) { // Returns an array of hashes $this-get_connection(); $result = $this-execute_sql($sql); if ($result == NULL) return array(); $num = pg_numrows($result); $result_set = array(); for($i = 0; $i $num; $i++) array_push($result_set, pg_fetch_object($result, $row++)); return $result_set; } [snip] } The following main php page (ommiting includes) works: $db = new db_postgres; $result = $db-get_rs(select * from vendor); $result = $db-get_rs(select * from vendor); However, $db = new db_postgres; $result = $db-get_rs(select * from vendor); $db = new db_postgres; $result = $db-get_rs(select * from vendor); Will break on the second calls ot get_rs(). Yes, I -could- be passing around the db handles, or passing around already instantiated class objects, but this gets a bit messy. Plus, everything was working dandy with making two $db objects within a single page... which is why this bothers me. The actual PHP error upon the second call is: Warning: 1 is not a valid PostgreSQL link resource in ... [snip] Suggestions? Justin Buist -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: Can PHP exclude % characters in external txt file?
On Mon, 13 Aug 2001, Phillip Bow wrote: I can't think of a simple way to do it off of an include, but off the top of my head: ?php $file = file(data.txt); for($x=0; $xcount($file); $x++){ $temp = str_replace(%, , $file[$x]); print $temp\n; } unset($file, $temp); ? -- Few things I think I should point out here. The first being that str_replace() will replace -every- percent sign in the line, not just the one that occurs as the first character. If you know for sure that the the first character is always a % and you don't want to print it just use: print substr($line, 1); as the body of your for loop. Secondly, you're callilng count() for every iteration of your for loop. Might as well call it once, store the variable and save the computation time of repeatdly calling it. Thirdly, and this one is perhaps a bit anal retentive, PHP treats arrays as dynamically growing linked lists. So, when you call an array by it's subscript the php engine starts at the head and walks X steps through the list to get what you wanted. If you don't plan on re-using the array, It'd be better to do something like array_shift() to get values from it. Perhaps something like this would work better: $file = file(data.txt); for($x=0; $xcount($file); $x++){ $temp = str_replace(%, , $file[$x]); print $temp\n; } unset($file, $temp); ? $file = file(data.txt); $line = array_shift($file); while ($line != NULL) { print substr($line, 1); $line = array_shift($file); } unset($file, $line); Note: I've never done file I/O w/ PHP... I'm just assuming that the original post was correct there. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: reload page
Actually... it's not a bad idea to refresh a page once it's been submitted, even if that frame could be displaying the results with only one hit. We do it around here on quite a few things simply because it prevents accidents from happening on the user's end. If you redirect back to $PHP_SELF or $SCRIPT_NAME you clear out any GET/POST variables. If the user hit's refresh (for whatever reason) you end up submitting a request that's already been executed once. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Tue, 14 Aug 2001, Russ Michell wrote: I don't see what this gains you. Well you asked if there was a way to refresh your target frame once a submission was made from an origin frame. This method would do that. Then again, why does the second frame not already display the results of the submission?? As it get's called from the first (origin) frame. Maybe you should re-state your problem and indicate use of DB's in there too, as I may easily have got the wrong end of someone else's stick. Cheers. Russ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] get local file
Put the files in a web-viewable directory, pull the filename from the DB and redirect the browser to it. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Fri, 10 Aug 2001, Sommai Fongnamthip wrote: Hi, If I'd like to get Linux local filename (eg. filename.bmp, filename.txt) to display in Web with PHP. These filename.* was fill in MySQL column. I have to maintain these local file because I got them from another source. How could I do this? Sommai Fongnamthip -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Submit forms
I think it'd help if you pasted the HTML code for your form. Plus, which browser/OS you're using to test this out would help too. Justin Buist Trident Technology, Inc. 4700 60th St. SW, Suite 102 Grand Rapids, MI 49512 Ph. 616.554.2700 Fx. 616.554.3331 Mo. 616.291.2612 On Fri, 10 Aug 2001, Ian Grant wrote: Hi, I've got a simply search form, on my site using PHP and MySQL. It writes a SELECT query using WHERE (Field LIKE '%thingy%') where thingy is the word entered in the form. It works fine if the submit button is pressed, but if you press return after typing the word, instead, it fails and writes nothing for the query, so it ends up like WHERE () Any pointers? Thanks, Ian. -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]