[PHP] Re: dynamic class loaders
[EMAIL PROTECTED] wrote: Hi there i was wondering if there is such an extension available or possbility to have a dynamicclass loader extension which would use the request_uri as loading the class constructors ? I justthink building such a thing in php which is what i am doing too slow for each request and think itshould happen in the internals ? Let me know if its an insane idea. PHP5 provides autoload, see http://at2.php.net/manual/en/language.oop5.autoload.php for details. HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP script problem (with MySQL)
May I sugest that you assemble the SQL statement in a different way? With such a big conditional, it will slow down the Sql server. if ($tit != '') $condition .= and tit1 like '%$tit%'; and so on for each search field ... $sql = Select *, substring(loc1, 1, 3) as loc1 from openart_table where . substr($condition,4); 'like' conditions are hard on the server, specially if they start with a '%' since then no indexes can be used. The server can only go through each and every single record in the database. If, instead, you avoid the % at the begining, some index information can be used. You might also want to check FullText searches Satyam Sugimoto [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I need your help about PHP (ver 4.3.1) and MySQL (ver 3.23) database. I am struggling to customise a database (using left command etc), and am stuck now. Please have a brief look at my scripts below. What I do like to do is to get first 3 letters from loc1 column from openart_table (MySQL). And show the data in the follwoing part... td? echo $row[loc1]; ?br/td but also I would like to make hyperlinks to jpg files to images/the first 3 letters from loc1.jpg So it will be something like this... td a href=/image/? echo $row[loc1]; ?.jpg? echo $row[loc1]; ?/abr /td But when I tried, select left (loc1,3) from openart_table where.. doesnt work properly. I do not want to destroy anything for the rest of the table. I need all data from tit1, pub1, id1, and ref1 in each column. Could you show me a script example? Could you help me, please? Thank you. -PHP script from here html body table border=1 bordercolor=black cellspacing=0 align=center BGCOLOR=#CC width=900 tr bgcolor=#ffcc66 td align=centerbID No/bbr/td td align=center BGCOLOR=#CC3366bBook Title/bbr/td td align=centerbPublisher/bbr/td td align=centerbID/bbr/td td align=centerbReference/bbr/td td align=center width=10%bLocation/bbr/td /tr ? mysql_connect(localhost,root,cheers); mysql_select_db(openart); if($tit == $res == $pub == $date == $id == $ref == $loc == $type == $vol == $fre == $note == ) { echo 'Type something'; } elseif($tit == % || $res == % || $pub == % || $date == % || $id == % || $ref == % || $loc == % || $type == % || $vol == % || $fre == % || $note == %){ echo 'Not Valid'; } else{ if($tit == ){ $tit = '%'; } if($res == ){ $res = '%'; } if($pub == ){ $pub = '%'; } if($date == ){ $date = '%'; } if($id == ){ $id = '%'; } if($ref == ){ $ref = '%'; } if($loc == ){ $loc = '%'; } if($type == ){ $type = '%'; } if($vol == ){ $vol = '%'; } if($fre == ){ $fre = '%'; } if($note == ){ $note = '%'; } $result = mysql_query(select * from openart_table where tit1 like '%$tit%' and res1 like '%$res%' and pub1 like '%$pub%' and date1 like '%$date%' and id1 like '%$id%' and ref1 like '%$ref%' and loc1 like '%$loc%' and type1 like '%$type%' and vol1 like '%$vol%' and fre1 like '%$fre%' and note1 like '%$note%' order by tit1); $rows = mysql_num_rows($result); echo $rows,Records Found p; while($row = mysql_fetch_array($result)){ ? tr tda href = openart_detail.php ?iden=? echo $row[openart_id] ?? echo $row[openart_id]; ?/abr/td td? echo $row[tit1]; ?br/td td? echo $row[pub1]; ?br/td td? echo $row[id1]; ?br/td td? echo $row[ref1]; ?br/td td? echo $row[loc1]; ?br/td /tr ? } } ? /table /body /html end of script -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thanks but problem again! Re: [PHP] PHP script problem (with MySQL)
On Wednesday 20 April 2005 06:07, Sugimoto wrote: (B Thank you, Richard, (B (B I simply change this part (B (select * from openart_table) into (B (select substring(loc1, 1, 3) as THREE_LETTER_CODE, * from openart_table) (B but Ive got this error, whats wrong with it? (B (B Warning: mysql_num_rows(): supplied argument is not a valid MySQL result (B resource in c:\apache..\openart\test\openart_search.php on line 98 (B Records Found (B (BWhy don't you try the query in the mysql console? You'll see what it returns (Band debug the error easily. (B (B (B Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result (B resource in c:\apache\openart\test\openart_search.php on line 100 (B (B Cheers (B (B-- (B (BCyberly yours, (BPetar Nedyalkov (BDevoted Orbitel Fan :-) (B (BPGP ID: 7AE45436 (BPGP Public Key: http://bu.orbitel.bg/pgp/bu.asc (BPGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436 pgpBAtVz6F3Ky.pgp Description: PGP signature
Re: [PHP] dynamic class loaders
On Wednesday 20 April 2005 06:28, [EMAIL PROTECTED] wrote: Hi there i was wondering if there is such an extension available or possbility to have a dynamicclass loader extension which would use the request_uri as loading the class constructors ? I justthink building such a thing in php which is what i am doing too slow for each request and think itshould happen in the internals ? Let me know if its an insane idea. Use the autoload extension. http://www.php.net/manual/en/language.oop5.autoload.php Have in mind the exception case when loading an unexisting class definition. -- Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-) PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436 pgp2lkwjnq0m3.pgp Description: PGP signature
[PHP] Re: Thanks but problem again! Re: [PHP] PHP script problem (with MySQL)
I think that in your database it is : substring(loc, 1, 3) as loc1 Anyway, the error is not where you are getting the message, the query failed and this you don't have a valid resource to ask the number of rows or do anything else. You should add an 'or die(message: . mysql_error()) to your query to trap the error. Satyam Sugimoto [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thank you, Richard, I simply change this part (select * from openart_table) into (select substring(loc1, 1, 3) as THREE_LETTER_CODE, * from openart_table) but Ive got this error, whats wrong with it? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\apache..\openart\test\openart_search.php on line 98 Records Found Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\apache\openart\test\openart_search.php on line 100 Cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: dynamic class loaders
Thanks this seemed to work except say you had a class Packagename_Classname its trying to load the file like that Packagename_Classname.php On 20/04/2005, at 4:23 PM, Markus Fischer wrote: [EMAIL PROTECTED] wrote: Hi there i was wondering if there is such an extension available or possbility to have a dynamicclass loader extension which would use the request_uri as loading the class constructors ? I justthink building such a thing in php which is what i am doing too slow for each request and think itshould happen in the internals ? Let me know if its an insane idea. PHP5 provides autoload, see http://at2.php.net/manual/en/language.oop5.autoload.php for details. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] One more time (Duft Punk) about hyperlink
Thank you very much, I do appreciate your help. (B (BUr script doens work, but, curiously, it works when I changed a bit... (B select left(loc1,3) as locx, openart_id, tit1, pub1, id1, ref1 from (Bopenart_table (B (BIf possible, can I ask one more thing? (BThis part is the problem (B A HREF="/momatlib/image/? echo $row["locx"]; ?.jpg"? echo (B$row["locx"]; ?/A (B (BI got 3 letters, but I would like to show all "loc1" data (eg "1-2 near (Bentrance") in the table, and have first 3 letters of "loc1" for jpg (Bhyperlink (http://www.heyjude.com/image/1-2.jpg). (B (BDo you know how to fix this? (B (Bscript-- (B$result = mysql_query("select left(loc1,3) as locx, openart_id, tit1, pub1, (Bid1, ref1 from openart_table (B where tit1 like '%$tit%' (B and res1 like '%$res%' (B and pub1 like '%$pub%' (B and date1 like '%$date%' (B and id1 like '%$id%' (B and ref1 like '%$ref%' (B and loc1 like '%$loc%' (B and type1 like '%$type%' (B and vol1 like '%$vol%' (B and fre1 like '%$fre%' (B and note1 like '%$note%' order by tit1"); (B (B$rows = mysql_num_rows($result); (B echo $rows,"Record Found p"; (B while($row = mysql_fetch_array($result)){ (B ? (B tr (B tda href = "openart_detail.php ?iden=? echo $row["openart_id"] ?"? (Becho $row["openart_id"]; ?/abr/td (B td? echo $row["tit1"]; ?br/td (B td? echo $row["pub1"]; ?br/td (B td? echo $row["id1"]; ?br/td (B td? echo $row["ref1"]; ?br/td (B td (B A HREF="/momatlib/image/? echo $row["locx"]; ?.jpg"? echo (B$row["locx"]; ? (B /Abr (B /td (B /tr (B (B-- (BPHP General Mailing List (http://www.php.net/) (BTo unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Why is the default value for arg_separator.output ''?
Jared Williams wrote: Given this, why is the default value of arg_separator.output '' and not 'amp;'? URLs don't have amp; in them. The amp; is specific escaping for _only_ XML. No, XML and SGML which includes XHTML and HTML. How often are PHP sessions used to generate output for languages other then those? And even if you want to generate for other languages, why not set arg_separator.output to ; instead? Its already in arg_separator.input and doesn't need escaping to be represented in an HTML or XHTML document. The HTML specification even goes so far as to explicitly recommend it. -- David Dorward http://blog.dorward.me.uk/ http://dorward.me.uk/ Home is where the ~/.bashrc is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encoding help!
On Wednesday 20 April 2005 03:05, Brian Dunning wrote: I know this is a common question but I have RTFM and STFW until I'm blue in the face - I really need some help here. :) I've got some forms into which users are going to enter text that frequently contains funny characters (pilcrows, foreign text, etc). So I need to encode it before writing it into MySQL, and decode it when reading it back out and writing it to the page. I've tried base64_encode/base64_decode, rawurlencode/rawurldecode, utf8_encode/utf8_decode, combinations, and others. My MySQL table is set to use UTF8 and my web pages are all set to UTF8. Most of what I've tried takes: And when I read it from MySQL and output it to the web page, it's turned into: What is the default content-type of the webserver you use? What is the content-type you return to the user through your php scripts? I need some help here! Thanks. :) :) :) -- Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-) PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436 pgpvr6EmSkXr5.pgp Description: PGP signature
Re: [PHP] Why is the default value for arg_separator.output ''?
Richard Lynch wrote: But if it's going to break a billion scripts, it's probably not gonna happen to follow a standard that isn't the only game in town. XHTML is not ubiquitous. [shrug] Representing characters as amp; has been a requirement of SGML and XML based languages, HTML included, since long before XHTML appeared on the scene. What scripts would making this change be likely to break? I have difficulty believing it could cause problems for other then a very small proprotion of users - unlike the change in register_globals a few years ago. Since there are still browsers in use that will choke on amp; in the URL, last time I checked, you're pretty much fighting for a lost cause, as far as I'm concerned. We aren't talking about in the URL, we're talking about in the href attribute. Browsers convert amp; in HTML documents (including in href attributes) to before they think about them being part of URLs. Can you name any browser that gets it wrong? I stress that typing http://www.example.com/?foo=baramp;baz=baa into the address bar is not how the issue should be tested. -- David Dorward http://blog.dorward.me.uk/ http://dorward.me.uk/ Home is where the ~/.bashrc is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: dynamic class loaders
Dan Rossi wrote: Thanks this seemed to work except say you had a class Packagename_Classname its trying to load the file like that Packagename_Classname.php Well, you can put whatever logic you need into the autoload function. It's up to you. HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] One more time (Duft Punk) about hyperlink
Why not try selecting both the short and the full values of loc1 from the database? Then you can display them both in the html output. Select loc1, left(loc1,3) as locx, etc Have I missed your point here? Mark -Original Message- From: Sugimoto [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 08:15 To: PHP ML Subject: [PHP] One more time (Duft Punk) about hyperlink Thank you very much, I do appreciate your help. Ur script doens work, but, curiously, it works when I changed a bit... select left(loc1,3) as locx, openart_id, tit1, pub1, id1, ref1 from openart_table If possible, can I ask one more thing? This part is the problem A HREF=/momatlib/image/? echo $row[locx]; ?.jpg? echo $row[locx]; ?/A I got 3 letters, but I would like to show all loc1 data (eg 1-2 near entrance) in the table, and have first 3 letters of loc1 for jpg hyperlink (http://www.heyjude.com/image/1-2.jpg). Do you know how to fix this? script-- $result = mysql_query(select left(loc1,3) as locx, openart_id, tit1, pub1, id1, ref1 from openart_table where tit1 like '%$tit%' and res1 like '%$res%' and pub1 like '%$pub%' and date1 like '%$date%' and id1 like '%$id%' and ref1 like '%$ref%' and loc1 like '%$loc%' and type1 like '%$type%' and vol1 like '%$vol%' and fre1 like '%$fre%' and note1 like '%$note%' order by tit1); $rows = mysql_num_rows($result); echo $rows,Record Found p; while($row = mysql_fetch_array($result)){ ? tr tda href = openart_detail.php ?iden=? echo $row[openart_id] ?? echo $row[openart_id]; ?/abr/td td? echo $row[tit1]; ?br/td td? echo $row[pub1]; ?br/td td? echo $row[id1]; ?br/td td? echo $row[ref1]; ?br/td td A HREF=/momatlib/image/? echo $row[locx]; ?.jpg? echo $row[locx]; ? /Abr /td /tr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, Cisco, Sun Microsystems, 3Com GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 2000' REGISTERED COMPANY ** CONFIDENTIALITY NOTICE: This Email is confidential and may also be privileged. If you are not the intended recipient, please notify the sender IMMEDIATELY; you should not copy the email or use it for any purpose or disclose its contents to any other person. GENERAL STATEMENT: Any statements made, or intentions expressed in this communication may not necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no content herein may be held binding upon Gamma Global (UK) Ltd or any associated company unless confirmed by the issuance of a formal contractual document or Purchase Order, subject to our Terms and Conditions available from http://www.gammaglobal.com EOE ** ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] set cookie function problem
You might consider using JavaScript to set the cookie, as that will execute on the client and therefore use the client's time to make any calculations regarding expiry. This may or may not suit your purpose. Mark -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 04:18 To: Ospinto Cc: php-general@lists.php.net Subject: Re: [PHP] set cookie function problem On Tue, April 19, 2005 2:20 pm, Ospinto said: Can someone help me with this problem? setcookie('myCookie',blah); works fine. but when i try to set it with an expiry time, it doesn't. setcookie('myCookie',blah,time()+3600); I have cookies enabled on my browser of course. And the way I know the second statement is not working is cos I'm doing a var_dump of $_COOKIES. Thanks for your help. If the user's computer clock is way out of whack, and you are setting a cookie to expire in 1 hour, you're likely to have problems... Though *maybe* browsers account for this by comparing your Date: header and your clock time, and ignore the user clock. For sure, though, *some* versions of IE will *NOT* work when you set a Cookie time, but not a path. That's because the Microsoft engineers mis-read the Cookie spec (on purpose perhaps) and require *both* time and path, or neither, but not just path. YMMV -- 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 Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, Cisco, Sun Microsystems, 3Com GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 2000' REGISTERED COMPANY ** CONFIDENTIALITY NOTICE: This Email is confidential and may also be privileged. If you are not the intended recipient, please notify the sender IMMEDIATELY; you should not copy the email or use it for any purpose or disclose its contents to any other person. GENERAL STATEMENT: Any statements made, or intentions expressed in this communication may not necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no content herein may be held binding upon Gamma Global (UK) Ltd or any associated company unless confirmed by the issuance of a formal contractual document or Purchase Order, subject to our Terms and Conditions available from http://www.gammaglobal.com EOE ** ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP]Gunzip problem
Hello, I have txt file text.txt that contains: line1:one line2:two line3:three line4: Line 4 contains empty string. If I use f*() functions to read from the file: $handle=fopen(text.txt,r); while (!feof($handle)) echo(-.chop(fgets($handle)).-BR); fclose($handle); the RESULT will be: -one- -two- -three- -- I gzipped the file using ZLIB functions. If I use gz*() function to read from the gzip file: $handle=gzopen(text.txt.gz,r); while (!gzeof($handle)) echo(-.chop(gzgets($handle)).-BR); gzclose($handle); the RESULT will be: -one- -two- -three- SEE? The last (empty) line is not returned . What am I doing wrong? OKi98 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Classe Variable
Hi, i got a problem to write automaticaly varibles in classes. i got a simple object name test like this classes Test{ public $id; public $text; } i want to affect my value to my variable like this $test = new Test $champ = id; $valeur_champ = 4; $test-$champ = $valeur_champ; my example is stupid i know but its just for an example. in fact when i write $test-$champ = $valeur_champ; I want that php execute $test-id = 4; can someone help me plz, Marc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explode a string
Richard Lynch wrote: On Tue, April 19, 2005 7:03 am, Jochem Maas said: The 'other' guy mentioned that while() is faster than foreach, is this true? Don't know ; Don't care. You should never loop through so many things in PHP that it matters in the first place :-) I read a few days ago somewhere on php.net that foreach() is the recommended (by php devs) way of iterating over arrays [shrug] That's probably because they're tired of people not understanding the internal pointer array, and asking FAQs about it. Or maybe not. Ask them why they prefer it. I sure don't know. also, compare these 2 lines: while (list(, $idcat) = each($idcats)){ /* ... */ } foreach ($idcats as $idcat){ /* ... */ } now its seems to me that the foreach version is 'up' 2 function calls None of those are function calls. They are all language constructs. Okay, each() *might* be a function... I'm not sure how much difference there is in the number of language constructs used, nor if they are even comparable in sheer numbers the way functions are. ah yes, lang constructs rather than function calls. foreach is probably slower, I think, because it creates a *copy* of the array to work on, so it won't mess up the original and its internal pointer. unless I'm mistaken its a copy-on-change, so unless you are changing the the array inside the loop you don't suffer the actuall copy penalty - can anyone knowledgable on php internals confirm or deny this? actually now I think of it you can use references in a foreach statement: php -r ' $arr = array(1,2,3); foreach($arr as $k = $v) { $v++; } var_dump($arr); ' which suggests that a copy is not (always?) being made... Again, with 200 bytes, you are wasting your time to worry about any of this. true, It's purely a theoretical interest - deeper understanding is alway nice :-) ...its not even my 200 bytes we're talking about ;-) on the while loop, all else being equal the foreach loop has to be faster (given that calling functions is relatively very expensive)... or is foreach() _really_ heavy when compared to while()? Why don't you just benchmark it on your own machine and find out? because I don't have the skills to write a test/benchmark that I _know_ is kosher (and not skewed by a million of my misconceptions, besides I run so much stuff on my machine that speed can be severely affected by things like apache or firebird running in the background that and I lazy ;-) (or I just don't care enough to invest time investigating this) not that I care too much, I find foreach() more pleasing to the eye and there is less to type (in the given example). I'm an old dog, and I don't quite understand for sure how this new-fangled foreach thingie works. I'd spend more time looking it up and reading about it than just typing what I *know* works. [shrug] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Classe Variable
On Wednesday 20 April 2005 13:29, marc serra wrote: Hi, i got a problem to write automaticaly varibles in classes. i got a simple object name test like this classes Test{ public $id; public $text; } i want to affect my value to my variable like this $test = new Test $champ = id; $valeur_champ = 4; $test-$champ = $valeur_champ; Just use $test-{$champ} ;-) my example is stupid i know but its just for an example. in fact when i write $test-$champ = $valeur_champ; I want that php execute $test-id = 4; can someone help me plz, Marc. -- Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-) PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436 pgpLpqGa7yl5J.pgp Description: PGP signature
[PHP] delete session cookie?
Hello, Is it possible to delete a session cookie from browser? If so how? Thanks -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] explode a string
Sorry jocham, for you getting this twice. I'd assume foreach is recommended because it lends to more readable code. More readable code, is generally considered better code. Personally I'd disagree and use while( list() = each() ), because it doesn't create a copy of the array in memory, especially for the array. If you're dealing with an array where the elements are large, or multi-dimentional, you may want to consider a different approach, such as assigning by reference, like: for($keys = array_keys($sample_array); $key = each($keys), $val = $sample_array[$key]; ) but that is very ugly untested code(and I'm drunk), so I wouldn't recommend you copy n paste it. besides for the sake of 200 bytes, with an average of around 5 characters per word, it pretty much doesn't matter, which you use. Even something as crappy as ASP would easly deal with 200b. On 4/20/05, Jochem Maas [EMAIL PROTECTED] wrote: Richard Lynch wrote: On Tue, April 19, 2005 7:03 am, Jochem Maas said: The 'other' guy mentioned that while() is faster than foreach, is this true? Don't know ; Don't care. You should never loop through so many things in PHP that it matters in the first place :-) I read a few days ago somewhere on php.net that foreach() is the recommended (by php devs) way of iterating over arrays [shrug] That's probably because they're tired of people not understanding the internal pointer array, and asking FAQs about it. Or maybe not. Ask them why they prefer it. I sure don't know. also, compare these 2 lines: while (list(, $idcat) = each($idcats)){ /* ... */ } foreach ($idcats as $idcat){ /* ... */ } now its seems to me that the foreach version is 'up' 2 function calls None of those are function calls. They are all language constructs. Okay, each() *might* be a function... I'm not sure how much difference there is in the number of language constructs used, nor if they are even comparable in sheer numbers the way functions are. ah yes, lang constructs rather than function calls. foreach is probably slower, I think, because it creates a *copy* of the array to work on, so it won't mess up the original and its internal pointer. unless I'm mistaken its a copy-on-change, so unless you are changing the the array inside the loop you don't suffer the actuall copy penalty - can anyone knowledgable on php internals confirm or deny this? actually now I think of it you can use references in a foreach statement: php -r ' $arr = array(1,2,3); foreach($arr as $k = $v) { $v++; } var_dump($arr); ' which suggests that a copy is not (always?) being made... Again, with 200 bytes, you are wasting your time to worry about any of this. true, It's purely a theoretical interest - deeper understanding is alway nice :-) ...its not even my 200 bytes we're talking about ;-) on the while loop, all else being equal the foreach loop has to be faster (given that calling functions is relatively very expensive)... or is foreach() _really_ heavy when compared to while()? Why don't you just benchmark it on your own machine and find out? because I don't have the skills to write a test/benchmark that I _know_ is kosher (and not skewed by a million of my misconceptions, besides I run so much stuff on my machine that speed can be severely affected by things like apache or firebird running in the background that and I lazy ;-) (or I just don't care enough to invest time investigating this) not that I care too much, I find foreach() more pleasing to the eye and there is less to type (in the given example). I'm an old dog, and I don't quite understand for sure how this new-fangled foreach thingie works. I'd spend more time looking it up and reading about it than just typing what I *know* works. [shrug] -- 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] delete session cookie?
On Wednesday 20 April 2005 14:51, William Stokes wrote: Hello, Is it possible to delete a session cookie from browser? If so how? Just unset it. Thanks -Will -- Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-) PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436 pgpFDNAHh6Dzp.pgp Description: PGP signature
Re: [PHP] delete session cookie?
William Stokes wrote: Hello, Is it possible to delete a session cookie from browser? If so how? http://www.php.net/manual/en/function.session-destroy.php See the example. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting table columns dynamically on normalized MySQL tables [LONG]
Hello Jay, Tuesday, April 19, 2005, 1:28:25 PM, you wrote: J Normalization has no effect on sort order where any DB is concerned. J Sort order is determined in the sort clause in the query. So if you want J to sort by location and you are using MySQL your ORDER BY clause should J be location(regardless of joins) J SELECT foo J FROM bar J ORDER BY location J returns J course instructor location J Science Bill Elementary School J Basket Weaving Dave High School J Math Dave Middle School J Biology Jessica Middle School Maybe I wasn't clear. SELECT * FROM Course ORDER BY locationID ASC Now the ORDER BY can be any one of five things based on the variable passed by the hyperlink for the column they clicked on (location, course, date, category, and instructor Because locationID is an integer which directly relates to the Instructors table id field (also an integer), there is no way in heck that it can sort that any other way than numerically. There is no join between the Course, Locations, and Instructors tables. All the Course table knows is that there is an integer in the instructorID, categoryID, and locationID field. Therefore it gets sorted numerically, not alphabetically. As I said, I was trying to keep the example simple. I actually have the following tables in the DB. Courses Instructors Locations Categories Students Registrations Supervisors Courses contains information pertinent to a course. - id - name - courseDate - courseTime - ampm (morning or afternoon) - capacity (number of seats available) - locationID (corresponding id from the Locations table) - instructorID (corresponding id from the Instructors table) - seatsLeft (counter for the number of available seats) - description (what the course is about) - categoryID (corresponding id from the Categories table) Instructors - id - firstName - lastName - email - phone - image - about Locations - id - name - seatingCapacity (How many true seats there are in the room) - address - directions Categories - id - name Students - id - firstName - lastName - email - phone - password - username - divisionOrFacility - programArea - supervisorID Supervisors - id - firstName - lastName - email - phone Registrations - id - courseID - studentID - attended So... For me to list the upcoming courses on the main page, I have the following column in the table: Course Name - From Course Table Open Seats- From Course Table Category - From Course Table (match id in Categories table) Date - From Course Table Time - From Course Table Location - From Course Table (match id in Locations table) Instructor- From Course Table (match id in Instructors table) Category, Location, and Instructor are integers. What I did to get the names respective to the integer value is that beforehand I built an array for those three tables then I match the id from the Course Table for each of the three with their respective array, and then display the name. Since the SELECT statement is based on the Course table, and the Course table contains only integers, it's sorting by the integer value of the categoryID, instructorID, or locationID in the Course table. The actual SELECT statement is as follows: $sqlCourses=SELECT * FROM . $tbl_courses . WHERE courseDate ' . date(Y-m-d) . ' ORDER BY . $orderBy . ASC; the $orderBy variable is set via $_GET['orderBy'] which is sent by the table headers as below: $tblHeaders = 'tha href=' . $_SERVER['PHP_SELF'] . '?orderBy=nameCourse/a/ththOpen Seats/ththa href=' . $_SERVER['PHP_SELF'] . '?orderBy=categoryIdCategory/a/ththa href=' . $_SERVER['PHP_SELF'] . '?orderBy=courseDateDate/a/ththTime/ththa href=' . $_SERVER['PHP_SELF'] . '?orderBy=roomIdLocation/a/ththa href=' . $_SERVER['PHP_SELF'] . '?orderBy=instructorIdInstructor/a/th'; The sorting works just fine, but it's numerical ASC based off the integer value (instructorID, categoryID, or locationID). It is *not* alphabetical, which is what the customer wants. If they sort by Location, the location column should be alphabetical ASC, if by course name, then alphabetical ASC by the course name. Is that a bit clearer now? Sorry that this has degenerated into a MySQL question rather than PHP. I was originally looking for how people handled it in PHP. BTW, just for clarity sake on the arrays used to build the lookups to display the list of courses, I'm doing an include with the following: ?php //Get instructors -- $sqlInstructors=SELECT * FROM . $tbl_instructors; $resultInstructors=mysql_query($sqlInstructors) or die('Failed to get instructors. Please contact ' . $maintainer); while ($rInstructors=mysql_fetch_assoc($resultInstructors)) {
Re: [PHP] Sorting table columns dynamically on normalized MySQL tables [LONG]
The actual SELECT statement is as follows: $sqlCourses=SELECT * FROM . $tbl_courses . WHERE courseDate ' . date(Y-m-d) . ' ORDER BY . $orderBy . ASC; the $orderBy variable is set via $_GET['orderBy'] which is sent by the table headers as below: I'm curious why you aren't joining the other tables? That will solve all your woes... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explode a string
explode by , $output1 = explode(,,$string); use a loop and explode array $output1 by : Hope this helps. Saswat On 4/18/05, Sebastian [EMAIL PROTECTED] wrote: $string = '4:gaming,5:hardware,3:software,8:security'; what is the best way to explode then loop this string after its taken apart. output should be something like: $id = 4 $cat = gaming etc.. im just looking for the best/fastest way to do this. the string can grow to 200 or so bytes, maybe more. should i list(), while(), explode it, or should i explode it and foreach it? or..? 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] Sorting table columns dynamically on normalized MySQL tables [LONG]
[snip] SELECT * FROM Course ORDER BY locationID ASC Now the ORDER BY can be any one of five things based on the variable passed by the hyperlink for the column they clicked on (location, course, date, category, and instructor [/snip] If you had a JOIN to the location table you could order by the actual location. Here is an example... SELECT c.courseName, l.locationName FROM Course c, Location l WHERE c.locationID = l.locationID ORDER BY l.locationName [snip] Sorry that this has degenerated into a MySQL question rather than PHP. I was originally looking for how people handled it in PHP. [/snip] Actually it didn't degenerate, it was a SQL question all along. Unless you had a desire to build sortable arrays in PHP this type of sort should always be done on the SQL side because it would be much more efficient. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] handling file upload (OT not exactly PHP)
Hello , Need to do handle a file upload done via http POST. I can read the content length and from POST and get the contents. But, how do I get the exact file ?? Eg. suppose for uploading a .doc file I could see that it sends the font type and other parameters also.. I am not sure how does it will matter when I am extracting the exact file from the POST request . Again, how would I extract the exact file ?? Would appreciate any pointers or someone giving me some headstart . Thanks and Regards, -Saswat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sorting table columns dynamically on normalized MySQL tables [LONG]
[snip] Sorry that this has degenerated into a MySQL question rather than PHP. I was originally looking for how people handled it in PHP. --- Actually it didn't degenerate, it was a SQL question all along. Unless you had a desire to build sortable arrays in PHP this type of sort should always be done on the SQL side because it would be much more efficient. [/snip] I also should have said that it the joins that allow you to maintain normalized tables, for without joins you would be stuck with doing the magic in the programming language. Since most DB engines are optimized for handling joins leave that efficiency on that side of the equation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] handling file upload (OT not exactly PHP)
[snip] Need to do handle a file upload done via http POST. I can read the content length and from POST and get the contents. But, how do I get the exact file ?? Eg. suppose for uploading a .doc file I could see that it sends the font type and other parameters also.. I am not sure how does it will matter when I am extracting the exact file from the POST request . Again, how would I extract the exact file ?? [/snip] Have you read all of this - http://us3.php.net/manual/en/features.file-upload.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] handling file upload (OT not exactly PHP)
Did you try using the $_FILES superglobal? -- Original Message --- From: Saswat Praharaj [EMAIL PROTECTED] To: Sent: Wed, 20 Apr 2005 18:26:14 +0530 Subject: [PHP] handling file upload (OT not exactly PHP) Hello , Need to do handle a file upload done via http POST. I can read the content length and from POST and get the contents. But, how do I get the exact file ?? Eg. suppose for uploading a .doc file I could see that it sends the font type and other parameters also.. I am not sure how does it will matter when I am extracting the exact file from the POST request . Again, how would I extract the exact file ?? Would appreciate any pointers or someone giving me some headstart . Thanks and Regards, -Saswat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- End of Original Message --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Cannot load mysqli extensions
Hi, I've installed PhpMyAdmin 2.6.2, PHP 5.0.4 and Mysql 4.1.11 and PHP is working fine but when I try to start PhpAdmin I get this message: PHP cannot load mysqli extensions, please controll your PHP configuration. In Paths and directories I wrote: extensions_dir=e:\php\ext\ and in Dynamics extensions I wrote: extensions=php_mysqi.dll. All that on a w2k server with IIS 5 and mysql is running as a service. Can someone give me little help on that ? Thanks in advance. Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting table columns dynamically on normalized MySQL tables
Hello Kim, Tuesday, April 19, 2005, 6:44:58 PM, you wrote: K If you are still looking for tips and want to get K complicated/fancy, I have seen columns used called sort_order more K than a few times. This should not be too hard to maintain for K things like a few buildings, etc., where the lookup table does not K change much over time. You would then have another option for your K oder by clause. I understand what you mean, but I'm still in the same boat. There is no join between the four tables (mainly because I didn't think you were supposed to do joins on four tables. I've written a couple other replies which I think more clearly state where my problem is so I won't retype them here. Thanks though. -- Leif (TB lists moderator and fellow end user). Using The Bat! 3.0.9.17 Return under Windows XP 5.1 Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting table columns dynamically on normalized MySQL tables
Hello Richard, Tuesday, April 19, 2005, 9:12:14 PM, you wrote: R Just build a JOIN query and do one query. Doing a join on four tables is ok? (serious question, not being facetious). R No, it is *NOT* sorting on the ID number. I can definitely say it is sorting on locationID, categoryID, or instructorID. It's not alphabetical. When I view the listing after a sort on say locationID, it's not alphabetical but ordered by which class has the lowest numerical value in the locationID field and then ASC from there. R By definition, in SQL, if you don't specify a sort order (or in R this case a second order) then the SQL engine can and will output R the records in any order it feels like. Really? I didn't know that. I thought it started at record 0 and then output them in the order they appeared in the table data view (using something like PHPMyAdmin.) R In that case of MySQL and ISAM tables, that *HAPPENS* to be the ID R order, because the under-lying SQL engine happens to find it R convenient to have them in that order. Ahhh. Ok, there we go. R If you *DELETE* an ID number, then put another one in, but force it R to be the same ID number you'll probably see the records come out R in a different order. It's usually a really Bad Idea to do that R (forcing an ID to be re-used) but for the purposes of R learning/demonstration you can do it. I'll give it a shot sometime to see. It'll be interesting to find out. R At any rate, MySQL is *NOT* sorting by ID number. It's not sorting R *AT* *ALL* except for what you told it to sort. It just spews out R the records in any old order at all after location is done -- R Which happens to be ID order, but that's more like coincidence than R plan [*]. Maybe I confused you with the ID nomenclature. I mean to say it's sorting by locationID, categoryID, instructorID (whichever column I clicked on), and since those are integer values they aren't sorted alphabetically). That's not what they want obviously. R Why not? R What *DO* they want, then? If they sort by location, they want the course records to show up in alphabetical order based on location. Right now it does sort by location, but it's not alphabetical because the Course.locationID, Course.instructorID, and Course.categoryID are integers which relate to three other respective tables. There is no join, and I didn't think you were supposed to do a join on four tables. R Do you want, perhaps, to have a DEFAULT sort order, which kicks in R after their chosen ordering? By default it sorts by Course date. R Perhaps you could do (here's your magic bullet): R ?php R $default_sort_order = course, instructor, location; R . R . R . R $query .= ORDER BY $_GET[order_by], $default_sort_order ; ? I'm kinda doing that already as: if (isset($_GET['orderBy'])) $orderBy = $_GET['orderBy']; else $orderBy = 'courseDate'; R Then, oddly enough, by location again, but that's kinda R irrelevant. It won't *hurt* anything [**], mind you, it's just R kinda silly, since you have already sorted by location in the very R first place. Got it. R [**] Technically, it's a little inefficient to have that extra R bogus location in there at the end, but you're probably not R sorting enough rows for it to make any measurable difference in R your results... And MySQL might even be smart enough to optimize it R out anyway. True enough. I'm guessing they'll be maybe 30 to 50 records at any one time. R You did the right thing. :-) grin Tell me that again once I get the sorting working right! grin R You just needed to go farther down the road you are on, instead of R stopping partway. Only stopped because I got stuck... :-) Thanks. -- Leif (TB lists moderator and fellow end user). Using The Bat! 3.0.9.17 Return under Windows XP 5.1 Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting table columns dynamically on normalized MySQL tables
Hello Chris, Tuesday, April 19, 2005, 1:23:53 PM, you wrote: C Firstly, what DB are you using? MySQL. C SELECT C course.name, C location.name, C instructor.name C FROM C course C INNER JOIN location ON location.id = course.locationID C INNER JOIN instructor ON instructor.id = course.instroctorID C ORDER BY instructor.name C (or location.name or course.name). C It should be as simple as that... So joining on four tables isn't considered bad practice? Technically it's going to be five tables because the whole HTML table layout changes to include enroll and disenroll buttons once they log in and based on if they are enrolled or not in a particular course which comes from the registrations table, which is simply their the id from the Students table and the id from the Course table. Thanks. -- Leif (TB lists moderator and fellow end user). Using The Bat! 3.0.9.17 Return under Windows XP 5.1 Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting table columns dynamically on normalized MySQL tables
R Just build a JOIN query and do one query. Doing a join on four tables is ok? (serious question, not being facetious). Yes. I've built a query before (for reporting purposes) that join 15 tables... Just make sure the tables are indexed properly. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sorting table columns dynamically on normalized MySQL tables
[snip] Doing a join on four tables is ok? (serious question, not being facetious). [/snip] Yes, it is OK. Make sure that you have the tables properly indexed and you'll have no problems. [snip] R By definition, in SQL, if you don't specify a sort order (or in R this case a second order) then the SQL engine can and will output R the records in any order it feels like. Really? I didn't know that. I thought it started at record 0 and then output them in the order they appeared in the table data view (using something like PHPMyAdmin.) [/snip] PHPMyAdmin uses an ORDER BY clause and it is initially on the primary key index for any given table. Then PHPMyAdmin uses relevant column data for the sort. SQL CAN and DOES spit out the records any way it wants when no sort is specified. You dod not typically see it because of query caching. (Ever notice that a second issue of the same query you just made is much faster? Query caching.) [snip] R If you *DELETE* an ID number, then put another one in, but force it R to be the same ID number you'll probably see the records come out R in a different order. It's usually a really Bad Idea to do that R (forcing an ID to be re-used) but for the purposes of R learning/demonstration you can do it. I'll give it a shot sometime to see. It'll be interesting to find out. [/snip] +1 on the bad idea for primary key re-use. [snip] If they sort by location, they want the course records to show up in alphabetical order based on location. Right now it does sort by location, but it's not alphabetical because the Course.locationID, Course.instructorID, and Course.categoryID are integers which relate to three other respective tables. There is no join, and I didn't think you were supposed to do a join on four tables. [/snip] Furthering our discussion of the ORDER BY clause...you can put more than one sort criteria there... ORDER BY l.locationName, c.courseName -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Last visitors
On Tuesday, April 19, 2005 18:46, Ryan A wrote: Hey, Thanks for replying, I tried using the test example of Petar Nedyalkov, but when i try to create the following: CREATE TABLE `profile_log` ( `profile_id` int(10) default NULL, `user_id` int(10) default NULL, `last_login` timestamp NOT NULL ) ENGINE=MyISAM CHARSET=utf8 I get an error on both ENGINE=MyISAM and CHARSET=utf8 What are they for really? can I omit them? or will that effect the program later on? Thanks, Ryan You can leave these off. Changing ENGINE to TYPE will fix that error, and you can leave off the charset. I believe utf8 was added in 4.1. If you leave off charset=xxx it will just default to whatever the server's default-character-set is set to, probably latin1. On 4/19/2005 4:42:08 PM, Tom Crimmins ([EMAIL PROTECTED]) wrote: On Tuesday, April 19, 2005 09:09, John Nichel wrote: Petar Nedyalkov wrote: snip You can store only 10 records for each user by using the following logic: mysql show create table profile_log\G *** 1. row *** Table: profile_log Create Table: CREATE TABLE `profile_log` ( `profile_id` int(10) default NULL, `user_id` int(10) default NULL, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP ) ENGINE=MyISAM DEFAULT CHARSET=utf8 1 row in set (0.00 sec) When you create a profile you fill 10 blank records with timestamp -00-00 00:00:00. Then if a user sees a profile: PSEUDO SQL: $SQL = UPDATE profile_log SET user_id=.$userId. WHERE profile_id=. $profileId. ORDER BY timestamp ASC LIMIT 1 -- Tom Crimmins Interface Specialist Pottawattamie County, Iowa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] handling file upload (OT not exactly PHP)
Saswat Praharaj wrote: Hello , Need to do handle a file upload done via http POST. I can read the content length and from POST and get the contents. But, how do I get the exact file ?? Eg. suppose for uploading a .doc file I could see that it sends the font type and other parameters also.. I am not sure how does it will matter when I am extracting the exact file from the POST request . Again, how would I extract the exact file ?? Would appreciate any pointers or someone giving me some headstart . RTFM http://us4.php.net/manual/en/features.file-upload.php -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Replacement Question.
I have a database field that I need to read and do some conversion on. Here is what the raw data from the database looks like: -- 1084751309jpenaDisney Vignette Fleximon disk utilization alert C:\ at 85%1084799703bpalmafixed.1084799713bpalmaclosed -- After conversion, it should look like this: -- 5/16/2004 7:48:29 PM jpena Disney Vignette Fleximon disk utilization alert C:\ at 85% 5/17/2004 9:15:03 AM bpalma fixed. 5/17/2004 9:15:13 AM bpalma closed -- I have tried to use eregi_replace to convert the timestamps to DateTime, but I end up with all three timestamps being changed to the same time (5/16/2004 7:48:29 PM). Here is the quick, albeit ugly, code I've tried to come close -- $worklogt3 = eregi_replace(,br, $worklogt1); $worklogt4 = eregi_replace(,brbr, $worklogt3); $worklog = eregi_replace([0-9]{10,10},date(m/j/y g:i a,$worklogt4),$worklogt4); -- $worklogt1 is the value of the field from the database and the first two replacements are actually for different characters, even though they look the same. Can anyone help me with this? I've been beating myself up for almost three days over this. Thanks in Advance, Bob Palma [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacement Question.
On Wednesday 20 April 2005 15:22, Bob Palma typed: I have a database field that I need to read and do some conversion on. Here is what the raw data from the database looks like: -- 1084751309jpenaDisney Vignette Fleximon disk utilization alert C:\ at 85%1084799703bpalmafixed.1084799713bpalmaclosed -- Are the group delimiters different from the field delimiters? Ie, can you do: $array_of_groups = explode('group_delim', $in_string); foreach ($array_of_groups as $i) { $array_of_fields = explode('field_delim', $i); $date = date('m/j/y g:i:a', $array_of_fields[0]); print $date {$a_o_f[1]}br /{$a_o_f[2]}br /br /\n; } YMMV of course. -- My mind not only wanders, it sometimes leaves completely. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Last visitors
clip 1 Thanks for replying, I tried using the test example of Petar Nedyalkov, but when i try to create the following: CREATE TABLE `profile_log` ( `profile_id` int(10) default NULL, `user_id` int(10) default NULL, `last_login` timestamp NOT NULL ) ENGINE=MyISAM CHARSET=utf8 I get an error on both ENGINE=MyISAM and CHARSET=utf8 What are they for really? can I omit them? or will that effect the program later on? /clip 1 You can leave these off. Changing ENGINE to TYPE will fix that error, and you can leave off the charset. I believe utf8 was added in 4.1. If you leave off charset=xxx it will just default to whatever the server's default-character-set is set to, probably latin1. Hey, Thanks for replying. Theres something wrong coz its not working as expected... I followed instructions and created a table like this: CREATE TABLE test_last_visitors ( profile_id int(10) default NULL, user_id int(10) default NULL, ttimestamp timestamp(14) NOT NULL) TYPE=MyISAM; then I ran this 5 times: (logic being: test with 5, if it works go with 10 or more) :-) insert into `test_last_visitors` values(1,1,now()); then from my php script (test_last_visitors.php) I ran this test SQL: $SQL = UPDATE test_last_visitors SET profile_id=.$profile_id., user_id=user_id+1, ttimestamp=now() WHERE profile_id=1 ORDER BY ttimestamp ASC LIMIT 1; The first 5 times it works perfectly, then after that it updates only the latest record over and over again :-( I tried playing with the ASC and DESC, MIN and MAXno joy. Any idea whats wrong? Thanks, Ryan -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.16 - Release Date: 4/18/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacement Question.
Wow! Thanks.. That works great. Just one small hitch though. After it prints all of the data properly, it adds one more '$date' on the end which gets printed as '12/31/69 7:00:pm'. Is there a way to do all groups - 1 ? Bob Palma [EMAIL PROTECTED] Duncan Hill wrote: On Wednesday 20 April 2005 15:22, Bob Palma typed: I have a database field that I need to read and do some conversion on. Here is what the raw data from the database looks like: -- 1084751309jpenaDisney Vignette Fleximon disk utilization alert C:\ at 85%1084799703bpalmafixed.1084799713bpalmaclosed -- Are the group delimiters different from the field delimiters? Ie, can you do: $array_of_groups = explode('group_delim', $in_string); foreach ($array_of_groups as $i) { $array_of_fields = explode('field_delim', $i); $date = date('m/j/y g:i:a', $array_of_fields[0]); print $date {$a_o_f[1]}br /{$a_o_f[2]}br /br /\n; } YMMV of course. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacement Question.
On Wednesday 20 April 2005 16:01, Bob Palma typed: Wow! Thanks.. That works great. Just one small hitch though. After it prints all of the data properly, it adds one more '$date' on the end which gets printed as '12/31/69 7:00:pm'. Is there a way to do all groups - 1 ? No reason for it to do that unless your data is a bit weird. Use print_r() or var_dump to see what each array contains - you might find you have a blank entry being tacked on somehow (which you could detect with an if). -- My mind not only wanders, it sometimes leaves completely. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Replacement Question.
Thanks. I took a look, and you were right. It was creating another entry in the array at the end, so I used an if statement checking the value of [1] and [2] in $array_of_fields. Thanks for all the great help Bob Palma [EMAIL PROTECTED] Duncan Hill wrote: On Wednesday 20 April 2005 16:01, Bob Palma typed: Wow! Thanks.. That works great. Just one small hitch though. After it prints all of the data properly, it adds one more '$date' on the end which gets printed as '12/31/69 7:00:pm'. Is there a way to do all groups - 1 ? No reason for it to do that unless your data is a bit weird. Use print_r() or var_dump to see what each array contains - you might find you have a blank entry being tacked on somehow (which you could detect with an if). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Last visitors
On Wednesday, April 20, 2005 09:57, Ryan A wrote: clip 1 Thanks for replying, I tried using the test example of Petar Nedyalkov, but when i try to create the following: CREATE TABLE `profile_log` ( `profile_id` int(10) default NULL, `user_id` int(10) default NULL, `last_login` timestamp NOT NULL ) ENGINE=MyISAM CHARSET=utf8 I get an error on both ENGINE=MyISAM and CHARSET=utf8 What are they for really? can I omit them? or will that effect the program later on? /clip 1 You can leave these off. Changing ENGINE to TYPE will fix that error, and you can leave off the charset. I believe utf8 was added in 4.1. If you leave off charset=xxx it will just default to whatever the server's default-character-set is set to, probably latin1. Hey, Thanks for replying. Theres something wrong coz its not working as expected... I followed instructions and created a table like this: CREATE TABLE test_last_visitors ( profile_id int(10) default NULL, user_id int(10) default NULL, ttimestamp timestamp(14) NOT NULL) TYPE=MyISAM; then I ran this 5 times: (logic being: test with 5, if it works go with 10 or more) :-) insert into `test_last_visitors` values(1,1,now()); then from my php script (test_last_visitors.php) I ran this test SQL: $SQL = UPDATE test_last_visitors SET profile_id=.$profile_id., user_id=user_id+1, ttimestamp=now() WHERE profile_id=1 ORDER BY ttimestamp ASC LIMIT 1; The first 5 times it works perfectly, then after that it updates only the latest record over and over again :-( I tried playing with the ASC and DESC, MIN and MAXno joy. Any idea whats wrong? Thanks, Ryan The following works for me. UPDATE test_last_visitors SET user_id=user_id+1 WHERE profile_id=1 ORDER BY ttimestamp LIMIT 1; You don't have to explicitly update the timestamp column. It will do this automatically. This will rotate through the five rows. This may have failed in your test because if you executed this in a script and all of the sql statements occurred in the same second, you would probably see the behavior that you described. -- Tom Crimmins Interface Specialist Pottawattamie County, Iowa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Last visitors
Theres something wrong coz its not working as expected... I followed instructions and created a table like this: CREATE TABLE test_last_visitors ( profile_id int(10) default NULL, user_id int(10) default NULL, ttimestamp timestamp(14) NOT NULL) TYPE=MyISAM; then I ran this 5 times: (logic being: test with 5, if it works go with 10 or more) :-) insert into `test_last_visitors` values(1,1,now()); then from my php script (test_last_visitors.php) I ran this test SQL: $SQL = UPDATE test_last_visitors SET profile_id=.$profile_id., user_id=user_id+1, ttimestamp=now() WHERE profile_id=1 ORDER BY ttimestamp ASC LIMIT 1; The first 5 times it works perfectly, then after that it updates only the latest record over and over again :-( I tried playing with the ASC and DESC, MIN and MAXno joy. Any idea whats wrong? /* The following works for me. UPDATE test_last_visitors SET user_id=user_id+1 WHERE profile_id=1 ORDER BY ttimestamp LIMIT 1; You don't have to explicitly update the timestamp column. It will do this automatically. This will rotate through the five rows. This may have failed in your test because if you executed this in a script and all of the sql statements occurred in the same second, you would probably see the behavior that you described. */ Keep running the same UPDATE query a few times and see that it only updates the top record, it leaves all the others even though the others timestamps are lower... atleast thats whats happening to me :-( Thanks, -Ryan -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.16 - Release Date: 4/18/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Last visitors
Ryan A wrote: snip then from my php script (test_last_visitors.php) I ran this test SQL: $SQL = UPDATE test_last_visitors SET profile_id=.$profile_id., user_id=user_id+1, ttimestamp=now() WHERE profile_id=1 ORDER BY ttimestamp ASC LIMIT 1; Why are you setting the profile_id equal to a value when you also have that in your WHERE clause? I may have missed something here, but I though the purpose of this was to track the last ten visitors to a certain page, and if this is the case, why increment the user_id when updating the row? Shouldn't the query be more like... UPDATE `test_last_visitors` SET `user_id`=$user_id, `ttimestamp`=now() WHERE `profile_id`=$profile_id ORDER BY `ttimestamp` ASC LIMIT 1 -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Last visitors
Hey, Why are you setting the profile_id equal to a value when you also have that in your WHERE clause? I may have missed something here, but I though the purpose of this was to track the last ten visitors to a certain page, and if this is the case, why increment the user_id when updating the row? Shouldn't the query be more like... I was just playing with the SQLinstead of entering new user_id's for each person visiting i just tried increment it... UPDATE `test_last_visitors` SET `user_id`=$user_id, `ttimestamp`=now() WHERE `profile_id`=$profile_id ORDER BY `ttimestamp` ASC LIMIT 1 I ran the above in phpmyadmin like so: UPDATE `test_last_visitors` SET `user_id`=7, `ttimestamp`=now() WHERE `profile_id`=2 ORDER BY `ttimestamp` ASC LIMIT 1 its only updateing the top first record :-( I'm just about to throw in the towel... Thanks, Ryan -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.16 - Release Date: 4/18/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Images - Converting TIFF Format?
I searched through my server's system (I'm not running it, it's my ISP) and finally found that TIFF isn't compiled into GD. I can get them to do it, but I need to know what functions to use! Are they under a different file type? I'm pretty sure I searched through thoroughly for the function. Did I miss something? Thanks for all your help! On 4/19/05, Tom Rogers [EMAIL PROTECTED] wrote: Hi, Wednesday, April 20, 2005, 12:39:54 AM, you wrote: TDJ Is there a quick way to convert a TIFF format picture to a GIF quickly? I TDJ can only find support for GIFs in PHP, but maybe I'm missing something. I TDJ have a client running a photography business, and I have designed an image TDJ watermark and resizing engine, and a server to check the request, serve the TDJ file, and then delete it. I mainly made this to help him run the site TDJ himself, since he isn't very good with Photoshop, and can't watermark the TDJ images (I shouldn't say that...he probably could, but not very fastbut TDJ anyway...). TDJ This is all working fine and dandy, but the system will only accept GIF TDJ format. His images are all raw scans in TIFF format. This means that he has TDJ to open the image in Photoshop, resize it, and convert it to a GIF. I think TDJ he can do this himself, but I'd like to make it even simpler, which is why TDJ I'm writing. TDJ I need a quick way, preferably in PHP, but it doesn't have to be, to TDJ convert large batches of TIFF format images to GIF. Does anyone know of a TDJ way to do this? TDJ Thanks for reading, and for your responses in advance... I use netpbm for conversion to png from tiffs and windows bitmaps like this: //$tempname from fileupload tmpname //$file from fileupload name $jobpath = '/wherever/you/want/files/stored'; if($im = getimagesize($tempname)){ if($im[0] 0){ //cleanup filename $file = ereg_replace(',,$file); $file = ereg_replace(%20,_,$file); $file = ereg_replace( ,_,$file); $ext = @substr($file, (@strrpos($file, .) ? @strrpos($file, .) + 1 : @strlen($file)), @strlen($file)); $fname = basename($file,$ext); switch(intval($im[2])){ case 7: case 8: //force a tif extension for netpbm $tfilename = $jobpath.'/'.$fname.'tif'; move_uploaded_file($tempname, $tfilename); $file = $fname.'png'; $filename = $jobpath.'/'.$file; shell_exec (/path/to/netpbm/bin/tifftopnm -quiet $tfilename | /path/to/netpbm/bin/pnmtopng $filename); break; case 6: //force a bmp extension for netpbm $tfilename = $jobpath.'/'.$fname.'bmp'; move_uploaded_file($tempname, $tfilename); $file = $fname.'png'; $filename = $jobpath.'/'.$file; shell_exec (/path/to/netpbm/bin/bmptoppm -quiet $tfilename | /path/to/netpbm/bin/pnmtopng $filename); break; default: $filename = $jobpath.'/'.$file; move_uploaded_file($tempname, $filename); break; } } } -- regards, Tom -- The Disguised Jedi [EMAIL PROTECTED] Now you have my $0.02. Or .01 Pounds, .014 Euros, or $0.025 CAN. I'm world-wide BABY! PHP rocks! Knowledge is Power. Power Corrupts. Go to school, become evil Disclaimer: Any disclaimer attached to this message may be ignored. However, I must say that the ENTIRE contents of this message are subject to other's criticism, corrections, and speculations. This message is Certified Virus Free
[PHP] Classes, Constructors, References and Recursion
Hi, I have this piece of code: class test1 { var $data = 'hi', $node = false; function test1() { $this-node = new test2($this); } } class test2 { var $data = 'yoyo', $root = false; function test2($root) { $this-root = $root; } } $test = new test1(); echo('pre'); print_r($test); echo('/pre'); And it outputs: test1 Object ( [data] = hi [node] = test2 Object ( [data] = yoyo [root] = test1 Object ( [data] = hi [node] = *RECURSION* ) ) ) while it should output: test1 Object ( [data] = hi [node] = test2 Object ( [data] = yoyo [root] = *RECURSION* ) ) I know there are some difficulties using references in constructors, but I think this should be right.. I'm using PHP/4.3.11. Can anyone tell me what is wrong with this code or why PHP behaves this way? regards, Evert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Classe Variable
Petar Nedyalkov wrote: On Wednesday 20 April 2005 13:29, marc serra wrote: Hi, i got a problem to write automaticaly varibles in classes. i got a simple object name test like this classes Test{ public $id; public $text; } i want to affect my value to my variable like this $test = new Test missing a ';' above $champ = id; I think this should be: $champ = 'id'; $valeur_champ = 4; $test-$champ = $valeur_champ; Just use $test-{$champ} ;-) curlies are not required in this case (although they do allow more complex expressions), the following works for me: class T{public $id;}$t=new T; $a=i;$b=d;$c=id;$v=4;$t-$c=$v;$t-{$b.$a}=5; var_dump($c,$v,$t-$c,$t-id,$t-{$a.$b},$t); my example is stupid i know but its just for an example. in fact when i write $test-$champ = $valeur_champ; I want that php execute $test-id = 4; can someone help me plz, Marc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: post redirect
hello, I created little script in PHP 5 in which I entered the following line form name=transfert method=post action=wogl_transfert.php input name=rep_final type=hidden value=?=$rep_final? input name=rep_source type=hidden value=?=$rep_source? input type=submit value=TRANSFERT the hidden input helped me to keep the rep_source variable with the same value in the next page than in the new page. I'm not a specialist but it has been working well until today. Olivier energize! -Message d'origine- De : Matthew Weier O'Phinney [mailto:[EMAIL PROTECTED] Envoyé : mercredi 20 avril 2005 04:39 À : php-general@lists.php.net Objet : [PHP] Re: post redirect * Jem777 [EMAIL PROTECTED]: If I submit a post and then, serverside, I redirect the request to another page, do the post variables still live in the new page? No. HTTP requests are stateless, meaning they have no memory of what requests happened before or after, or how those requests were made. PHP does not affect that behaviour at all; it's entirely a matter of the HTTP protocol. If you want the POST variables to propogate to the redirected page, use a session. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- 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] Classes, Constructors, References and Recursion
Evert|Rooftop Solutions wrote: Hi, I have this piece of code: class test1 { var $data = 'hi', $node = false; function test1() { $this-node = new test2($this); } } class test2 { var $data = 'yoyo', $root = false; function test2($root) { $this-root = $root; } } $test = new test1(); echo('pre'); print_r($test); echo('/pre'); And it outputs: test1 Object ( [data] = hi [node] = test2 Object ( [data] = yoyo [root] = test1 Object ( [data] = hi [node] = *RECURSION* ) ) ) while it should output: test1 Object ( [data] = hi [node] = test2 Object ( [data] = yoyo [root] = *RECURSION* ) ) does the output of print_r() correlate with whats actually happening? i.e. is the first test1 object not a reference of the second test1 object (as per the print_r() dump). what does the following show? (I don't have php4 at hand): var_dump($test); also I believe print_r() and var_dump() have a few odditities regarding display of recursion with regard to objects... internals mailinglist archive might tell you more on that. does the following show different output? ?php class test1 { var $data = 'hi', $node = false; function test1() { $this-node = new test2(); $this-node-root = $this; } } class test2 { var $data = 'yoyo', $root = false; } $test = new test1(); echo pre; print_r($test); echo hr /; var_dump($test); echo /pre; ? I know there are some difficulties using references in constructors, but I think this should be right.. I'm using PHP/4.3.11. Can anyone tell me what is wrong with this code or why PHP behaves this way? go for php5 if you can, you'll have alot more fun with object then :-) no more ''s for starters. regards, Evert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] To mysqli or not to mysqli
Looks like mysqli is the new method of talking to mysql? Should I be moving away from the legacy mysql_* functions? I'm running php5 and mysql 4.1.11 on IIS5 and Apache 2. John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encoding help!
Petar Nedyalkov wrote: On Wednesday 20 April 2005 03:05, Brian Dunning wrote: I know this is a common question but I have RTFM and STFW until I'm blue in the face - I really need some help here. :) I've got some forms into which users are going to enter text that frequently contains funny characters (pilcrows, foreign text, etc). So I need to encode it before writing it into MySQL, and decode it when reading it back out and writing it to the page. I've tried base64_encode/base64_decode, rawurlencode/rawurldecode, utf8_encode/utf8_decode, combinations, and others. My MySQL table is set to use UTF8 and my web pages are all set to UTF8. Most of what I've if mySQL is setup for UTF8 I thought that you didn't need to encode the data...? assuming you have told the browser to send UTF8 (which you seem to have) and it does. tried takes: And when I read it from MySQL and output it to the web page, it's turned into: What is the default content-type of the webserver you use? What is the content-type you return to the user through your php scripts? I need some help here! Thanks. :) :) :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why is the default value for arg_separator.output ''?
David Dorward wrote: Richard Lynch wrote: But if it's going to break a billion scripts, it's probably not gonna happen to follow a standard that isn't the only game in town. XHTML is not ubiquitous. [shrug] Representing characters as amp; has been a requirement of SGML and XML based languages, HTML included, since long before XHTML appeared on the scene. you might be able to put this func to use somewhere: function properAmpersands($url) { return preg_replace(/()(?!amp;)/,amp;,(string)$url); } What scripts would making this change be likely to break? I have difficulty believing it could cause problems for other then a very small proprotion of users - unlike the change in register_globals a few years ago. Since there are still browsers in use that will choke on amp; in the URL, last time I checked, you're pretty much fighting for a lost cause, as far as I'm concerned. We aren't talking about in the URL, we're talking about in the href attribute. Browsers convert amp; in HTML documents (including in href attributes) to before they think about them being part of URLs. Can you name any browser that gets it wrong? I stress that typing http://www.example.com/?foo=baramp;baz=baa into the address bar is not how the issue should be tested. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse error, unexpected T_CLASS
Dasmeet Singh wrote: ... Get some decent editor with syntax highlighting ditto. :-) Thanks.. That was really silly.. BTW.. pls suggest some good editor.. I use notepad currently.. OFFS. http://www.php-editors.com/ http://www.google.com/search?hl=enlr=q=good+editor+for+phpbtnG=Search choose one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To mysqli or not to mysqli
On 4/20/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Looks like mysqli is the new method of talking to mysql? Should I be moving away from the legacy mysql_* functions? I'm running php5 and mysql 4.1.11 on IIS5 and Apache 2. Finding clients who even run 4.0.x is rare for me, most still use 3.23 I find. I'm hosting my personal stuff with a company that has 4.1.x installed but it's with PHP 4 so I still use the regular mysql functions. On thing I've been doing to prepare for the switch is stuff like this: $extensions = get_loaded_extensions(); if( in_array( 'mysqli', $extensions ) ) { } elseif( in_array( 'mysql', $extensions ) ) { } -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Classes, Constructors, References and Recursion
Jochem Maas wrote: also I believe print_r() and var_dump() have a few odditities regarding display of recursion with regard to objects... internals mailinglist archive might tell you more on that. I think I have the answer, when I pass a var to print_r it isn't passed by reference, so there will be a copy made immediately. go for php5 if you can, you'll have alot more fun with object then :-) no more ''s for starters. God I wish I could! The thing is, most hosting company's don't support it yet, and since I'm making a product that should run (and is already running) at various places, I have to use PHP4 :( thanx man, Evert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: post redirect
Please don't hijack threads. Olivier GOEGEL wrote: hello, I created little script in PHP 5 in which I entered the following line form name=transfert method=post action=wogl_transfert.php input name=rep_final type=hidden value=?=$rep_final? input name=rep_source type=hidden value=?=$rep_source? input type=submit value=TRANSFERT the hidden input helped me to keep the rep_source variable with the same value in the next page than in the new page. I'm not a specialist but it has been working well until today. Read this, and check your settings... http://us4.php.net/register_globals -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 32 bit PNG (256 color alpha channel), TGA images, etc
I find it not quite right that imagecolorallocatealpha is limited to 128 levels right now (0-127) ... the png format can support 256 with true 32bit images. I am concerned about this because I am using php to make an application that loads a nonstandard image format (MM2/MC TEX) and converts it to png - but the format supports 256 alpha levels, imagecolorallocatealpha does not, and therefore I am losing small amounts of detail in the alpha channel by reducing it to conform to the max 128 levels idea. Can I get an explanation as to why it's limited at 128 levels instead of the preferred 256, and maybe an estimate or guess to whether or not this limitation will ever be lifted? On to the next part of this post. Is there any way to create an equivalent to imagecreatefrompng for tga (maybe imagecreatefromtga), /including/ alpha channel? I've found examples on php.net, but none of them take an image with more than 256 colors, much less one with an alpha channel. I'm not keen on the binary structure of the tga format, but i might be required to learn it this time.. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] To mysqli or not to mysqli
Looks like mysqli is the new method of talking to mysql? Should I be moving away from the legacy mysql_* functions? I'm running php5 and mysql 4.1.11 on IIS5 and Apache 2. Why not use PDO :) Jared -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Robustly using XSLT across different versions of PHP?
Has anyone written anything, perhaps in PEAR or elsewhere, that allows for some portability of XSLT use across PHP 4 with Sablotron, PHP 4 with domxml, and PHP 5? I'm doing some work on a project at the moment, and the server it will be hosted on initially has PHP 4 compiled with Sablotron support. Unfortunately my workstation where I'm doing a lot of prototyping runs Fedora Core 3 and has PHP 4.3.11 compiled with '--with-xml' '--with-expat-dir=/usr' '--with-dom=shared,/usr' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr'. All attempts so far to recompile Fedora's src rpm with sablotron have failed and frankly I've given up. Besides which, it's likely that at some we'll want to start using PHP 5. I can use the domxml XSLT support in PHP 4 on my FC3 box just fine, e.g. like this: ?php $filename = default.xsl; $xmldoc = domxml_open_file(control.xml); $xsldoc = domxml_xslt_stylesheet_file($filename); $result = $xsldoc-process($xmldoc); echo $xsldoc-result_dump_mem($result); ? but that isn't too much help given that that doesn't work on the production server. Has anyone done any work on creating something like PEAR:DB which will use the functions described here: http://uk.php.net/manual/en/ref.domxml.php http://uk.php.net/manual/en/ref.xslt.php http://uk.php.net/manual/en/ref.xsl.php depending on their availability? TIA. Best, Darren -- == D. D. Brierton[EMAIL PROTECTED] www.dzr-web.com Trying is the first step towards failure (Homer Simpson) == -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To mysqli or not to mysqli
On 4/20/05, Jared Williams [EMAIL PROTECTED] wrote: Why not use PDO :) Pacific Decadal Oscillation? I'm stumped. -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] To mysqli or not to mysqli
On 4/20/05, Jared Williams [EMAIL PROTECTED] wrote: Why not use PDO :) Pacific Decadal Oscillation? I'm stumped. PHP Data Objects http://www.php.net/pdo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 32 bit PNG (256 color alpha channel), TGA images, etc
Andrew D. Keyser wrote: I find it not quite right that imagecolorallocatealpha is limited to 128 levels right now (0-127) ... the png format can support 256 with true 32bit images. I am concerned about this because I am using php to make an application that loads a nonstandard image format (MM2/MC TEX) and converts it to png - but the format supports 256 alpha levels, imagecolorallocatealpha does not, and therefore I am losing small amounts of detail in the alpha channel by reducing it to conform to the max 128 levels idea. Can I get an explanation as to why it's limited at 128 levels instead of the preferred 256, and maybe an estimate or guess to whether or not this limitation will ever be lifted? On to the next part of this post. Is there any way to create an equivalent to imagecreatefrompng for tga (maybe imagecreatefromtga), /including/ alpha channel? I've found examples on php.net, but none of them take an image with more than 256 colors, much less one with an alpha channel. I'm not keen on the binary structure of the tga format, but i might be required to learn it this time.. Andrew It's likely limitation of gd or png library. Try imagick extension: http://pecl.php.net/packages.php?catpid=12catname=Images -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To mysqli or not to mysqli
On 4/20/05, Jared Williams [EMAIL PROTECTED] wrote: PHP Data Objects http://www.php.net/pdo Sweet.. DBI for PHP. -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] converting word document to plain text file
hi, i need to store some files that contain text in my database. im planing to upload the file using a php script. what id like is to be able to take the info(text writen in the file) from the file and store it on a plain text file and then store it since i plan to consult the info in these plain text files later. the thing is that in case someone decides to upload a *.doc, *.rtf or *.pdf, i dont know how to read such files to get the text from them. is there a way to these types of files in php or some other way? thanx. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Abstract Legacy question
Hi group This is kinda hard to say in words, so I'll give a little example Class A function x calls function guid function y function z function guid Class B extends A function y calls function x function guid So what I'm wondering is when class B calls its function Y, it will in its turn call function X (which is not overloaded in class B) and function X calls the function GUID from which class? Class A or Class B? Kind regards Andy -- Registered Linux User Number 379093 -- --BEGIN GEEK CODE BLOCK- Version: 3.1 GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++ L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++) PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+) e$@ h++(*) r--++ y--() -- ---END GEEK CODE BLOCK-- -- Check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Abstract Legacy question
* Andy Pieters [EMAIL PROTECTED]: This is kinda hard to say in words, so I'll give a little example Class A function x calls function guid function y function z function guid Class B extends A function y calls function x function guid So what I'm wondering is when class B calls its function Y, it will in its turn call function X (which is not overloaded in class B) and function X calls the function GUID from which class? Class A or Class B? Since Class B overrides method guid, function x will call the method from Class B. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why is the default value for arg_separator.output ''?
Jochem Maas wrote: Representing characters as amp; has been a requirement of SGML and XML based languages you might be able to put this func to use somewhere: Not really, since my concern is with URLs modified by the session handling code and that can be fixed by changing the arg_separator.output ini directive. I'm just trying to work out if the default value for that directive is (rather then amp; or ;) due to a bug or if there is a good reason for it. -- David Dorward http://blog.dorward.me.uk/ http://dorward.me.uk/ Home is where the ~/.bashrc is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Abstract Legacy question [SOLVED]
On Wednesday 20 April 2005 23:36, Matthew Weier O'Phinney wrote: Since Class B overrides method guid, function x will call the method from Class B. Thank you. Andy -- Registered Linux User Number 379093 -- --BEGIN GEEK CODE BLOCK- Version: 3.1 GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++ L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++) PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+) e$@ h++(*) r--++ y--() -- ---END GEEK CODE BLOCK-- -- Check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] converting word document to plain text file
On Wednesday 20 April 2005 23:14, Cima wrote: them. is there a way to these types of files in php or some other way? The easiest way is to tell your users you expect file format to be text only. You can test for mime type by using built-in php functions (and should do so!). The hard way means that you need a parser for pdf, rtf, and doc files. PDF is open format so there will no doubt be some PEAR module for it. Rtf is quit ieasy to parse yourself, and doc is m$ propriety so that will be a lot more difficult to implement. Or better, you might find a commandline tool that can do the job for you, and call that from within php. Before doing so, please take at least one day to study security. Since you provide your users with a way to transfer files to your server. And you process those files then possibly users can hack your server. When you got it working, report back here and ask us to analyze your code for pointers on how to make it more secure. Good luck! Andy ps: Google is your friend! http://www.google.com/search?num=100q=%22read+pdf%22+%2BphpbtnG=Search Also search on PEAR http://pear.php.net -- Registered Linux User Number 379093 -- --BEGIN GEEK CODE BLOCK- Version: 3.1 GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++ L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++) PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+) e$@ h++(*) r--++ y--() -- ---END GEEK CODE BLOCK-- -- Check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Images - Converting TIFF Format?
Hi, Thursday, April 21, 2005, 3:15:31 AM, you wrote: TDJ I searched through my server's system (I'm not running it, it's my ISP) and TDJ finally found that TIFF isn't compiled into GD. I can get them to do it, but TDJ I need to know what functions to use! Are they under a different file type? TDJ I'm pretty sure I searched through thoroughly for the function. Did I miss TDJ something? TDJ Thanks for all your help! As far as I know gd does not support tiffs directly. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Abstract Legacy question
Andy Pieters wrote: This is kinda hard to say in words, so I'll give a little example Class A function x calls function guid function y function z function guid Class B extends A function y calls function x function guid So what I'm wondering is when class B calls its function Y, it will in its turn call function X (which is not overloaded in class B) and function X calls the function GUID from which class? Class A or Class B? class B. Which makes sense if you think about the code, which will look like $this-guid() ... and '$this' is a 'B' Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] script
Thank you both, this was indeed helpful. Now for one more question... I'd like to get my code to calculate the time between the current date (when the page is loaded by the visitor) and the very next Tuesday at 11pm. I suspect I can do this with date(w) but I can't quite figure out how to make Tuesday the beginning or end of the week in order to accomplish this... maybe I'm going about this the wrong way. Again, any pointers or assistance appreciated. Tommy On Apr 19, 2005, at 10:34 PM, Rob Agar wrote: here's the clue to the other half of the puzzle: you can do this kind of thing in php if (whatever) { include 'something.php'; } else { include 'something else.php'; } hth, Rob -Original Message- From: Stephen Johnson [mailto:[EMAIL PROTECTED] Sent: Wednesday, 20 April 2005 11:53 AM To: tommy Cc: php-general@lists.php.net Subject: Re: [PHP] script http://php.net/time http://php.net/date http://php.net/mktime one or a combination of these functions will help you do what you want. HTH On Apr 19, 2005, at 6:37 PM, tommy wrote: I'm hoping someone on this list can help me with something I've been struggling with lately... I have a php based web page that I'd like to have load an include file only when it is Tuesday 11pm - Weds 1 am Eastern Standard time (USA). At other times I would like my page to load and alternate include file. If someone could help me with the code or point me in the right direction it would be very appreciated. Thanks. Tommy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php * Stephen Johnson [EMAIL PROTECTED] http://www.thelonecoder.com --continuing the struggle against bad code-- * -- 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] script
I'd like to get my code to calculate the time between the current date (when the page is loaded by the visitor) and the very next Tuesday at 11pm. I suspect I can do this with date(w) but I can't quite figure out how to make Tuesday the beginning or end of the week in order to accomplish this... maybe I'm going about this the wrong way. Again, any pointers or assistance appreciated. Hmm... well, using date(w) will tell you what day of the week it is, and you know that 0=sunday and 2=tuesday. use that and some logic to compute the number of days between today and the next tuesday. Then figure out how many seconds have elapsed for today and use that in conjunction with the number of days in between and the number of seconds to get to 11pm (23*60*60). Then substract the two... and pass that to date in the format you want. Or something like that :) -philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse error, unexpected T_CLASS
On 4/20/05, Jochem Maas [EMAIL PROTECTED] wrote: Dasmeet Singh wrote: BTW.. pls suggest some good editor.. I use notepad currently.. http://www.php-editors.com/ http://www.google.com/search?hl=enlr=q=good+editor+for+phpbtnG=Search choose one. This can take a long time, I know. My favorite by far on Windows is Crimson Editor (also free as in beer). http://www.crimsoneditor.com/ -KB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular Expression to replace pseudo-HTML?
Hi All, I'm hoping someone can help me figure out a regex that will replace pseudo-HTML codes in a string with desired HTML equivalents. In particular, I'm trying to implement a message quoting facility, such as when you click on the 'quote' button in phpBB. An example of a source string would be: source string [quote=John]Some quoted text. Some more quoted text. [quote=Mary]My older comment.[/quote][/quote] My current comments. /source string Ideally, I'd like this to become something like: regexed string div class='quotehead' John wrote: /div div cass='quote' Some quoted text. Some more quoted text. div class='quotehead' Mary wrote: /div div class='quote' My older comment. /div /div My current comments. /regexed string Given that pseudo-HTML seems common on bulletin board systems I'd hoped there'd be a published function available to handle it, but I haven't had any luck finding one and while I've been able to find a couple of regex examples (eg http://www.regexlib.com/REDetails.aspx?regexp_id=520) they appear to be aimed at ASP.NET rather than PHP and my attempts to get them working in PHP (hampered, admittedly, by my general confusion about regex's) haven't met with any luck. Truly, any help immensely appreciated! Much warmth, Murray