RE: [PHP] Table Making
Thanks for the code improvement, but that will still print results from left to right, top to bottom, i.e. the items ascend left to right in the rows. I'm not concerned with the actual order that they come out of MySQL in, just how they're displayed. Basically, instead of this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I want this: 1 6 11 2 7 12 3 8 13 4 9 14 5 10 15 Thanks again for the help, though. Jason Soza -Original Message- From: Analysis Solutions [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 10:13 PM To: PHP List Subject: Re: [PHP] Table Making Jason: On Wed, Jul 10, 2002 at 10:04:45PM -0800, Jason Soza wrote: I have this nice piece of code to take my SQL result and organize it into a nice 5 column table: Nice is in the eye of the beholder... Here's what I think is nice: echo table width=\100%\ border=\0\ align=\center\\n; echo tr\n; while ($row = mysql_fetch_array($sql, MYSQL_ASSOC)) { echo ' td align=centera href=year.asp?year='; echo $row['grad_year'] . '' . $row['grad_year'] . /a/td\n; } echo /tr\n; echo /table\n\n; If you want to reverse the order, use an ORDER BY clause in your query string. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php4apache.dll...
Use this file instead: php4apache2.dll It's supposedly in the sapi directory. Did you search the internet for this subject before you posted? If not, you should have. There's lots of info on this missing file. if you can't find a working version anywhere, mail the php-dev mailing list, they can probably help you out more. -- Tyler Longren Captain Jack Communications [EMAIL PROTECTED] www.captainjack.com On Thu, 11 Jul 2002 16:22:27 +1000 Peter [EMAIL PROTECTED] wrote: Howdy can any one remember where to get the apache2 ver of php4apache.dll? Cheers Peter the only dumb question is the one that wasn't asked -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Table Making
I'm not sure if you can do that because you have to go row by row when writing html, not column by column. I could be mistaken though. -- Tyler Longren Captain Jack Communications [EMAIL PROTECTED] www.captainjack.com On Wed, 10 Jul 2002 22:34:15 -0800 Jason Soza [EMAIL PROTECTED] wrote: Thanks for the code improvement, but that will still print results from left to right, top to bottom, i.e. the items ascend left to right in the rows. I'm not concerned with the actual order that they come out of MySQL in, just how they're displayed. Basically, instead of this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I want this: 1 6 11 2 7 12 3 8 13 4 9 14 5 10 15 Thanks again for the help, though. Jason Soza -Original Message- From: Analysis Solutions [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 10:13 PM To: PHP List Subject: Re: [PHP] Table Making Jason: On Wed, Jul 10, 2002 at 10:04:45PM -0800, Jason Soza wrote: I have this nice piece of code to take my SQL result and organize it into a nice 5 column table: Nice is in the eye of the beholder... Here's what I think is nice: echo table width=\100%\ border=\0\ align=\center\\n; echo tr\n; while ($row = mysql_fetch_array($sql, MYSQL_ASSOC)) { echo ' td align=centera href=year.asp?year='; echo $row['grad_year'] . '' . $row['grad_year'] . /a/td\n; } echo /tr\n; echo /table\n\n; If you want to reverse the order, use an ORDER BY clause in your query string. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session, performance, timeout
I use PHP sessions for my sites. The session_set_save_handler() is set to Files. I would like to increase the gc_maxlifetime to get longer sessions. Today my sites generate about 1500-2000 simultaneous sessions. The number of sessions will probably grow if I increase the gc_maxlifetime. My question is: how does increased sessions affect the performance? Best regards Fredrik Nygren -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to know upload progress status
Hello, I'm beginning to use PHP, maybe my question is very simple... Anyway, I want permit users to upload files using a form, and I would show them the upload progress status... I don't know how to extract informations about upload progress status and how to show informations to users. For example I want the users can see 30% of upload completed, or the MByte just uploaded. I had some difficulties to write to the list, so I send the mail (with some modifies in the address) several times; I apologyze if many mails are sended to the list. Thanks for help...! S. In th file fileupload.php I call a function named uploadfile as shown in the follow code: uploadfile($g_dir_corrente); if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { $nomefile=$HTTP_POST_FILES['userfile']['name']; if(($nomefile!=.htaccess)($nomefile!=.ftpaccess)($nomefile!=.quota)) { copy($HTTP_POST_FILES['userfile']['tmp_name'],$g_dir_corrente/$nomefile); messaggio(12); // show a message to users echo br; } else { messaggio(13); // show a message to users } } ** function uploadfile($g_dir_corrente) { $Upload_file=messaggioX(11); // show a message to users echo form enctype=\multipart/form-data\ action=\fileupload.php\ method=\post\ input type=\hidden\ name=\MAX_FILE_SIZE\ value=\10\ $Upload_file input name=\userfile\ type=\file\ input type=\submit\ value=\Upload\ /form ; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Where is the Error
y m i getting this error can ne 1 help me out Parse error: parse error, expecting `')'' in /home/test/public_html/mp3/music.php3 on line 10 ? function ConvertBin($Binary) { /* global extract($GLOBALS);*/ //This function converts a binary byte into an ASCII byte. for ($i=1; $i=strlen($Binary); $i=$i+1) { $strChar=char($AscB[substr($Binary,$i-1,1)]); $function_ret=ConvertBin(.$strChar); } return $function_ret; } //Specify the folder to iterate through, displaying all the MP3s $folder=/home/test/public_html/mp3/; //Grab the folder information // $objFSO is of type Scripting.FileSYstemObject $objFolder=readfile($folder); //Create the Stream object // $objStream is of type ADODB.Stream $objStream.$Type=$adTypeBinary; //Loop through the files in the folder foreach (; // unknown filesystem method as $objFile) { //Open the stream } $Open; $objStream.$LoadFromFile$objFile.$Path; //Read the last 128 bytes $objStream.$Position=$objStream.$size-128; //Read the ID3 v1 tag info $strTag=ConvertBin($objStream.$Read[3]); if (strtoupper($strTag)==TAG) { $strSongName=ConvertBin($objStream.$Read[30]); $strArtist=ConvertBin($objStream.$Read[30]); $strAlbum=ConvertBin($objStream.$Read[30]); $strYear=ConvertBin($objStream.$Read[4]); $strComment=ConvertBin($objStream.$Read[30]); } //Display the results print tabletrtd colspan=2h3. ID3 Tag info for:/td/trtr. td colspan=2.$objFile.$Name./td/tr; print trtdbArtist: /b/td. td.$strArtist./td/tr; print trtdbTrack: /b/td. td.$strSongName./td/tr; print ; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Postal / Zip Code Proximity Search
Richard, I just tried performing a search on http://chatmusic.com/venues.htm http://chatmusic.com/venues.htm . All I did was supply my zipcode. I didn't change/supply any other information. My trial just took 15 seconds, and that's pretty damn slow... I don't recall it being that slow though. And the original page took far too long to come up as well, so I suspect there's something wrong somewhere... The load is around 1.25 which is not so hot... The search was really slow. I wanted to ask you what you would attribute the slowness to. What is your architecture? I'm on a shared $20/month server... uname -a gives me: OpenBSD o2 2.9 conf#0 i386 But I don't even know how to get the /proc/sysinfo or whatever it is under this OS... If you know how to get more info out of this box, I'll give it a shot, though. I sure wouldn't base any kind of performance data on the output from that site though -- It's hardly a dedicated server or anything like that. And I suspect the server is under abnormally high load or something, cuz it's not usually *that* slow... I've never even really tried hard to optimize this thing, once I got it to work. There aren't that many users hitting the page that often... -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where is the Error
millwOrm There shouldn't be . (full stop) before $strChar on line 10: $function_ret=ConvertBin(.$strChar); You also have issues on line 30 (the for loop). Rgds John - Original Message - From: millw0rm [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, July 11, 2002 8:41 AM Subject: [PHP] Where is the Error y m i getting this error can ne 1 help me out Parse error: parse error, expecting `')'' in /home/test/public_html/mp3/music.php3 on line 10 ? function ConvertBin($Binary) { /* global extract($GLOBALS);*/ //This function converts a binary byte into an ASCII byte. for ($i=1; $i=strlen($Binary); $i=$i+1) { $strChar=char($AscB[substr($Binary,$i-1,1)]); $function_ret=ConvertBin(.$strChar); } return $function_ret; } //Specify the folder to iterate through, displaying all the MP3s $folder=/home/test/public_html/mp3/; //Grab the folder information // $objFSO is of type Scripting.FileSYstemObject $objFolder=readfile($folder); //Create the Stream object // $objStream is of type ADODB.Stream $objStream.$Type=$adTypeBinary; //Loop through the files in the folder foreach (; // unknown filesystem method as $objFile) { //Open the stream } $Open; $objStream.$LoadFromFile$objFile.$Path; //Read the last 128 bytes $objStream.$Position=$objStream.$size-128; //Read the ID3 v1 tag info $strTag=ConvertBin($objStream.$Read[3]); if (strtoupper($strTag)==TAG) { $strSongName=ConvertBin($objStream.$Read[30]); $strArtist=ConvertBin($objStream.$Read[30]); $strAlbum=ConvertBin($objStream.$Read[30]); $strYear=ConvertBin($objStream.$Read[4]); $strComment=ConvertBin($objStream.$Read[30]); } //Display the results print tabletrtd colspan=2h3. ID3 Tag info for:/td/trtr. td colspan=2.$objFile.$Name./td/tr; print trtdbArtist: /b/td. td.$strArtist./td/tr; print trtdbTrack: /b/td. td.$strSongName./td/tr; print ; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sort problem
ok here we go: Table 1 user_table id points Table 2 reports report_id user_id rating The goal is to associate every user extra 50 points if he has a top 10 report. Top 10 report means the 10 reports with the highest ranking. This value is always changing, thats why I did not include it to the other points. Now that we have the users with the additional points we could add them to the total points of the user and then find out the 5 users with the highest total points. Thats the theory, but how to achieve this in real live?? Thanx for any idas, Andy Analysis Solutions [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Please post the relevant table and field names. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [REGEX] Regex ref to '' character problem (fwd)
Hi, I try to refer to the '' character in a regex using preg_replace function: preg_replace(/(http:\/\/.\S+(?![\\]))/, a href=\$1\ target='ext'$1/a, http://testbr); Ref to '' with '\' seems to work but not '' with '\'... Any idea??? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Table Making
Jason, HTML tables will always be displayed left to right, top to bottom. This is why you should ensure that the data from your database table comes out in the right order. Use an ORDER BY clause in your SELECT statement. Designing the table layout to be suitable avoids the problem you currently have. HTH Chris Jason Soza wrote: snip- I'm not concerned with the actual order that they come out of MySQL in, just how they're displayed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to know upload progress status
I don't know how to extract informations about upload progress status and how to show informations to users. For example I want the users can see 30% of upload completed, or the MByte just uploaded. It's impossible. PHP script starts when file is 100% uploaded on the server. -- Sincerely, val petruchek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Posting Problem
Hi, I have a problem with php.notes when I post to php.notes I get nothing...I have no error or no persmission ...nothing at all Regards -- Sameh Attia Senior System Engineer T.E. Data -- __ __ _ _ _/ /_/ /_(_)___ _ / ___/ __ `/ __/ __/ / __ `/ (__ ) /_/ / /_/ /_/ / /_/ / //\__,_/\__/\__/_/\__,_/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP CGI versus Module
We have some cases where we run PHP as a standalone executable for scripting certain processes that can be called from CRON, and we also have PHP for Apache. Does the php.ini affect both? Specifically script times? Only if you compiled it with the exact same settings for that one --xxx-dir I can't think of right now... Just use ?php phpinfo();? for both and search (grep) for php.ini in the output. You'll find out what you need to know. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: getting the IP address off a visitor
I am new to PHP and need some help. I was wondering if there is a way to get hold of the IP address of a site visitor with PHP. I'm trying to develop an interaction where the server would recognise a new visitor from a returning visitor via the IP address. IP address is useless for identification. Dial up users change IP faster than their underwear, and corporate users behind a firewall will share an IP. Use http://php.net/sesssion_start -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Cross-Site Sesison ID Propagation
All ya gotta do is have three invisible GIFs on all three sites that come from the *other* sites and the GIF does the set_cookie() of whatever their user ID is. I'm not sure where you got this idea, but you should investigate further. A banner ad is usually nothing more than an image, and your browser will make a complete separate HTTP GET request for that image. I'm not sure how you interpreted the above paragraph, but it clearly is not what I intended. If you control all three domains, or have some access to put code on them, you can use the images to send the right Cookies from all three domains to 'synchronize' them by embedding the current site's session_id() in the request from the 'other' sites, and have the 'other' sites send the Cookies required with the image. Each site has three IMG SRC=xxx that are requesting GIFs from the other sites. The request for the GIF has, in the GET data, the Cookie value you want to use. The servers simply spew out the same Cookie value as the original server, and now they all refer to the same user in a shared database. When that is the case, there is no way the remote site can read or write cookies outside of its own domain. They can set cookies from their own domain, and you might see the cookies warnings on the same page or whatever, but the domains will definitely be different. Okay, let me spell it out, since at least some readers are obviously not getting it. Assumption #1. You have access to *some* code on all three servers, and want to maintain the Session ID the same across all three. I believe that was the original poster's thesis -- They simply didn't want to rip apart all the rest of the HTML on all three sites, but could painlessly insert a few lines of code at the top of all three site's pages. If, on all three sites, you can auto_prepend (or include) the following code: ?php session_start(); $session_id = session_id(); echo IMG SRC=server1.com/session.jpg?session_id=$session_id\n; echo IMG SRC=server2.com/session.jpg?session_id=$session_id\n; echo IMG SRC=server3.com/session.jpg?session_id=$session_id\n; ? Then, on all three servers, have the file session.jpg. ?php setCookie('PHPSESSIONID', $session_id); header(Content-type: image/jpg); readfile('images/invisible.jpg'); ? You can effectively get the 'same' Cookie sent from all three sites. NOTES: I probably do not have the name of the Cookie variable, PHPSESSIONDID, correct. You may want to write cleaner code with more error-checking. :-) And add the Content-length. You'll also need to ForceType session.jpg to be PHP, not JPEG, or rename it session_jpg.php or something to make the code get executed. If a user is browsing with no Images, or uses Lynx, it ain't gonna work, because they'll never request the Image that transfers the Cookie values from site-to-site. Obviously, the Session Cookie can now be hijacked more easily, since you are accepting the value from the Internet. You will want to consider this very carefully, and insert cross-checks that somebody doesn't 'create' an account simply by presenting a request to all three servers with their own home-brewed session ID. It might be best to only GET the GIFs from the 'other' two servers on each server, and cross-check with the original server's data somehow that the account is valid. If you even care. If Cookies are simply used to identify the user as the same user, and there's no particularly private content nor user-customization happening, there's not much point. Only you and your application can determine this. Think the security implications through fully. If you're not 100% sure you'll never ever use the Cookie ID for anything more than convenience as they travel site-to-site, then you'd better be sure it's not a forgery. If a user's ID/Session Cookie every changes, you *MUST* re-issue the same Cookie on all three servers, or you'll get hopelessly out-of-sync. You may want to use the customized session storage handlers just to be sure you track this correctly. Search the PHP manual for something not unlike session_set_handler and you'll find the function I'm talking about. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Build-up of MySQL Sessions
I'm running windows 2000 and the latest releases of PHP and MySQL. All database connections are made with mysql_pconnect(). Connections build up, however. The only person connecting to this webserver at the moment is myself. It seems that it opens connections and keeps them open, but doesn't always reuse them, thus causing it to open new ones. Is this a bug in mysql_pconnect()? Should I just use mysql_connect()? Any and all help is appreciated. Some of this answer uses Un*x-specific terminology. MS, of course, would never use an industry-standard term, so you may need to translate. And, there actually is a big difference between process on Un*x and thread under Windows. However, for the purposes of this discussion, the difference is *MOOT* so I'm going to pretend they are the same, even when they aren't. Here's the deal: When you do mysql_pconnect(), PHP tells MySQL to *KEEP* the connection open. MySQL keeps the connection open, and, for performance+security reasons, knows which process opened the connect, and which username/password combo was used. You see, if MySQL has to change all the stuff related to username/password, then a lot of the benefit of keeping the old connection around would be lost. Much of the benefit of the connection is the construction of some particularly complicated gnarly pieces of data that tie the connection to a particular username/password.* * These last two sentences are possibly wildly inaccurate. Maybe even call them lies. They are particularly useful, though, in that the average user of PHP/MySQL can believe them and understand them, and cope with the fact that _pconnect is tied to the username/password, which is just how it is. I never let facts get in the way of education. YMMV. When the *SAME* process ('thread' under Win 2K, alright?) with the same username/password asks the (obviously same) MySQL server to mysql_pconnect() again, MySQL goes: Oh, look, here I already *have* the connection open and ready. I don't need to make another one. The reason you see multiple connections open is that you have multiple processes (threads in Win2K), each one holding on to their connection for their username/password. Actually, MySQL holds on to them *for* the process, but they are tagged for that process/username/password only. But some folks find it easier to think of them as being held onto by the HTTP process. [shrug] You see, when you asked for your first page, it was HTTP Process # 1s turn to answer. Then, on the second page, it was HTTP Process # 2s turn. Third, maybe it was #3's turn. Or #4's. Who knows? Maybe you didn't even do mysql_pconnect on your 4th request. Maybe by the time you asked for the fifth page, #1 was ready again. Time went by, and different processes answered different HTTP requests. *EACH* Process, as it does a _pconnect() gets its own persistent connection left open for it. Indeed, two processes *might* be running concurrently and *need* two connections open, since you don't want one connection's data getting mixed up with the other's data. They are both running at the same time. ** ** Purists will point out that the CPU can only do one thing at a time... Yes, but the *context* for what it is doing, the script that is running, the data structures/streams required, are all alive in some sense concurrently, even though the actual CPU is only dealing with one at a time. The Apache/PHP/MySQL/OS software needs to keep all this crap organized and different processes separated from each other, and it's easiest to think of them as running concurrently even when technically they are all taking turns with the CPU in time slices. Unless, of course, you have multiple CPUs, in which case this paragraph (and entire post) would get hopelessly complexified to no real benefit for the average reader. In time *every* process will have its own persistent connection. If you are running Apache, you can configure the number of Child processes and thus control the maximum number of open connections to MySQL. (One per process/username/password). If you are running IIS, you are on your own. :-) While I assume there is some kind of way to configure IIS wrt number of threads/children, I have no idea, and don't even want to know, how to do it. Meanwhile, it is abso[bleep]ing critical that your MySQL settings be such that *IT* does not have fewer connections limited than the number of persistent connections that your web-server is going to use. In fact, you want a few extra, so that you can *ALWAYS* use the monitor from the shell to take down a thrashing, dying, over-loaded MySQL. If you're maxed-out, you can't even get to MySQL from the shell, and you're in trouble. Example: Suppose httpd.conf has a cap of 30 HTTPD child processes. Then my.conf should have, oh, 35 as a limit on the number of open connections. Eventually, each HTTP process will have one (1) connection of its own, and you'll have a few spares for shell access. *IF* you have
[PHP] Re: no subject
Note that this only hides them from dumber, not dumb :-) Your POST variables and such-like are all visible when doing View Source, which is not particularly tricky, even for the average bear. The better way would be to use HTTP Authentication (search php.net for it). While this could still be sniffed, and I'm sure some real geeks can manage to snag their own username/password out of the browser's RAM, it's much less visible to the average user. If you also do that over HTTPS, you can guarantee that they will not be sniffed in transit from browser to server. Use the POST method instead of GET for submitting forms. Bogdan - wrote: Hi everyone, Is there any way to hide my form submitted variables (like passwords etc) in the location bar http://somedomain.org/checkpassword.php? password=mypassword or atleast show in an encypted form n the location bar. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dual Server...
It might be easiest to have: --- default.asp % ' Some ASP I've forgotten that redirects to http://example.com:8080/index.htm % And your real site, on port 8080, served up by Apache, will be fine, so long as the links are absolute, and httpd.conf is configured correctly. All the links/IMG/etc will stay on 8080 unless you have an absolute URL in there. I will probably do this the other way round as we have a few sites... so if i have a single file with a frame and point contents of frame to apache this should work? I have Apache and IIS coexisting on my intranet server and the way I set them up was to put each on a different port. (Apache serves http://intranet and IIS serves http://intranet:8080) this appears to work fine. Hope this helps OK following from my thread 'Browser Issues' I have found that when serving the site from apache, that the aforementioned errors go away... mostly... OK so... What is the best way to setup so that IIS/Apache co-exist... I'd like to keep the 'entry' to the site on IIS as we have other sites too... and use apache to serve the content of it. Any help mucho appreciated... also working to a deadline! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Qmail and PHP
You know really anoying mailing lists that send you e-mail you don't want Wait... thats called spam... well... to unsubscribe all you have to do is send an email back [EMAIL PROTECTED] with the subject REMOVE PHP === Can this wonder process things like that Perhaps... You'll might want to tie into Qmail in the, e, Qmail-equivalent of sendmail.conf and add in your unsubscribe.php script as the EXEC (is that what it's called?) for some kind of regex in your spam identifier. I only did something like this once, so have forgotten the details. There are a zillion examples with Perl, though, and there's no real difference from that to doing it with PHP, except the filename ends in .php, not .pl, and then the file itself is PHP and uses the PHP parser instead of Perl. You'll need to put unsubscribe.php in the smrsh directory, and make it executable with #!/path/to/php, the CGI (or CLI now) PHP version you compiled the same way you compiled the Module, only without the --with-apxs Or, perhaps, you'll want to re-direct *ALL* your email to PHP, and write your own spam detector in PHP. Or, perhaps, you don't have access to Qmail at all, and you could build yourself a web-page where you paste in the offending email, with headers, and then PHP does something. I doubt the latter, but it's hard to tell from your question... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: No server var array, why
I just moved an application from one Linux server running Apache to another running Apache. The version of Apache on both is 1.3.12. The version of PHP on one is 4.0.3pl1 and on the other it is 4.0.1pl2. Here is what is baffling for me: one the second server the $HTTP_ENV_VARS array is empty. I have to get my information by calling what would ususally be the indexes e.g. $HTTP_SCRIPTNAME. Is there a switch I did not set? php.ini track_vars Compare ?php phpinfo();? on both machines any time they are not behaving the same. Your answer will almost always be in there. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Odd Request: Image 2 HEX
I'm using a Zebra label printer in an application I have and in order to display an image on the label, according to the ZPL II printer language, any image must be converted to HEX code. Does anyone hvae a code snippet or know of a free utility that will take a graphic image (BMP, GIF, JPG, etc...) and convert it to HEX values? Something not unlike this may work... ?php $image = 'sample.bmp'; $file = fopen($image, 'r') or die(Could not open $image); while ($file !feof($file)){ $chunk = fread($file, 100); # You can affect performance altering this number. YMMV. # This loop will be dog-slow, almost for sure... # You could snag two or three bytes and shift/add them, # but at 4 bytes, you violate the 7fff limit of dechex... # You could maybe write a better dechex that would accept multiple bytes # and use substr... Maybe. for ($byte = 0; $byte strlen($chunk); $byte++)){ echo dechex(ord($chunk[$byte])); } } ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: header()
I'm trying to change some information in the header...lets say that User Agent for example...but it just wont change. putenv() will change the User Agent..but nothing else will ? $ua = Mozilla/4.0 (compatible;); header(User-Agent: $ua\n, TRUE); header(Accept: */*, TRUE); //putenv(HTTP_USER_AGENT=$ua); echo \nbruser agent: ; echo getenv(HTTP_USER_AGENT); ? You are confusing the headers that your web-server sends *TO* the client, with the headers the server gets *FROM* the user's Browser. You can't upgrade somebody's stupid IE browser to Mozilla just by sending them a new User-Agent header, no matter how attractive a solution it might seem :-) On each HTTP request, their browser composes a User-Agent setting to tell you what Browser they are, and you while you can change the value of the Environment variable that ends up in, it won't change the reality of which broken browser they are using. Exactly why did you think you wanted to do this? Because whatever it is you're trying to do, this for sure is nowhere near the right way to do it. :-) Short description: Each HTTP request and response consists of *TWO* sets of headers -- The browser *SENDS* some headers to the server, and the server sends back some headers and (usually) some content. You can't alter the headers being sent by the browser, though. Well, okay, you can send Cookies, and they'll come back as headers, and you can use HTTP Authentication, and on their second page, the browser uses headers to send back the same username/password they already typed in. But the actual User-Agent and other stuff the browsers tell you, they make up all on their own and send in as headers. Note that geeky users can send any User-Agent they desire... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Wait/Timeout
Hi! I've been using PHP to write shell scripts and was wondering how to implement the following: - I have a menuing system - If a user does not give an input within a certain amount of time, I want it to go to a default value I checked the PHP functions page and the closest thing I found was sleep which isn't quite right. I'm sure this is a common thing, so does anyone have any suggestions? Again, this is a terminal program and not a web CGI. *MAYBE*, I say just *MAYBE* http://php.net/fgetc will time out and return false if nothing is typed for long enough... But that's probably too long for what you need, and you have no control over it. If you can somehow use fsockopen instead of a fopen, and fool that socket into being a file using named pipes and redirect, you could *probably* do much better by then setting the time-out on the socket... While I have your attention, I also wanted to create one of those spinners while users wait for longer tasks to complete. I tried using the ncurses stuff to print and erase characters, but it didn't seem to work. What is a good way to create a spinner so that users know that the program is working. For those who don't know what I mean, I'm thinking of something like... - (backspace) \ (backspace) | (backspace) / (backspace) etc. etc. Wild Guess: ?php $beach_ball = array('-', '\', '|', '/'); $file = fopen('php://stdout', 'w') or die(Could not open stdout); for ($i = 0; $i 80; $i++){ echo $i, chr(8); # 8 is ^H, right? } ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Script File Permissions
I've been trying and trying to get my site to work lately and all but one part does. Of course that one part is the most important part (it always is). My problem is probably rather simple to most of you, but I don't know how to get around it: My script does not have permissions to write/append files or just flat out create the files; it can read any files (accessed files//nameoffile.xml). Originally I was working with text files, but that didn't work either (and had the exact same problems). So my question is this: how do I get my script to have permissions to write or append to any file? Your question should be more like: How do I get specific files to be readable/writeable by PHP? The only way to get any arbitrary file readable/writeable by PHP is to run PHP (ie, Apache) as 'root' and that's just plain stupid. Under Un*x, you can do: chmod 766 filename and then PHP will be able to read/write it. NOTE: So will *ANY* other user on the same system using PHP/Perl/whatever!!! You do *NOT* *NOT* *NOT* *NOT* want world-write-able files in your web-tree. Put them in your home directory, *NEXT* to 'htdocs' or 'www' or 'web' or whatever they called the directory where you stick your HTML files. Use a full pathname to access the file. If you don't know the pathname, you can do: pwd to figure it out. If you can't SSH (or telnet) [is any ISP dumb enough to still allow telnet?] in to your server, then you *might* be able to use your FTP client to alter a file's permissions. If you are on Windows, the same principles apply, but the permissions system changed from version to version, and in some cases, you're just screwed because there are no sensible alternatives to set the permissions of a file. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: exif_read_data to read, and to write ...?
Hi, I am making a script to generate counter image on the fly for the office web site, and i have noticed that my dynamically generated jpeg images bears following comment: CREATOR: gd-jpeg v2.0 (using IJG JPEG v62), quality = 100 Does anyone know how to insert user defined comments into generated images? I looked around the net, and php API list, and found that i can only read the JPEG header markers with exif_read_data. Is there a exif_write_data function? Thank you, Alex If there is no gd_set_comment function in http://php.net/gd then you are probably reduced to using exec() for some external program to add comments to the file, or to figuring out how to shove them into the file by hand yourself, by digging apart the JPEG specs... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sigh... forms
Speaking of forms, and I'm sure lots have asked this before me, but anyone know anywhere I can go to see some examples or existing code for automatically generating and and validating dynamic forms? Wait though, I'm already doing this myself. To explain further, what I really want is an abstract set of php functions to say, ok, I want another form with say 10 questions, and I want to define each question and set of possible answers (input types and ranges) manually, and have the action script automatically check that the input types and ranges for each question are valid. hforms (not that many 'o's but more than one) inside of PHPLib does this, I think... Or are PHPLib and oforms competitors? Whatever. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP code optimization
Question on optimizing code for quicker runtimes. Which is quicker (this is on a webpage also..NOT commandline)? ?php if ($a){ echo 'abc'; } ? OR ?php if ($a) { ? abc ?php } ? You will not be able to measure the difference until you have a zillion of them... Both do the same thing and are legit but wondering which is better from an optimization standpoint (NOT interested in readability or *proper* code here) Why not?! It's *FAR* more important than raw performance 90% of the time! Optimize the code that's slow, don't try to write all code at maximum performance. If we really needed all code at maximum performance, we'd all still be coding in binary. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: CANT GET STUFF TO WORK
Hello, I am wondering if you could help me... I can't seem to figure out how to get sessions working. Thank You, Mike We'll need a lot more info than this... What part is not working? Set your browser Cookie settings to Ask every time for starters. Are you getting the cookies from: ?php session_start(); Then, are you remembering to: session_register('counter'); and what do you see when you have: echo You have been here , $counter++. times.; ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: multi dimensional arrays / radio buttons / mass confusion on my part
Ok.. what I have is a database of first names and last names, and some other columns that don't matter here. A form is presented to a user, lets them enter a bunch of names, attributes of the person, etc. After submission, each record is checked against the current database to see if the name currently exists, or names similar to it exist. If so, it gives the option of either: a) entering the new record or b) selecting one of the existing records Okay, here's one thing: Why make me type all the crap in for somebody who might already be there? It would be much better human interface to first let me know who's missing before I go typing in all that stuff for the players already input. I'm assuming LW and RW are, like, Left Wing and Right Wing in soccer or hockey or something, right? A team roster is going to be, what, 30 records at most? Show me the current list and let me choose whom to edit, and give me a New Player button. Example: Enter your names, positions: Joe Schmoe, LW Random Guy, RW (submit button) After DB check for existing users: Found: () Joey Schmoe Click radio button to se this record () Create New Record No matches found for Random Guy, must be a new user. (submit button) My problem is keeping this data consistent form by form, and updating the data when an existing record is selected instead of creating a new one (the existing data needs to go into another table, so I need to grab the user id # of the existing record, etc) Any thoughts on how to approach this? After the first form, should I make a multi-dimensional array, and have the second form update/change the elements of it? I haven't used any PHP arrays in this yet, just been messing with the HTML form array stuff.. Sorry if this is confusing.. if any part needs clarification, please let me know. If there are only a few fields, and not too many rows, one thing I frequently do is display them with User IDs and then use 'NULL' as the ID for a New Record, and have code something like this: ?php require 'connect.inc'; # This just has one line $connection = mysql_connnect('localhost', 'user', 'pass'); in it. # Handle any FORM input: if (isset($lastname)){ while (list($id, $ln) = each($lastname)){ $fn = $firstname[$id]; # Other fields the same way $xx = $[$id]; if ($id == NULL || $id == 'NULL' ($fn || $ln)){ # New Player, but only if they've filled in a name: $query = insert into players (firstname, $lastname, ...) values('$fn', '$ln', ...); } else{ $query = update players set firstname = '$fn', lastname = '$ln', ... where players_id = $id; } $update = mysql_query($query, $connection) or error_log(mysql_error()); } } # Display FORM $query = select players_id, firstname, lastname from players order by lastname, firstname; $players = mysql_query($query, $connection) or error_log(mysql_error()); while (list($id, $fn, $ln) = mysql_fetch_row($players)){ echo TR\n; echo TDINPUT NAME=lastname[$id] VALUE=', htmlentities($ln), '/TD\n; echo TDINPUT NAME=firstname[$id] VALUE=', htmlentities($fn), '/TD\n; # More fields here. They can be Radio buttons or whatever, of course. echo /TR\n; } # Output a row for a New Player: echo TR\n; echo TDBNEW:/BINPUT NAME=lastname[NULL]/TD\n; echo TDINPUT NAME=firstname[NULL]/TD\n; # More fields here. They can be Radio buttons or whatever, of course. echo /TR\n; echo /TABLE/FORM\n; ? Now, this is not going to win any awards for Design or anything, but for a busy admin to have everything in one place to fill in all the crap and see all of it is very handy. It also means that when (not if) they forget to update 'Joe Schmoe', they'll see his record when they go to add in 'Betsy Buick' -- which means they just might notice that it's out of date and fix it at the same time. This simply gets unwieldy, though, if there are a ton of records, or too many fields... Still, I'm making the wild guess that for a team roster this is going to be fine... You can also output 5 or even 10 rows of the New row, if they frequently have to put in a lot of players at once, but then you need to give them *DIFFERENT* 'key' values inside the [], and change the if ($id == NULL || $id == 'NULL' ...) part to be more complex: if (strstr($id, 'NULL') ($fn[$id] || $ln[$id])){ . . . # Output five rows for a New Player: for ($i = 1; $i = 5; $i++){ echo TR\n; echo TDBNEW:/BINPUT NAME=lastname[NULL$i]/TD\n; echo TDINPUT NAME=firstname[NULL$i]/TD\n; # More fields here. They can be Radio buttons or whatever, of course. echo /TR\n; } -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script File Permissions
I hope that I can get permissions, but I bet you're right. Probably just have to create a database, which I planned on doing (and know how to). I really did want to use XML though, oh well. Using a database does not in any way, shape, or form preclude you from using XML. XML is just text. Databases store text very nicely. Some databases even claim to understand XML internally. I have no direct knowledge of the validity of such claims. If you think it would be better in a database, you are probably correct, and you probably should stop using files immediately. Otherwise, you will almost for sure find yourself dealing with race conditions and other gnarly stuff that is taken care of in the database. In short, you'll find yourself basically re-writing a goodly chunk of very tricky code that somebody already wrote for you, for free. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Mail() function
I wonder if thereÂ’s a way to *HIDE* some parts from the Heading of the emails sent with PHP. IÂ’m trying to create an anonymous mail sender but in the header of the message appears: Received: (from httpd@localhost) by www.whateverdomain.com (8.10.2/8.10.2) id g69MEA527130; Tue, 9 Jul 2002 18:14:10 -0400 Date: Tue, 9 Jul 2002 18:14:10 -0400 Message-Id: 200207092214.g69MEA527130@www. mailto:200207092214.g69MEA527130@www.%20whateverdomain.com whateverdomain.com I want to hide the *whateverdomain.com* (because is my hosting providerÂ… You can't do that using PHP's mail function. That particular header is automatically inserted, I believe, by the software actually sending the email, IE sendmail or qmail or whatever. What's more, it's pretty much not kosher to not have that. This is not to say it's impossible to forge such things, and insert email via an open relay into the mail stream/system somewhere. Just that it's not something that should be a built-in function to PHP, or *ANY* legitimate mass-use software for that matter. I mean, that would be like inviting *EVERYBODY* to spam, uncontrollably, and would just be stupid. I honestly have no idea how to forge an email routing path, just know it can be done, and is not rocket-science. But you're going to have to dig into the guts of sendmail or equivalent at a minimum, or search out send spam to 1,000,000 people!!! software to do it... I don't *think* you can even do it with just PHP's fsockopen to the much-hated Open Relays of the world... Or, at least, they'd be tracked back to that Open Relay anyway... That might be sufficient for your purposes, whatever they are. I suggest, however, that you re-examine your purpose, and decide if it's really worthy of your time and talent. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_REQUEST???
Considering all of this... Would it be better simply to turn register_globals = On if the vast majority of the stuff you have on your site is simple search engine type stuff and/or GET variables? That's the reason why register_globals was originally ON. Actually, going way back, I don't think you could even turn it OFF at all... It's just *S* convenient. Considering the fact that anyone can forge GET, POST, cookies, is there really any purpose in turning register_globals = Off ?? *YES* Consider the following (stupid but common) code: ?php if (valid_user($PHP_AUTH_USER, $PHP_AUTH_PW)){ $valid = 1; } . . . if ($valid){ # SECRET stuff here } ? Now, with register globals on, if I visit: http://example.com/valid=1 Game Over. In theory, nobody would ever have a variable they were using that was uninitialized because they set error_reporting to E_ALL (like they should) and they completely test every line of code and branch of logic in their application (like they should)... Here in the Real World, there are a zillion scripts out there by non-programmers (hey, PHP *is* that easy!) and they have Security Holes like this in them. Some of these are (or at least were) in widely-distributed third-party PHP applications, as I understand it. :-( Turning register_globals ON will make the above hack to pass in $valid through GET as a global not work. Stops the hack cold, because $valid isn't allowed to sneak in through the URL any more. You could say register_globals OFF increases the security of a badly-written application :-) This register_globals has *nothing* to do with global in functions, just in case the terminology is making anybody think they're the same thing. They're not. Not related at all. If you're an expert programmer and you *NEVER* make the mistake of using an uninitialized variable, then by all means, turn register_globals on and live happily ever after writing code without all those pesky $_GET and $_POST, or $_REQUEST if you want to treat both GET and POST data the same for a particular variable. If you've ever made a single mistake in your life, leave register_globals OFF and get used to the new paradigm. :-) For the record, $_GET and/or globals are *NOT* filtered in any way, shape, or form by PHP. If they *were* filtered somehow by PHP, there is *NO* reason that filter could not be applied in either paradigm. It is entirely UP TO YOU to validate the incoming data as kosher, whatever kosher means in the context of your application, and at the level of Security is acceptable risk to your organization, application, boss, and self-pride. Alas, PHP really *CANNOT* filter your incoming data, since there's simply no way for PHP to know what is or isn't kosher. Think about it. Try to write a generic data-validating system. It gets very messy, very fast, and it just can't be applied across the board to arbitrary data. You have to know, at a minimum, some business-logic specific information about the data. register_globals OFF *ONLY* stops the hack of somebody over-riding an un-initialized variable with whatever value they choose. This is NOWHERE NEAR sufficient for you to TRUST data coming from the big, bad, Internet. Disclaimer: I originally argued against register_globals OFF as default, for various reasons (not least of which is the traffic on this list from this change), and I still have it ON in many places because I actually *DO* always initialize variables. It's just an ingrained habit with me, and I daresay there truly are no uninitialized variables floating around in my personally-written code. Can't say the same for any third-party code I've installed (not much) and I *should* migrate to register_globals OFF, but I've got a *LOT* of code to fix, and there's no maintenance budget for any of it... -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php loopholes
I just wish RedHat's updater worked as seamlessly as Microsoft's. MUHAHAHA ;) I dunno what I screwed up where, but I never have gotten up2date to work :-( Damn thing takes me to a web-page, I pick what I want, then it takes forever, then it pukes somehow. It's been so long since I bothered to try it, I forget the exact error message. Sigh. RedHat 6.2 though... I've never seen MS auto-updater, and have no intention of seeing it. :-) -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How do I import tables into MySQL from web page ...
Hi, I am trying to import some tables from a dump file into a MySQL database from a php web page. What is the best way to do this without using backticks (fpassthru, system, exec or something else) and test for success or failure? I tried the following and while it works, my test for success or failure always produces a Success even when I change something to make it fail. I thought system() outputs the last line of the command on success and FALSE on failure. Any examples appreciated. The FALSE on failure is if PHP completely fails to execute the command at all. This is a rather rare condition. PHP is quite happy to execute commands that fail (whatever that means) and return the last line of their output which may, or may not, contain an error message you could detect, though, and as far as PHP is concerned, it did not fail to execute the command. That your command didn't do what you wanted, or that the command itself failed, is not a failure on the part of PHP, if you see what I mean. However, you may want to use exec() and get the full output, as well as the OS error code, if any, returned by MySQL and then you'd know for sure what happened. ?php $status = system(mysql -umyuserid -pmypassword mydbname /path/to/mydumpfile.txt); if($status == 'FALSE'){ echo 'Failed'; } else { echo 'Success'; } ? -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I import tables into MySQL from web page ...
Thanks for pointing out the syntax error. I added the space after the -u but it did not make any difference. It still gives the same result, that is Success, when it actually fails. What I am trying to figure out is how I can tell if it failed (did not create the tables)? The $status variable does not appear to hold the output of the system() function. Anyone know how to get the output of system, passthru or exec into the $status variable to check for success or failure? Analysis Solutions [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Tue, Jul 09, 2002 at 06:09:36PM -0700, Fargo Lee wrote: $status = system(mysql -umyuserid -pmypassword mydbname ?php exec(mysql -u myuserid --password=mypassword myddbname ..., $result, $errorcode); echo implode('', $result); if ($errorcode){ echo OS Error $errorcode Use 'man errno' to find meaning, but it's almost always path/permissions; } ? Oh yeah. You'll need the full path to mysql, almost for sure. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function source?
No, they are written in C. And yes, you can of course download the C source code from php.net. If you are interested in a particular PHP function, there's even a really nice interface at http://cvs.php.net that lets you look at it without downloading the whole darn thing. VERY nice. You don't even really really have to know a lot of geeky things to understand it, so long as you're willing to just ignore the parts you don't understand, and peck away at what you do understand :-) -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I import tables into MySQL from web page ...
But if system() thinks it is a success because the command executed, even though MySQL returns an internal error on the command line, why is'nt the last line of the MySQL error message stored in the variable as the system() manual suggests it should be when system() thinks it is a success? *MAYBE* system() only catches stdout, and not stderr... Though I doubt it. Is there a blank line at the end of the MySQL error output when you do it wrong in the shell? Use the exec() I just posted and get *ALL* your output, *AND* the actual OS error (or 0) code returned. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: T_string error
Can someone tell me what the following error means, and how to fix it...please? Parse error: parse error, unexpected T_STRING in c:\program files\apache group\apache\htdocs\phpbb\language\lang_english\lang_main.php on line 629 this is the code on that page: $lang['Avatar_filesize'] = 'The avatar image file size must be less than %d kB'; // The avatar image file size must be less than 6 kB (than 6 kB this part of that line is on the next line down) *REALLY* on the next line down, or just wrapping in your editor?... What happens if you make the editor window bigger (wider) or even narrower? That should all be one line. The error is either because of that, or on the line[s] *before* that line. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: shtml php in the same file?
I'm working on this site that is all shtml files... in order to add some dynamic content, it just includes php scripts in different places. However, sessions don't work unless you start it before outputting anything to the server and that's what's needed now... I don't want to change all the links to end in .php and do the includes in php just so I can put ? session_start(); ? at the beginning of all the pages. So I was trying to get the server to treat shtml files as both server-parsed and as php scripts. Not working too well. ;) Anyone have any ideas? You can't get Apache 1.x to treat the file as both SSI and PHP. Period. You could just make the first line of each file do whatever magic you do to include PHP, and then it would be something not unlike: --- foo.shtml -- !-- #EXEC session.inc --! More HTML and SSI here. I *THINK* if you do this, and have ?php session_start();? in the session.inc file, it will work... I'm assuming there is no output to the browser by the !-- #EXEC -- bit. I'm also quite likely not doing SSI right, since I abandoned SSI for PHP very rapidly. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Exporting mySQL Table Data to .csv
I use phpMyAdmin which enables me to take dump of mySQL Table Data into Comma Seperated Values file (.csv) Now, i have to create such a program that accomplishes this, without using phpMyAdmin. Can someone guide me to this procedure.. Since PHP has a fget_csv function (or something like that) odds are pretty good it can write CSV as well. If not, and *IF* you can do tab-delimited instead (*MUCH* easier) and just as easy to suck in on the other end, you can do: ?php require 'connect.inc'; $query = select * from mytable; $rows = mysql_query($query, $connection) or error_log(mysql_error()); while ($row = msyql_fetch_row($rows)){ $tab_delimited = implode(\t, $row); echo $tab_delimited, \n; // Or you can write to a file, or whatever. } ? If you *MUST* use CSV, not tab-delimited, I *THINK* this will work: ?php require 'connect.inc'; $query = 'select * from mytable'; $rows = mysql_query($query, $connection) or error_log(mysql_error()); while ($row = mysql_fetch_row($rows)){ while (list(,$value) = $row){ if (strstr($value, ',') || strstr($value, '')){ $value = str_replace('', '', $value); $value = str_replace(',', ',', $value); $value = \$value\; $output_row[] = $value; } echo implode(',', $output_row), \n; } } ? -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: strange php output
I'm trying to do a little trick with my new site. i have one main php script, index.php which includes the header and footer scripts and the page script between them. the page script is determined by $page, which is set to main if it doesnt exist already. $page . .php is then included. I have one other page so far, datetime.php. I wanted to let datatime run itself by including the headers and footers on its own if it wasnt included by index.php. so, i add this to the top and similar code at the bottom (replaced header with footer): ? if (!$page==datetime) // Not using index.php { include(header.php); } ? The !$page probably happens before the ==, so you are testing !$page (true or false) being equal to datetime... You may or may not want to use something more like: ?php if (!strstr($PHP_SELF, 'datetime')){ include 'header.php'; } ? I personally, though, would have *three* files. One, datetime.inc would do the work. index.htm would include 'datetime.inc' datetime.htm would also include 'datetime.inc' I think this will be less confusing to you a year later when you have to maintain this code. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP 4.2.1 / Apache
HELLO, I just installed PHP 4.2.1. I am using a Redhat 7.3, installed as server with Apache. My problem is I can t compile it as a module for Apache : ./configure --with-apache=/usr/include/apache configure: error: Invalid Apache directory - unable to find httpd.h under /usr/include/apache But hhtpd.h is really under /usr/inclu/apache [root@localhost php-4.2.1]# slocate httpd.h /usr/include/apache/httpd.h PHP needs to find *both* the include files *AND* the lib files (.so) and you only get to plug in one path to --with-apache (or --with-mysql or any of them). In all cases, you want the path *ABOVE* the include/ directory -- You want only the part that is common to both your include directory, and your lib directory. Probably just /usr in your case. Don't worry about how far PHP has to dig to find include and lib so long as they are *BOTH* somewhere under the directory you provide. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Storing values in Session
I want to add a set of values to the session variable $BOOKS. This is the code which I used. if($BOOKS==) { #this seems to be the first book which the user has selected $BOOKS = $bookid; #this param comes from the URL } else { $BOOKS = $BOOKS+,+$bookid; } Here the 'if..' part gets executed, and because of that I cannot add details of another book. I have initialised the session and added the registered the value BOOKS in the previous page. Did you call session_start() in this page? Cuz if not, like, PHP doesn't know you want to use the session variables from the other page. Also, it's not + to concatenate strings in PHP. It's . $BOOKS = $BOOKS . , . $bookid; And, what's more, you can shorten $foo = $foo . xxx to: $foo .= xx So, in your case, it's: $BOOKS .= , . $bookid; And, since you can bury variable in strings and work, even go with: $BOOKS .= ,$bookid; You might, however, want to turn $BOOKS into an array anyway: $BOOKS[] = $bookid; But you'll need to read up on arrays to use them. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: cookie ( still not working )
i simpley put an cookie with : setcookie(gfo_cms ,$sessid , ''); That's wrong. You should be passing a TIME in for the third argument, or nothing at all. Also, due to an IE bug, if you *DO* pass in a TIME, you *MUST* also pass in a non-empty path. '/' will be fine. So, if you want a 'session' Cookie, use: setcookie('gfo_cms', $sessid); If you want it to expire, use: setcookie('gfo_cms', $sessid, time() + 60*60*24*30, '/'); Oh, and for Vins, PHP sessions *USE* cookies, so you're no better off with them *UNLESS* you --enable-trans-sid or you stuff the session_id() into every URL/FORM. ? if (isset($HTTP_COOKIE_VARS[gfo_cms])) { $sessid = $HTTP_COOKIE_VARS[gfo_cms]; if (!check_valid_sessid($sessid)) { login_form(); } if (!check_ip($sessid, $REMOTE_ADDR)) { login_form(); } $rights = get_user_rights($sessid); $user_id = get_userid_from_sessid($sessid); } This might as well be else -- it will be less cluttered that way. if (!isset($HTTP_COOKIE_VARS[gfo_cms])) { login_form(); } ? the last code looks if the cookie exists ... but it look likes it won't even create the cookie Use your browser Preferences to select Cookie Ask every time so that when you do or don't send a Cookie from your own site, you'll know what you're getting. You'll want to turn it off before real surfing again, though, since some sites send a zillion cookies on every damn page, no matter how silly that is. Sigh. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: count number of downloads
I have a php-script with which one can download a file with a specific format like this: header(Content-type: application/specific); header(Content-Disposition: attachment; filename=$name.sqrfld); echo (output funny stuff...); and i will count the number of downloads in a database. When i write the code for counting after the echo ... statement it will be executed regardless if the user aborted the download or not. How can i guarantee that i update the database when the download is complete? Don't think you *CAN* be 100% certain the download succeeded... You can dink around with ignore_user_abort (or not) and friends to *maybe* improve accuracy, but you'll never get 100%... -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange stuff in a class
class test { function test() { $globals['test2'] = $this; } } $test1 = new test(); The problem hier is that $globals['test2'] is a copy of $globals['test1'] not a references. Use $GLOBALS rather than $globals I think he's building his own pool of objects for object-management in $globals, rather than trying to set the value of $test2... And mucking directly with $GLOBALS is morally wrong :-) global $test2; $test2 = $this; if that's what you wanted to do, which I don't think it is. Of course, you *will* need: global $globals; if you expect this code to do anything useful. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Wildcard
IÂ’m trying to figure out how to do a search trough a MySQL db using LIKE or = but the thing is that I have 3 select boxes from where to choose the search terms. Can I use something like a wildcard instead of making several IF statements like this? SELECT * FROM table_name WHERE col1 = value1 AND col2 = value2 AND col3 = % % goes for an unselected select box (default value = %) in case the user doesnÂ’t want to make an *advanced* search, so it fetches all rows which does contains values 1 2. Here is what I would do, if I was doing what I think you're doing, which I'm not at all sure of... ?php $query = select col1, col2, ... from table_name where 1 = 1 ; if (isset($value1)){ $query .= and col1 = $value1 ; } if (isset($value2)){ $query .= and col2 = $value2 ; } if (isset($value3)){ $query .= and col3 = $value3 ; } mysql_query($query) or error_log(mysql_error()); ? The where 1 = 1 technique is a sort of yeast to allow all the subsequent parts to start with and ... If you change to OR ... then you need where 1 = 0 Think about it or work through an example to see why :-) -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: cookie ?
Do you remember to reload the page after the cookie is sent? (some browser cant see the cookie at the page it sent but first after it have been reloaded!). Actualy this is not browser issue but PHP issue No, that's just how cookies work. PHP can't get a cookie from the browser before you send it. In slow-motion: 1. Browser asks for URL 2. PHP sends cookie to browser 3. PHP sends HTML page to browser 4. Browser renders page. 5. User clicks to new URL 6. Browser sends cookie with request for new URL 7. PHP gets cookie with request for new URL PHP *CANNOT* get a cookie the browser never got, and thus never sent back, until step 7. Oh yeah: The stuff about using time/directory is an IE bug. You can supply *BOTH* time and directory, but not just time. This is not the way the Cookie spec reads, but Microsoft never reads specs properly, much less implements them properly, mostly on purpose. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Display criteria
I want to display data based on the criteria selected by the user eg click on size to display smallest to largest, or by price smallest to highest, location etc etc what is the code I need? Assuming PHP/MySQL, you'd want something not unlike: ?php if (!isset($order)){ $order = 'title'; $ascdesc = 'asc'; } $query = select title, size, price from products ; $query .= order by $order $ascdesc ; $products = mysql_query($query, $connection) or error_log(mysql_error()); echo TABLE\n; echo TR\n; echo THA HREF=$PHP_SELF?order=titleascdesc=asc^/AA HREF=$PHP_SELF?order=titleascdesc=descv/A/TH\n; echo THA HREF=$PHP_SELF?order=sizeascdesc=asc^/AA HREF=$PHP_SELF?order=sizeascdesc=descv/A/TH\n; echo THA HREF=$PHP_SELF?order=priceascdesc=asc^/AA HREF=$PHP_SELF?order=priceascdesc=descv/A/TH\n; echo /TR\n; while (list($title, $size, $price) = mysql_fetch_row($products)){ echo TRTD$title/TDTD$size/TDTD$price/TD/TR\n; } echo /TABLE\n; ? Disclaimer: I'll be damned if I can ever tell if ^ is suppose to represent ASC or DESC in these stupid interfaces. I just click until I get what I want. YMMV. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: cookies
Nope thats not they way If you don't specify a expire date it will live for ever or until you delete it. The only way is to set it with an expiry date and then it will delete it'self when the browser closes. Check this by running a file on the same domain with phpinfo(); No. If you send no expiration date, it expires when the browsers are all closed. Read the Cookie spec. Not that MS actually got all of the Cookie spec correct, but they got that part right. To erase a cookie, just do: setcookie('cookie', ''); -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: if syntax
Is that also correct?? No brackets needed? Two Comments: The alternate syntax with the colons is passe -- I think you'd have to dig pretty deep to find a script old enough that uses it for anything other than demonstration purposes. (Rasmus?) You don't *HAVE* to have {} for one-line clauses, but sooner or later, you'll end up adding a line, and then the whole thing will puke on you because you don't have {}... Thus, it is morally wrong to not have {} in all your code. This is a religious issue, and others will disagree. They're just wrong :-) -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Images in Mysql
the web server, how should the image be named [uniquely]? The problem is that if the user specifes the name of the image file, there's a chance he'll name another one the same way (and thus overwrite the original). I was thinking of maybe a dual approach, where the user gives the image file a name, but then the PHP script appends, say, the table name and record ID--so as to make the filename unique. What I do is this: ?php # Get rid of gnarly characters in filenames: $filename = ereg_replace('[^a-zA-Z0-9_\\.-]', '', $photo_name); # If their filename was so messed up that there's nothing left, give it a random name. $filename = $filename ? $filename : chr(rand(ord('A'),ord('Z'))) . chr(rand(ord('A'),ord('Z'))) . chr(rand(ord('A'),ord('Z'))) . chr(rand(ord('A'),ord('Z'))); # Now be sure it's unique: $appendix = ''; # break the filename up into 'whatever' and '.jpg' (or '.gif' or whatever it is) # In order to force uniqueness (below) I want to change 'duplicate.jpg' into 'duplicate2.jpg', not 'duplicate.jpg2' :-) $extpos = strrpos($filename, '.'); # echo extpos is $extposBR\n; if (!$extpos){ $extension = ''; } else{ $extension = substr($filename, $extpos); $filename = substr($filename, 0, $extpos); } $pathname = $directory/$filename$appendix$extension; # echo extension $extensionBR\n; # echo filename $filenameBR\n; # echo appendix $appendixBR\n; # echo pathname $pathnameBR\n; while (file_exists($pathname)){ # It's kinda hacky to ++ the empty string, but it avoids tacking on '0' # to filenames that were fine as they were... $appendix++; $pathname = $directory/$filename$appendix$extension; # echo extension $extensionBR\n; # echo filename $filenameBR\n; # echo appendix $appendixBR\n; # echo pathname $pathnameBR\n; } if (move_uploaded_file($photo, $pathname)){ # Success! } else{ # Error message } ? -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Getting PHP to read the mail!
I'm writting an autoresponder system in PHP. and I'm using wget in my cron jobs to process it. Is there a way that I can process incoming mail in PHP and call the PHP using a similar method? Basically I want to go through all the email messages checking if they are to [EMAIL PROTECTED] and if they are I would like to processes the mail body and subject line. I'm sure there are different languages to do all this in; , Perl 5.0 for example but I like PHP ;-) If you are using sendmail (or qmail) and you have access to sendmail.conf, do it just like Perl autoresponders: Change sendmail.conf to have an EXEC (?) that calls a PHP script which must live in smrsh directory and must start with: #!/path/to/php You'll want to read man smrsh and man sendmail to get started... This assumes you compiled PHP as a CGI (or CLI these days) as well as Module for Apache. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Development Tools
I am looking for a good Development tool to write my PHP in and was wondering what people are using out there. I will confess to not reading the entire thread, and if it was mentioned, I apologize, but I think ActiveState's Komodo might be worth a try-out. The Zend IDE is great for huge projects if it's in your budget. My pages are all small and easy (and I like it that way) and I have no budget :-) -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: session error ... I think
what does this mean: Warning: Cannot send session cache limiter - headers already sent (output started at /home/.edy/alexross/bleen.net/forum/discussion_fns.php:88) in /home/.edy/alexross/bleen.net/forum/index.php on line 5 On line 88 in discussion_fns.php there is an echo or print or even just some HTML, or *EVEN* just a blank line outside of ?php ? tags. That is content which PHP had to send to the browser. Now, once PHP has to send content to the browser, it had to send all the headers first, then a blank line, then the content. Pretty much, that's why headers are called headers -- They come at the head of the HTML, with a blank line in between. Once all that went out to the browser, you can't call header() function, because, like, the train has left the station. You can still send more HTML (jump on a box car) but you can't put anything on the front of the train. It's gone. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Question about PHP
Hi, I am not sure if it is a right email address to ask question, if it is not plz disregard this email :) if it is this is my Q: I am reading a book about php, in its security section, it says it is more secure, as well as more efficient when installing PHP, to install PHP as a SAPI module for your Web server that to run it via the CGI interface do you know how can I do that? what is SAPI? Thank you for your time It's definitely more efficient. A case could be made for times when using PHP as a CGI (via suExec) could be more secure for doing certain kinds of things, though. I'm not at all there there's any real security difference from Module/CGI even without the caveats. Anyway, a SAPI allows PHP to live like a wart on the back of the web server. So, like, it becomes a part *OF* the web-server which is *already* running, and waiting to serve up web pages, and if PHP is already there, it just calls the main PHP function to start doing PHP. There is ISAPI for IIS, and ASAPI for Apache and so on. API is A-something Programming Interface or some such, and it's just a fancy acronym for saying we designed a logical reasonable set of functions that you can use to interact with our software without going crazy trying to figure out all the gory details inside I think the S part is for Server. Anyway, for Apache, you just configure it --with-apxs (or --with-apache, but that's less fun) instead of the php binary in /usr/local/bin. You also configure httpd.conf with the LoadModule and AddHandler instead of the Action. (Action is for CGI) For IIS, you use the php4nts.dll or something like that and make it a filter (MicrosoftIsm for Module) instead of the php.exe For other web-servers, it's pretty much the same idea, though I got no clue how to configure them... If you're stuck with one of them, and no PHP examples are coming up, find a Perl example, and do everything the same, only plug in PHP where it says Perl. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Security with XML
I've created a db like system with XML and PHP, and I want to require a username/password to change the contents of the file. How should I go about documenting the username/password? The contents of the site aren't really all to important (no financial info or anything like that, mostly just links actually), but I don't want someone's information stolen because someone found the users.xml file and opened it. Running on a Windows 2k server with IIS5. Read the PHP Manual about HTTP Authentication -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Appending to a file
I'm just curious if there's a function that allows you to see how many lines there are in a file. I could just set up a while(!feof($fp)) { fgets($fp); count++; } obviously, but I'm curious if there's a function built in like flines($fp) that I haven't noticed at php.net? If it's a relatively small file, it might be a little faster to do: ?php $file = file(filename.txt or die(Could not open file); echo count($file); ? It will suck the whole file into an array of lines faster than you can do fgets() in PHP. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Retrieving/Displaying hyperlinked images with PHP
I am trying to build a product detail page that pulls data from a MYSQL database using PHP. The data for the page includes product images, which I am trying to link to (i.e. from their location on the web server) instead of loading the images into the database. However, I cannot find any sample code that seems to work. Two questions: There's tons of it out there... Though, I admit *finding* the working sample can be tough :-) 1. Is this possible (i.e. to store the HYPERLINK to the image in the database , and as the results are returned to the product detail screen, the image file will be displayed)? OR RATHER do I need to store the physical image file in the database location and query it that way? Not only do you not need to store the image data in the db, it's a Bad Idea (tm), as often discussed here. 2. The code sample below contains several lines that show a field populated with text that I am returningthe line under the //Test comment is the field that I'm trying to pull an image back for: printf(REL_PLAN7: %sbr\n, mysql_result($result,0,REL_PLAN7)); printf(REL_PLAN8: %sbr\n, mysql_result($result,0,REL_PLAN8)); printf(REL_PLAN9: %sbr\n, mysql_result($result,0,REL_PLAN9)); //test printf(mysql_result($result,0,a href=FRONT_RENDFRONT_REND/a); NOTE: FRONT_REND is the name of the database field, and it contains a full web address, not relative. H. Try to think of it this way. PHP just spews out HTML. I need to spew out the HTML for my web-browser to display an image. That HTML looks like: IMG SRC=blahblahblah.jpg Or, if you want a link to that image, you'd use: A HREF=blahblahblah.jpgFront Rendering/A (or something like that) So, your code should be something not unlike: printf(IMG SRC=%s, mysql_result($result, 0, 'FRONT_REND')); or perhaps you want: printf(A HREF='%s'Front Rendering/A, mysql_result($result, 0, 'FRONT_REND')); That said, let me point out a few Big Picture issues. printf is incredibly useful for spitting out highly-detailed formatted text, but it's also a bit slower than echo. So, really, echo is probably going to be a better work-horse for you in the long run. Secondly, calling mysql_result() over and over and over instead of mysql_fetch_row() once... Well, that's a lot slower. So, ideally, your code should look more like: # Maybe in a while loop, maybe not... list($plan7, $plan8, $plan9, $front_rend) = mysql_fetch_row($result); echo $plan7BR\n; echo $plan8BR\n; echo $plan9BR\n; echo IMG SRC='$front_rend'BR\n; echo A HREF='$font_rend'Front Rendering/ABR\n; You might even have THUMBNAIL path in your database, as well as a FULLSIZE path for your images: echo A HREF='$fullsize'IMG SRC='$thumbnail'/ABR\n; -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with Configure Options
I am thinking of moving PHP-based web site to a new server. In doing my due diligence, I see that the new server has some different PHP configure options. I was able to make sense of most of them by looking through the PHP web site. But I'm still stumped by some of them. I'm hoping people here can tell me what they mean: --enable-libgcc: I found the 1-line explanation on www.php.net, but I'm unclear as to the implications of this option. Can anyone explain? I think it specifically tells gcc to link with the right thing, even though that's what it's going to do anyway... Unless you're using some really funky set up with weird things going on... --enable-pic: likewise. What does this mean? PIC has something to do with compilation issues... I think you can almost always ignore this one. --enable-inline-optimization: ?? If your computer is a *REAL* dog and has no RAM and no swap space, you can use this to get PHP to compile... It will take *FOREVER*, but it will work. Otherwise, the compiler might puke on you claiming you don't have enough RAM or something. --with-regex=system: the online docs say this is deprecated. Could this cause me trouble? YES!!! Big Trouble. Your OS has a Regex built-in to it. PHP has a Regex in it as well. Apache has a Regex in it as well. *IF* you forced Apache to use the OS Regex and not its own, and *IF* you force PHP to use the System Regex and not its own, you just *MIGHT* be okay, only you'll be using a Regex not quite like anybody else on the planet trying to help you will think you're using, and a lot of third-party code will break and some of the more complicated examples won't work, and... Short answer: Don't do it. --with-flex: ? Wild Guess: I suppose if you really worked at it you could put bison and flex and all that crap into some really weird place where ./configure won't be able to find it, and then you could use this to tell PHP where the hell you put flex... --with-png: I know what PNG is, but I don't know hat this option does. Tells GD that you not only want GD, but you want GD to be able to actually create/manipulate PNG files. --with-gd all by itself is useless. (Okay of limited use) You gotta also say if you want PNG and/or JPEG and/or whatever else GD can do this week. Ditto for PDF and Flash and so on, I think. You are kinda stuck using the same answer (Yes, I want PNG) for any packages that have PNG as an optional plug-in... I think. It also lets you tell PHP where the hell you installed PNG, which is important. --with-layout=GNU: I see the explanation in the docs, but I don't know if this has any implications for me as a PHP programmer. Probably not. I never used it. I think it just changes where PHP is going to install all the files it creates when it's done. If you leave it alone, you'll be the way most examples and tutorials expect you to be. If you mess with it, you'll have to translate any tutorials into your own setup. For all of these, leave them alone, and let ./configure do the usual, unless you *REALLY* know what you are doing, or just want to learn some very arcane stuff. :-) -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: is their a jobs mailing list?
But I found nothing about a jobs mailing list. I'm really a Perl programmer and we have jobs.perl.org which has a list which does a really good job. There used to be a nifty jobs database tied into php.net, but I think it was not getting utilized well, and the original author ended up having less time for maintenance than he'd hoped, and... Meanwhile, back at the ranch, scroll to the bottom of this link, which I found by searching php.net for Jobs (whole site, not just function names): http://www.php.net/links.php I dunno about these days, but I would hazard a guess that Job Openings would be kinda nifty, whereas people posting resumes would be pretty damned annoying. Just my opinion, and I haven't been back long enough to know for sure :-) As far as those plotting to *BUILD* a PHP jobs application, I'll throw out some comments to the wind: 1. Since there used to be such a best on php.net, and it seems to have gone, I can only surmise that PHP Developers are not *opposed* to the idea, but I suspect they will be leery of repeating whatever went wrong the first time around. I'd hazard a guess that it was (1) lack of a dedicated maintainer to develop it, and/or (2) lack of actual JOBS AVAILABLE postings. You may even be in a situation where it's more of a you build it first and then we'll believe it from the PHP Dev team given the history... THIS IS JUST A GUESS I AM NOT ON THE TEAM I COULD BE 100% WRONG AND OFTEN AM!!! Usually because the PHP Dev guys are just plain way nicer than I am :-) 2. This is a *HUGE* project you're suggesting. *HUGE*. If you don't have real experience in a Project this *HUGE* you really have no idea what you are biting off, and it's going to choke you. 3. There are a ton of job sites out there and some even let you plug in PHP as a known technology, and some of those are even aggressively managed/marketed by head-hunter-like industry people who are working this thing to the bone. What is really going to drive the traffic to the PHP version? I think the old one got few JOBS AVAILABLE, so got few Developers, so never really took off. It would be another MONUMENTAL task to take on the duty of enticing Job Posters to use it. Don't get me wrong -- I'd love for a really good jobs.php.net to exist with tons of work for everybody (self included). But really think this one through before you start folks, and do some basic homework about why the previous incarnation disappeared. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Execute script then output image.
Sorry, I lost the email that contained the info and I can't find it in the archives. How do I output a static image through a php script? it had something to do with headers but I can't remember exactly what. -- JJ Harrison [EMAIL PROTECTED] www.tececo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: cookies
Surely it would be better to use Sessions in this case? Danny Shepherd [EMAIL PROTECTED] wrote in message 08c501c22825$932917c0$0200a8c0@DANNYS">news:08c501c22825$932917c0$0200a8c0@DANNYS... No, I just tested it myself - if you set a cookie with no expire date it exists until the browser window is closed. My code: ?php if (!isset($_COOKIE['TestCookie'])) { setcookie (TestCookie, FUD); echo Just Set a cookie - reload the page; } else { echo Cookie is : {$_COOKIE['TestCookie']}brClose the window then return and the cookie should be gone; } ? HTH Danny. - Original Message - From: vins [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 10, 2002 3:34 PM Subject: [PHP] Re: cookies Nope thats not they way If you don't specify a expire date it will live for ever or until you delete it. The only way is to set it with an expiry date and then it will delete it'self when the browser closes. Check this by running a file on the same domain with phpinfo(); Alexander Ross [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... How can I set a cookie which expires when the borwser is closed?? How can I delete a cookie via PHP? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Character Array
Is there an easy way to get an array of characters from a string? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Character Array
On Thu, 11 Jul 2002 12:08:59 +0100, you wrote: Is there an easy way to get an array of characters from a string? $str = 'string'; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); from http://www.php.net/manual/en/function.preg-split.php djo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sort problem
If he has a top-ten report... is that a one-off thing? Or is it a weekly thing? Or is that every time his report get's into the top ten (in which case hovering around 10-11 would be the best bet!!)?? You need to decide WHEN the user is awarded the 50 points for being in the top ten. For example, if this was judged weekly, then you could write a small script which is run weekly, awarding 50 points to the user_id's in the top 10 ratings... easy, but what happens to the guy who had something in there for Sun-Thur, and you run the job on Friday? Not good. Or perhaps the points are awarded each time the top 10 changes... can't imagine why!! Yuk! Or maybe you can only be awarded the 50 points ONCE, the FIRST time you're in the top ten, in which case, I'd add a 4th field to Table reports, flagging it as once a top ten, and apply the 50 points at that point. Like I said, you need to define when this happens, so that we can figure out the best way... or perhaps you'll figure it out for yourself after you have a think about WHEN the 50 points are applied. Justin French on 11/07/02 7:30 PM, andy ([EMAIL PROTECTED]) wrote: ok here we go: Table 1 user_table id points Table 2 reports report_id user_id rating The goal is to associate every user extra 50 points if he has a top 10 report. Top 10 report means the 10 reports with the highest ranking. This value is always changing, thats why I did not include it to the other points. Now that we have the users with the additional points we could add them to the total points of the user and then find out the 5 users with the highest total points. Thats the theory, but how to achieve this in real live?? Thanx for any idas, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Table Making
I hate to think what sort of a burden this would place on ther server, but... You could always find out how many rows there are, then run individual queries for each cell of the table. In other words, to achieve this layout: 1 4 7 2 5 8 3 6 9 You would do queries in this order: 1 4 7 2 5 8 3 6 9 Like I said, I shudder at the thought of how much this would load the server (especially on large rows (lots of fields) or large tables (lots of rows = lots of queries)), but if the layout is imperative, then maybe this is an option... I can't see why you can't run it as 1 2 3 4 5 6 7 8 9 Cheers, Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Character Array
Is there an easy way to get an array of characters from a string? $str = 'string'; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); A string is already an array of chars : $toto=test; echo $toto[0]; // prints t echo $toto[1]; // prints e echo $toto[2]; // prints s echo $toto[3]; // prints t -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FW: [PHP-WIN] More bzip woes! No file written...
I know it is cross-posting, but I thought I might get an answer here... TIA, Mikey -Original Message- From: Mikey [mailto:[EMAIL PROTECTED]] Sent: 09 July 2002 19:51 To: [EMAIL PROTECTED] Subject: [PHP-WIN] More bzip woes! No file written... Hi ng! Well, I have finally managed to make my archive (thanks to being set on the right track by this ng), yet I am having a problem using the bz2 functions... The code I am using to make the compressed file is as follows: $data = implode (, file ($filename.tar)); $bz = bzopen ($filename.bz2, wb); bzwrite ($bz, $data); bzclose ($bz); (The tar file has been created previously in the script.) I have checked permissions on the directory in question (I have even opened them wide up for dev purposes) and yet the script fails withthe following error: Warning: bzopen(): Unable to open file in e:\apache\splatted.net\download_basket.php on line 53 Has anyone here got any ideas? regards, Mikey -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execute script then output image.
On Thu, 11 Jul 2002 21:00:36 +1000, you wrote: How do I output a static image through a php script? it had something to do with headers but I can't remember exactly what. You need to output the correct content-type header for the image (eg image/gif), take it's size and output it as content-length, and suppress error reporting. Then output the image data. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execute script then output image.
There was a much simpler way. It just said the location of the file. I could use your method but the other one was much simpler. -- JJ Harrison [EMAIL PROTECTED] www.tececo.com David Otton [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Thu, 11 Jul 2002 21:00:36 +1000, you wrote: How do I output a static image through a php script? it had something to do with headers but I can't remember exactly what. You need to output the correct content-type header for the image (eg image/gif), take it's size and output it as content-length, and suppress error reporting. Then output the image data. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Character Array
On Thu, 11 Jul 2002 13:50:59 +0200, you wrote: Is there an easy way to get an array of characters from a string? $str = 'string'; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); A string is already an array of chars : $toto=test; echo $toto[0]; // prints t echo $toto[1]; // prints e echo $toto[2]; // prints s echo $toto[3]; // prints t Not really; a string is better described as a type that has some properties in common with the array type. Consider these two examples: ? $str = Hello World!; $str = array_reverse($str); echo ($str); ? ? $str = Hello World!; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); $str = implode('', array_reverse($chars)); echo ($str); ? djo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Character Array
Hello, IMHO string is array of characters so is possible: $str = 'string'; for ($i = 0; $ count($str); $i++) echo $str[$i]; Regards, Michal Dvoracek [EMAIL PROTECTED] Capitol Internet Publisher, Korunovacni 6, 170 00 Prague 7, Czech Republic tel.: ++420 2 3337 1117, fax: ++420 2 3337 1112 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execute script then output image.
On Thu, 11 Jul 2002 22:01:03 +1000, you wrote: You need to output the correct content-type header for the image (eg image/gif), take it's size and output it as content-length, and suppress error reporting. Then output the image data. There was a much simpler way. It just said the location of the file. I could use your method but the other one was much simpler. Is this what you meant? http://news.php.net/article.php?group=php.generalarticle=106348 http://news.php.net/article.php?group=php.generalarticle=106370 Looks like the same thing I suggested to me... $filename = your/file.gif; // output the correct content-type header header(Content-Type: image/gif); // take it's size and output it as content-length header(Content-length:.filesize($filename)); // Then output the image data readfile($filename); djo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session_start and HTTP headers in Mozilla, plz help
Hi! I've run across a problem when using session_start and HTTP headers in Mozilla. I'm trying to write a snippet of code that checks whether a user has logged in or not. If the user has a session variable set I want to display the page and if he or she hasn't I want to give them a 403 Forbidden header. My current code looks like this: [top of page] ?php // Start session handling session_start(); // Check login if (isset($HTTP_SESSION_VARS[xyz]) and $HTTP_SESSION_VARS[xyz] == yes) { ? html [page contents] /html ?php } else { header(HTTP/1.0 403 Forbidden); } ? [end of page] This works perfectly in IE 6 (I get a 403 Error Message) but in Mozilla I just get an empty page (containing just the html and head tags). Most other headers seem to work though. If I use header(Location: somepage.php) both Mozilla and IE correctly redirects the browser. I don't know if it's a bug in IE or Mozilla or if I'm plain stupid, but perhaps someone else has experienced this and are willing to give me a hint? Thanks /lasso -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MAIL FROM NO ONE
Hi... I've just checked out a script from hotscripts.com that send email from and smtp server... I've managed to say the email has come from a server that doesn't exist but the email can still be traced... is there know way to build a php smtp server ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Development Tools
I've picked up PHPed, Zend IDE, and Dreamweaver MX. - ZendIDE has the best code-completion and editing features out of all of them, best auto-tabs and auto completes. - PHPed is ok, better with database and total MySQL development then Zend IDE. - Dreamweaver MX has limited PHP support but it is far superior on the front end than the other two. If only there were a ZendEd MX, hah. On Thu, 2002-07-11 at 06:33, Richard Lynch wrote: I am looking for a good Development tool to write my PHP in and was wondering what people are using out there. I will confess to not reading the entire thread, and if it was mentioned, I apologize, but I think ActiveState's Komodo might be worth a try-out. The Zend IDE is great for huge projects if it's in your budget. My pages are all small and easy (and I like it that way) and I have no budget :-) -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- This email was sent with Ximian Evolution. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 4.3.0-dev and gd
trying to get the built in gd to work without luck I am using redhat and it has gd 1.8.4(or something) but the newer compiled version does not seem to install. I check with phpinfo and it just says 1.6.2 or higher but none of the 2.* functions work so I assume the new gd did not install. my config line looks like this.. ./configure --with-apxs=/usr/sbin/apxs --with-mysql=/usr --with-ttf=/usr --enable-track-vars --enable-ftp --enable-imap --enable-ssl --enable-versioning --enable-trans-sid --enable-sysvsem --with-config-file-path=/etc --with-gd kind regards Kev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] HELP using Next() in session array
Hey .. for some un known reason .. next doesnt work properly on session array ... when the code below gets execuded .. next only traverses to a seconde element :( IS it a bug or just me? -- CODE - ? class questionData { var $Question; var $Help; var $Answer; } session_start(); if(!session_is_registered('_SESSION_program')){ session_register('_SESSION_program'); $questionData = new questionData (); $questionData-Question = 1; $questionData-Help = 1; $_SESSION_program [] = $questionData; $questionData-Question = 2; $questionData-Help = 2; $_SESSION_program [] = $questionData; $questionData-Question = 3; $questionData-Help = 3; $_SESSION_program [] = $questionData; $questionData-Question = 4; $questionData-Help = 4; $_SESSION_program [] = $questionData; $questionData-Question = 5; $questionData-Help = 5; $_SESSION_program [] = $questionData; $questionData-Question = 6; $questionData-Help = 6; $_SESSION_program [] = $questionData; $questionData-Question = 7; $questionData-Help = 7; $_SESSION_program [] = $questionData; $questionData-Question = 8; $questionData-Help = 8; $_SESSION_program [] = $questionData; } ? html head titleUntitled Document/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body form name=form1 method=get action=?=$_SERVER['PHP_SELF']? input name=programAction type=submit id=programAction value=Prev input name=programAction type=submit id=programAction value=Next /form ? if(isset($programAction) $programAction =='Next') print_r(next ($_SESSION_program)); if(isset($programAction) $programAction =='Prev') print_r(prev($_SESSION_program)); ? ? $obj = current ($_SESSION_program); echo $obj-Help; ? /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Development Tools
I usually always have my content dynamically generated by functions, or displayed in include files. I'm not a fan of cluttering up my apps with content. Martin Clifford http://www.completesource.net (Now Open!) Lazor, Ed [EMAIL PROTECTED] 07/10/02 05:38PM I am too. I've developed an approach to coding with Dreamweaver that allows me to take advantage of WYSIWYG and my own style of coding at the same time. The MX version of Dreamweaver is supposed to add support for code snipets, and a few other things. I'm looking forward to checking them out. Oh, and Dreamweaver has provided the most efficient WYSIWYG created code that I've seen so far. So... what do you do when it comes to creating actual content that's separate from the coding? My personal approach has been doing the coding necessary to create templates and then opening templates in Dreamweaver and filling in the blanks. -Ed -Original Message- WYSIWYG does nothing more for me than screw up my code. I'm very anal about how my code looks, firstly. Secondly, most WYSIWYG editors add superfluous markup into code which not only inflates the file size of your documents, but also slows down processing of them. I'm not saying that WYSIWYG isn't right for you, because obviously it is. I'm just saying that, to me, it might as well be fingernails running down a chalkboard for all the good it *doesn't* do me, personally. This message is intended for the sole use of the individual and entity to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message. Thank you very much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to know upload progress status
Thanks for informations, I'll try to work on a different approach, maybe analyzing the dimension of the temporary file during upload (if it is possible identify the temporary file and monitoring it with another script). Thanks for your help, S. Il 11:55, giovedì 11 luglio 2002, val petruchek ha scritto: I don't know how to extract informations about upload progress status and how to show informations to users. For example I want the users can see 30% of upload completed, or the MByte just uploaded. It's impossible. PHP script starts when file is 100% uploaded on the server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie Logical opertaor question
I have been trying this to no avail. Tryng to say the equivalent of: IF (var1 = 1 AND var2 = a or b or c) i.e. yield true if 1 and a OR 1 and b OR 1 and c :-) Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Postal / Zip Code Proximity Search
On Thu, Jul 11, 2002 at 03:11:08AM -0500, Richard Lynch wrote: uname -a gives me: OpenBSD o2 2.9 conf#0 i386 But I don't even know how to get the /proc/sysinfo or whatever it is under this OS... less /var/run/dmesg.boot works on my ISP's NetBSD system. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Table Making
This is one way of doing it: - calculate how many rows are needed given the total number of records (mysql_num_rows()) and how many columns you want. - loop through all records and store them in a two-dimensional array starting at arr[0][0] to arr[maxrows][0] and then increment the 'column' and store arr[0][1] to arr[maxrows][1] etc. - loop through the array the other way round and create the html-table. So start with arr[0][0] to arr[0][4] etc. Make any sense? Another way of doing it is to use mysql_data_seek() to jump back and forth in the result set. Regards Joakim Andersson -Original Message- From: Jason Soza [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 11, 2002 8:05 AM To: PHP-General Mailing List Subject: [PHP] Table Making I'm driving myself crazy trying to visualize what I want to do, so I thought I'd share the insanity and hope for some advice. I have this nice piece of code to take my SQL result and organize it into a nice 5 column table: print centertable width=\100%\ border=\0\\n; //start table $i=0; //define variable - avoid errors $grad_year=;//define variable - avoid errors while ($row = mysql_fetch_array($sql)) { extract($row); $i++; if($i==1) { print tr\n; //start table row on $i = 1 } printf(td align=\center\a href=\year.asp?year=%s\%s/abr/td\n, $grad_year, $grad_year); //print links if ($i==5) { print /tr\n; //end table row on $i = 5 to get 5 columns $i=0; //reset $i } $grad_year=; //clear $grad_year } if ($i5) print /tr\n; //end any rows with less than 5 columns print /table/centerp\n; //end table ---END Now, this works great for most things - it takes my SQL results and puts them in a table sequentially, from left to right, top to bottom. So in this case, the top-left cell displays 1941, the top-right cell displays 1945, the next row starts with 1946 on the left and goes to 1950 on the right, and so on. What I want is rather than sorting left to right, top to bottom, I want to sort top to bottom, left to right. So the top-left would still be 1941, but rather than increasing to the right, it would increase down, then continue at the top of the next column. I'm thinking this might be an easy thing to do with some creative use of $i and print, but I just can't think it out. I'm guessing $i would be used to limit the amount of items in a column... But, I'm in need of some guidance to get it right. I can't even begin to think where to start. Any help would be great - thanks! Jason Soza -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generating word documents based on fields in a browser
? $word=new COM(word.application) or die(Cannot start MS Word); print Loaded word version ($word-Version)\n; $word-visible = 1 ; $word-Documents-Add(); $word-Selection-Typetext(This is a test); ? does anyone recognise this? Oh yes - this would be Word via COM - if you are having problems getting this to work, I would suggest consulting the VBA reference manual that comes with Office - it will give you the methods/objects available to you, as well as examples of how to use them... Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Logical opertaor question
You'd have to separate it like so: if($var1 == 1 AND ($var2 == a OR $var2 == b OR $var2 == c) { // do stuff here if true } else { // do stuf here if false } HTH Martin Clifford http://www.completesource.net (Now Open!) Rw [EMAIL PROTECTED] 07/11/02 09:11AM I have been trying this to no avail. Tryng to say the equivalent of: IF (var1 = 1 AND var2 = a or b or c) i.e. yield true if 1 and a OR 1 and b OR 1 and c :-) Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Logical opertaor question
Fixing the below, since it would produce a parse error (I forgot a parenthesis, hehe) Martin Clifford http://www.completesource.net (Now Open!) Martin Clifford [EMAIL PROTECTED] 07/11/02 09:29AM You'd have to separate it like so: if($var1 == 1 AND ($var2 == a OR $var2 == b OR $var2 == c)) { // do stuff here if true } else { // do stuf here if false } HTH Martin Clifford http://www.completesource.net (Now Open!) Rw [EMAIL PROTECTED] 07/11/02 09:11AM I have been trying this to no avail. Tryng to say the equivalent of: IF (var1 = 1 AND var2 = a or b or c) i.e. yield true if 1 and a OR 1 and b OR 1 and c :-) Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MS SQL Server and ODBC
I am attempting to connect to a MSSQL 2000 database from a linux box. I have installed freetds successfully and configured php with sybase as directed by freetds. I configured the freetds .conf file. However this is where I have questions. The freetds.conf file only asks for the ip address of the database server. I have mulitple databases on my database server. How do I specify the database that I'm trying to reach? Are there any configuration flags that I could be missing to use odbc_connect, etc.? Any help would be greatly appreciated. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MS SQL Server and ODBC
I don't really know much about freetds so this could all be wrong, but... when you set-up a DSN on a server, the database is specified there - hope this helps. Mikey Tim Nields [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am attempting to connect to a MSSQL 2000 database from a linux box. I have installed freetds successfully and configured php with sybase as directed by freetds. I configured the freetds .conf file. However this is where I have questions. The freetds.conf file only asks for the ip address of the database server. I have mulitple databases on my database server. How do I specify the database that I'm trying to reach? Are there any configuration flags that I could be missing to use odbc_connect, etc.? Any help would be greatly appreciated. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sort problem
On Thu, Jul 11, 2002 at 11:30:16AM +0200, andy wrote: Table 1 user_table id points Table 2 reports report_id user_id rating The goal is to associate every user extra 50 points if he has a top 10 report. Top 10 report means the 10 reports with the highest ranking. This value is always changing, thats why I did not include it to the other points. Now that we have the users with the additional points we could add them to the total points of the user and then find out the 5 users with the highest total points. There are probably a couple ways to do this. This is the one that hits me off the top of my head, assuming you're using a version of MySQL which can't do subqueries. Now, all of this is untested, so my query syntax may be off a tad, but it'll give you the idea of where to go... Do the following intermittently on a scheduled basis: 1) Make a third table. It'll hold temporary data. user_id totalscore 2) LOCK TABLES Table3 READ 3) DELETE FROM Table3 WHERE 1=1 4) INSERT INTO Table3 (user_id, totalscore) SELECT user_id, 20 AS sc FROM Table2 ORDER BY rating LIMIT 10 5) INSERT INTO Table3 (user_id, totalscore) SELECT id, points FROM Table1 6) UNLOCK TABLES Now, whenever you want to generate the top 5 list use the following query SELECT user_id, SUM(totalscore) AS thescore FROM Table3 GROUP BY user_id ORDER BY SUM(totalscore) LIMIT 5 If you can create subqueries, then you don't need the third table and can write one nice query, something like this... SELECT id, sc+points AS totalscore FROM Table1 LEFT JOIN (SELECT user_id, 20 AS sc FROM Table2 ORDER BY rating LIMIT 10) ON (Table1.id = Table2.user_id) ORDER BY sc+points LIMIT 5 --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: setcookie then redirect
Hi David, Your question has seen much debate in this newsgroup. I had much the same problem and solved it by writing the following function: /** * wrapper for header( Location: url ) */ function redirect( $url, $showMoved=false ) { // set refresh to target $url header( Refresh: 0; url=$url ) ; // show page has moved if ( $showMoved ) { echo htmlheadtitleMoved to $url/title/headbodypThis page has moved to a href=\$url\$url/a./body/html ; } // exit current script exit ; } Since it doesn't use header( Location: ... ) you are able to write your cookies before you redirect. It's about the most elegant solution to your problem, short of redesigning your pages. Of course, I have noticed that if you don't supply the html ($showMoved) Opera chokes. IE and Netscape seem to handle it fine and I haven't tested Mozilla yet. Hope it helps! Cord David Busby [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... List, I'm trying to set a cookie like this: ?php function redirect() { [..snip..] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL Server and ODBC
Check out the mssql_select_db function. Call it right after the connection open. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 12:31, Tim Nields wrote: I am attempting to connect to a MSSQL 2000 database from a linux box. I have installed freetds successfully and configured php with sybase as directed by freetds. I configured the freetds .conf file. However this is where I have questions. The freetds.conf file only asks for the ip address of the database server. I have mulitple databases on my database server. How do I specify the database that I'm trying to reach? Are there any configuration flags that I could be missing to use odbc_connect, etc.? Any help would be greatly appreciated. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL Server and ODBC
Errr - doesn't that function apply to mySQL databases only? Mikey Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Check out the mssql_select_db function. Call it right after the connection open. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 12:31, Tim Nields wrote: I am attempting to connect to a MSSQL 2000 database from a linux box. I have installed freetds successfully and configured php with sybase as directed by freetds. I configured the freetds .conf file. However this is where I have questions. The freetds.conf file only asks for the ip address of the database server. I have mulitple databases on my database server. How do I specify the database that I'm trying to reach? Are there any configuration flags that I could be missing to use odbc_connect, etc.? Any help would be greatly appreciated. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL Server and ODBC
I wouldn't have said it if it did. Notice that it's MSSQL_select_db not MYSQL_select_db. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 10:03, Michael Davey wrote: Errr - doesn't that function apply to mySQL databases only? Mikey Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Check out the mssql_select_db function. Call it right after the connection open. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 12:31, Tim Nields wrote: I am attempting to connect to a MSSQL 2000 database from a linux box. I have installed freetds successfully and configured php with sybase as directed by freetds. I configured the freetds .conf file. However this is where I have questions. The freetds.conf file only asks for the ip address of the database server. I have mulitple databases on my database server. How do I specify the database that I'm trying to reach? Are there any configuration flags that I could be missing to use odbc_connect, etc.? Any help would be greatly appreciated. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL Server and ODBC
doh! Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I wouldn't have said it if it did. Notice that it's MSSQL_select_db not MYSQL_select_db. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 10:03, Michael Davey wrote: Errr - doesn't that function apply to mySQL databases only? Mikey Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Check out the mssql_select_db function. Call it right after the connection open. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 12:31, Tim Nields wrote: I am attempting to connect to a MSSQL 2000 database from a linux box. I have installed freetds successfully and configured php with sybase as directed by freetds. I configured the freetds .conf file. However this is where I have questions. The freetds.conf file only asks for the ip address of the database server. I have mulitple databases on my database server. How do I specify the database that I'm trying to reach? Are there any configuration flags that I could be missing to use odbc_connect, etc.? Any help would be greatly appreciated. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL Server and ODBC
However, this still wouldn't work for ODBC... Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I wouldn't have said it if it did. Notice that it's MSSQL_select_db not MYSQL_select_db. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 10:03, Michael Davey wrote: Errr - doesn't that function apply to mySQL databases only? Mikey Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Check out the mssql_select_db function. Call it right after the connection open. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 12:31, Tim Nields wrote: I am attempting to connect to a MSSQL 2000 database from a linux box. I have installed freetds successfully and configured php with sybase as directed by freetds. I configured the freetds .conf file. However this is where I have questions. The freetds.conf file only asks for the ip address of the database server. I have mulitple databases on my database server. How do I specify the database that I'm trying to reach? Are there any configuration flags that I could be missing to use odbc_connect, etc.? Any help would be greatly appreciated. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: if syntax
-Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED]] Sent: 11 July 2002 10:54 The alternate syntax with the colons is passe -- I think you'd have to dig pretty deep to find a script old enough that uses it for anything other than demonstration purposes. (Rasmus?) What utter tosh! *All* my scripts use the alternative syntax, as I think braces are an eyesore and an abomination, and cause more problems than they solve. I've pretty much lost count of the number of times I've seen code written like this: if (x) { while (y) { ... } // end while ... } // end if when it would be just as easy, and more functional, to write this (even saves a few characters, too!): if (x): while (y): ... endwhile; ... endif; Another advantage to the alternative syntax is that it can improve error reporting (slightly). Consider the following: if () { ; while () { ; for () { ; } } PHP will tell you you have a syntax error on the very last line of your file, and you have no option but to go back and laboriously hand match all of your braces -- and with each ellipsis representing maybe tens (or even hundreds!) of lines of code and/or HTML, that's a big job. Now suppose you wrote it like this instead: if (): ; while (): ; for (): ; endwhile; endif; Now PHP will throw an error at the endwhile, because it knows there's an endfor missing -- and you've already cut out a large chunk of your code to check; better yet, as you're checking you can see at a glance what each end should be matching. And every end has to be there, too -- no cursing yourself for that lazy day when you left out a few comments on some unimportant closing braces! /rant Just my two penn'orth. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generating word documents based on fields in a browser
Thanks for all the info, i have found a temporary solution which i am currently going to develop If anyone is interested, I found the following at http://www.pscode.com/xq/ASP/txtCodeId.625/lngWid.8/qx/vb/scripts/ShowCode.h tm Thanks Again Craig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL Server and ODBC
Ofcourse not. I didn't say it would. ODBC and FreeTDS (which is what he said he was using) are two totally different drivers. Thats like saying mysql_select_db wouldn't work for Oracle databases, ofcourse they wouldn't, there different drivers. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 10:08, Michael Davey wrote: However, this still wouldn't work for ODBC... Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I wouldn't have said it if it did. Notice that it's MSSQL_select_db not MYSQL_select_db. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 10:03, Michael Davey wrote: Errr - doesn't that function apply to mySQL databases only? Mikey Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Check out the mssql_select_db function. Call it right after the connection open. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-07-11 at 12:31, Tim Nields wrote: I am attempting to connect to a MSSQL 2000 database from a linux box. I have installed freetds successfully and configured php with sybase as directed by freetds. I configured the freetds .conf file. However this is where I have questions. The freetds.conf file only asks for the ip address of the database server. I have mulitple databases on my database server. How do I specify the database that I'm trying to reach? Are there any configuration flags that I could be missing to use odbc_connect, etc.? Any help would be greatly appreciated. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php