php-general Digest 9 Feb 2008 11:36:12 -0000 Issue 5283
php-general Digest 9 Feb 2008 11:36:12 - Issue 5283 Topics (messages 268978 through 269002): php 4.x + mysql 5 268978 by: ahlist 268980 by: Jim Lucas 268996 by: ahlist issues with calling methods twice in a row 268979 by: nihilism machine 268982 by: Jim Lucas 268983 by: Nathan Nobbe 268984 by: nihilism machine 268985 by: Nathan Nobbe 268986 by: Jochem Maas Re: Name of variable to string [SOLVED] 268981 by: tedd 268987 by: Daniel Brown 268988 by: Jim Lucas 268989 by: Jochem Maas 268990 by: tedd 268991 by: Robert Cummings 268992 by: tedd 268993 by: tedd Order directory output 268994 by: Pastor Steve 268995 by: Jim Lucas 268997 by: Shawn McKenzie 268998 by: Nathan Nobbe 268999 by: Nathan Nobbe 269000 by: Paul Scott 269002 by: Børge Holen Posting Summary for Week Ending 8 February, 2008: [EMAIL PROTECTED] 269001 by: PostTrack [Dan Brown] Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- Hi, I have a client who requires php 4.x with mysql 5 (cannot use php 5 for this project). Can anyone confirm that it is possible to use this combination without setting mysql to use old-style passwords. I have a clean php 4.4.7 compile but it still shows the old mysql lib version. I can't find where it is picking that up at. Is it just built into the php sources that way? Thanks. ---End Message--- ---BeginMessage--- ahlist wrote: Hi, I have a client who requires php 4.x with mysql 5 (cannot use php 5 for this project). Too bad... Can anyone confirm that it is possible to use this combination without setting mysql to use old-style passwords. Not sure I have a clean php 4.4.7 compile but it still shows the old mysql lib version. I can't find where it is picking that up at. Is it just built into the php sources that way? Yes, it is included with the php source. If you want it to use newer libs, then download the devel packages for the newer mysql version and at compile time, point the configure script for php use the newer devel libs instead. That should be all that is needed. Thanks. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare ---End Message--- ---BeginMessage--- On Feb 8, 2008 4:16 PM, Jim Lucas [EMAIL PROTECTED] wrote: ahlist wrote: Hi, I have a clean php 4.4.7 compile but it still shows the old mysql lib version. I can't find where it is picking that up at. Is it just built into the php sources that way? Yes, it is included with the php source. If you want it to use newer libs, then download the devel packages for the newer mysql version and at compile time, point the configure script for php use the newer devel libs instead. That should be all that is needed. Good idea! I may end up doing that. My goal is to position this so that a move to php5 would work and not be stuck with a bunch of old-style mysql passwords that need updated by users (since the original passwords are not retrievable of course for conversion unless I store plain text copies, which I do not want to do). Thanks for your input. ---End Message--- ---BeginMessage--- i have a method called CreateUser() which is public and takes 5 variables as its data, then adds them to a db. it only executes the first method not the other although its all the same but the variable. ex: $auth = new auth(); $auth-CreateUser(fake email, 1, fake name, 4); $auth-CreateUser(fake email, 2, fake name, 4); $auth-CreateUser(fake email, 3, fake name, 4); $auth-CreateUser(fake email, 4, fake name, 4); $auth-CreateUser(fake email, 5, fake name, 4); any ideas? only the first method gets executed? ---End Message--- ---BeginMessage--- nihilism machine wrote: i have a method called CreateUser() which is public and takes 5 variables as its data, then adds them to a db. it only executes the first method not the other although its all the same but the variable. Here you say that the method takes five (5) variables. ex: $auth = new auth(); $auth-CreateUser(fake email, 1, fake name, 4); $auth-CreateUser(fake email, 2, fake name, 4); $auth-CreateUser(fake email, 3, fake name, 4); $auth-CreateUser(fake email, 4, fake name, 4); $auth-CreateUser(fake email, 5, fake name, 4); But here, you are only putting 4 variables in the method call. Are you missing something that is required? The fifth field perhaps? any ideas? only the first method gets executed? -- Jim Lucas Some men are born to greatness, some achieve greatness, and
Re: [PHP] Re: Order directory output
On Saturday 09 February 2008 02:22:28 Shawn McKenzie wrote: Pastor Steve wrote: Hi, thanks for all your help today. I have the following code and I am trying to order the output. Currently it seems really random. Can anyone point me in the right direction? ?php $dir = content/current/breaking_news/; // set pattern $pattern = .txt*|.TXT*; // open directory and parse file list if (is_dir($dir)) { if ($dh = opendir($dir)) { //This is the div that contains the wrap around for the breaking news section. echo div class=\spstory\ style=\font-family: Times New Roman, Times, serif; font-size: 12px; width: 290px;\ div style=\width: 285px; background-color: #CC; padding: 3px;\ span class=\NormalHeadRed\Breaking News/span br /Please check here often for breaking news stories. /div p / span class=\NomalText\ ul; // iterate over file list while (($filename = readdir($dh)) !== false) { // if filename matches search pattern, print it if (ereg($pattern, $filename)) if(strpos($filename,'.')0) { $fh = fopen($dir . $filename, r); $filehead = fgets($fh); fclose($fh); echo li class=\bn_bullet\ a href=\/breaking_news/$filename\$filehead/a /li; } } echo /ulp / /span /div; // close directory closedir($dh); } } ? Thank you, -- Steve Marquez How is the output random? The text from the file, or the order the files are read? I recon its the same problem I faced where files are read in the fifo order instead of alphabetical. or did I miss out on this thread completly? -- --- Børge Holen http://www.arivene.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Posting Summary for Week Ending 8 February, 2008: php-general@lists.php.net
OI, I'm topposting in irritation herer ;) I've actuallly sent a couple of sarcasting mails and their not even counted. damn you dan. damn you btw, how did you build the sarcasms detect script? ;D my oh my I'm in good mood this morning. On Friday 08 February 2008 22:00:40 PostTrack [Dan Brown] wrote: Posting Summary for PHP-General List Week Ending: Friday, 8 February, 2008 Messages| Bytes | Sender ++-- 391 (100%) 581347 (100%) EVERYONE 32 (8.2%) 41862 (7.2%) Daniel Brown parasane at gmail dot com 27 (6.9%) 29259 (5%)Nathan Nobbe quickshiftin at gmail dot com 21 (5.4%) 23274 (4%)Paul Scott pscott at uwc dot ac dot za 17 (4.3%) 26180 (4.5%) Jochem Maas jochem at iamjochem dot com 15 (3.8%) 23318 (4%) Richard Lynch ceo at l-i-e dot com 15 (3.8%) 9331(1.6%) Per Jessen per at computer dot org 14 (3.6%) 15963 (2.7%) Eric Butera eric dot butera at gmail dot com 14 (3.6%) 11187 (1.9%) Richard Heyes richardh at phpguru dot org 12 (3.1%) 52246 (9%)szalinski barneytramble at gmail dot com 11 (2.8%) 27715 (4.8%) Shawn McKenzie nospam at mckenzies dot net 11 (2.8%) 9530(1.6%) Greg Donald gdonald at gmail dot com 9 (2.3%) 14608 (2.5%) Jim Lucas lists at cmsws dot com 9 (2.3%) 15210 (2.6%) Casey heavyccasey at gmail dot com 8 (2%)12953 (2.2%) Andrew Ballard aballard at gmail dot com 7 (1.8%) 11631 (2%)Robert Cummings robert at interjinn dot com 7 (1.8%) 21742 (3.7%) Manuel Lemos mlemos at acm dot org 6 (1.5%) 14733 (2.5%) Mad Unix madunix at gmail dot com 6 (1.5%) 10924 (1.9%) Zoltán Németh znemeth at alterationx dot hu 6 (1.5%) 11225 (1.9%) Wolf LoneWolf at nc dot rr dot com 6 (1.5%) 8139 (1.4%) Jason Pruim japruim at raoset dot com 6 (1.5%) 4308 (0.7%) js ebgssth at gmail dot com 5 (1.3%) 14543 (2.5%) Robbert van Andel robbert at vafam dot com 5 (1.3%) 5272(0.9%) Chris dmagick at gmail dot com 5 (1.3%) 4450(0.8%) Martin Marques martin at marquesminen dot com dot ar 4 (1%)4817(0.8%) Prabath Kumarasinghe prabath321 at yahoo dot com 4 (1%)11452 (2%)Nathan Rixham nrixham at gmail dot com 4 (1%)7322(1.3%) Warren Vail warren at vailtech dot net 4 (1%)4249(0.7%) Bastien Koert bastien_k at hotmail dot com 3 (0.8%) 2577 (0.4%) clive clive_lists at immigrationunit dot com 3 (0.8%) 3088(0.5%) jeffry s paragasu at gmail dot com 3 (0.8%) 4269(0.7%) Larry Garfield larry at garfieldtech dot com 3 (0.8%) 2680(0.5%) Pieter du Toit pieter at lpwebdesign dot co dot za 3 (0.8%) 3762(0.6%) John Taylor-Johnston John dot Taylor-Johnston at cegepsherbrooke dot qc dot ca 3 (0.8%) 9312(1.6%) Louie Miranda lmiranda at gmail dot com 3 (0.8%) 14240 (2.4%) McNaught, Scott scott dot mcnaught at synergy8 dot com 3 (0.8%) 1511(0.3%) Ron Piggott ron dot php at actsministries dot org 2 (0.5%) 1786(0.3%) John Taylor-Johnston jt dot johnston at USherbrooke dot ca 2 (0.5%) 839 (0.1%) AmirBehzad Eslami behzad dot eslami at gmail dot com 2 (0.5%) 1561(0.3%) blackwater dev blackwaterdev at gmail dot com 2 (0.5%) 841 (0.1%) nihilism machine nihilismmachine at gmail dot com 2 (0.5%) 2058(0.4%) Michael Moyle mmoyle at gaba dot co dot jp 2 (0.5%) 1147 (0.2%) ehl lhe ehl22_12 at hotmail dot com 2 (0.5%) 13541 (2.3%) Andrés Robinet agrobinet at bestplace dot biz 2 (0.5%) 2559(0.4%) Nikolay Ananiev ananiev at thegdb dot com 2 (0.5%) 2226(0.4%) VamVan vamseevan at gmail dot com 2 (0.5%) 1784(0.3%) Alain Roger raf dot news at gmail dot com 2 (0.5%) 3927(0.7%) Mr Webber captain_webber at hotmail dot com 2 (0.5%) 2935(0.5%) David Giragosian dgiragosian at gmail dot com 2 (0.5%) 1548(0.3%) pobox at verysmall dot org pobox at verysmall dot org 2 (0.5%) 1661 (0.3%) Feris Thia C dot feris dot thia at gmail dot com 2 (0.5%) 1244(0.2%) LKSunny ad at pc86 dot com 2 (0.5%) 1662(0.3%) Robert Fitzpatrick lists at webtent dot net 1 (0.3%) 365 (0.1%) Brian Dunning brian at briandunning dot com 1 (0.3%) 991
[PHP] PHP debugger recommendations, anyone?
Hi all, I am getting tired of writing echo statements for almost every parameter, then deleting them while I am writing code. I would really like a debugger which would work with my browser. I have run across an open source one, Xdebug, and would like to hear of other's experience with it. 2.0.2 is, I believe, the latest release. Mary Anderson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP debugger recommendations, anyone?
On Feb 9, 2008 11:48 AM, Mary Anderson [EMAIL PROTECTED] wrote: Hi all, I am getting tired of writing echo statements for almost every parameter, then deleting them while I am writing code. I would really like a debugger which would work with my browser. I have run across an open source one, Xdebug, and would like to hear of other's experience with it. 2.0.2 is, I believe, the latest release. hi mary, using xdebug for debugging involves the selection of a debugging client besides just the debugger itself. with xdebug ive used Eclipse PDT, and Protoeditor. PDT was really smooth because if i did something in the browser like, navigate away from the current page for example; PDT seemed to capture that. The downside of PDT was a lack of directory mapping support (they may have it by now). what this is, is a way to tell your xdebug client where the files on the remote server are, that are on your local system (the ones youre debugging). since PDT lacked this feature, i was unable to set breakpoints, which was very limiting. protoeditor is cool, but i had some problems with it as well; in all it didnt seem nearly as smooth as PDT and it didnt seem to be able to capture navigation away from the current page in the browser, also quite limiting. one issue i had w/ PDT was personal confusion with the controls in the ui. sometimes i would have to close down eclipse just to sort of reset things. in general, i think youll find these tools neat to experiment with, but when i was using them several months back they didnt seem ready for prime time. perhaps i should give them another look.. -nathan
[PHP] Re: issues with calling methods twice in a row
Evening, with a great deal of assuming, I would assume that you are saving all these new users to database, in that database you have a unique key on the email address (as you should) and because you're using the same email address, the insert's are getting ignored. ie function runs, but no data is saved due to key conflicts. that is with a hell of a lot of assuming though! try the ol' echo here; in your function and see if you get five here's on screen! Nathan nihilism machine wrote: i have a method called CreateUser() which is public and takes 5 variables as its data, then adds them to a db. it only executes the first method not the other although its all the same but the variable. ex: $auth = new auth(); $auth-CreateUser(fake email, 1, fake name, 4); $auth-CreateUser(fake email, 2, fake name, 4); $auth-CreateUser(fake email, 3, fake name, 4); $auth-CreateUser(fake email, 4, fake name, 4); $auth-CreateUser(fake email, 5, fake name, 4); any ideas? only the first method gets executed? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP debugger recommendations, anyone?
zend studio with zend debugger? Nathan Nobbe wrote: On Feb 9, 2008 11:48 AM, Mary Anderson [EMAIL PROTECTED] wrote: Hi all, I am getting tired of writing echo statements for almost every parameter, then deleting them while I am writing code. I would really like a debugger which would work with my browser. I have run across an open source one, Xdebug, and would like to hear of other's experience with it. 2.0.2 is, I believe, the latest release. hi mary, using xdebug for debugging involves the selection of a debugging client besides just the debugger itself. with xdebug ive used Eclipse PDT, and Protoeditor. PDT was really smooth because if i did something in the browser like, navigate away from the current page for example; PDT seemed to capture that. The downside of PDT was a lack of directory mapping support (they may have it by now). what this is, is a way to tell your xdebug client where the files on the remote server are, that are on your local system (the ones youre debugging). since PDT lacked this feature, i was unable to set breakpoints, which was very limiting. protoeditor is cool, but i had some problems with it as well; in all it didnt seem nearly as smooth as PDT and it didnt seem to be able to capture navigation away from the current page in the browser, also quite limiting. one issue i had w/ PDT was personal confusion with the controls in the ui. sometimes i would have to close down eclipse just to sort of reset things. in general, i think youll find these tools neat to experiment with, but when i was using them several months back they didnt seem ready for prime time. perhaps i should give them another look.. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php 4.x + mysql 5
save passwords as sha2 or such like instead? further, it would appear that since the old password new password is set mysql server side, then php will have no bearing what so ever on how passwords are saved, seeing as it's mysql which will run the password() function and not php :) ps too bad on the ol php 4 job Nathan ahlist wrote: On Feb 8, 2008 4:16 PM, Jim Lucas [EMAIL PROTECTED] wrote: ahlist wrote: Hi, I have a clean php 4.4.7 compile but it still shows the old mysql lib version. I can't find where it is picking that up at. Is it just built into the php sources that way? Yes, it is included with the php source. If you want it to use newer libs, then download the devel packages for the newer mysql version and at compile time, point the configure script for php use the newer devel libs instead. That should be all that is needed. Good idea! I may end up doing that. My goal is to position this so that a move to php5 would work and not be stuck with a bunch of old-style mysql passwords that need updated by users (since the original passwords are not retrievable of course for conversion unless I store plain text copies, which I do not want to do). Thanks for your input. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php file extension
Often people install php4 and 5 on the same server, then configure .php to use the latest version of php(5) and anything with extension php4 to use the old`e php4. Thus, the file contents remain the same, however the way they are executed depends entirely on the server(s) config. Nathan MaryAnn Woodall wrote: Just starting to use php on my webpages. If I save a file as .php or .php4 are they the same file. For example is index.php the same as index.php4? MaryAnn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] re: php file extension
and if you want even more superfluous information windows, more specifically, ntfs, doest support files with only capitalization differences in the file names. eg. WindowsSucks.txt windowssucks.txt -nathan
Re: [PHP] PHP debugger recommendations, anyone?
On Feb 9, 2008 3:02 PM, Nathan Rixham [EMAIL PROTECTED] wrote: It suddenly dawned on me that you are doing an echo for every paremeter, a debugger will never completely alleviate the need for this, however try using: print_r(get_defined_vars()); instead, that way you get everything output that you could need, it's often also worth putting an exit(); after prining out so you can see where the script is failing; if indeed it is. get_defined_vars() can be a real hassle to sift through, mainly because it spits out a bunch of data you dont usually want to see. if you want to see the values of a given functions parameters w/o an echo statement for each on the best way is to use, func_get_args(); eg. die(var_dump(func_get_args())); also, xdebug has something called function traces; which you dont need to configure a client for. it will simply log all function calls to a file and its configurable, so you can have it log the values of actual parameters if you like. and it also ships w/ a special highlighter for vim, which is quite nice. http://xdebug.org/docs/execution_trace -nathan
Re: [PHP] PHP debugger recommendations, anyone?
It suddenly dawned on me that you are doing an echo for every paremeter, a debugger will never completely alleviate the need for this, however try using: print_r(get_defined_vars()); instead, that way you get everything output that you could need, it's often also worth putting an exit(); after prining out so you can see where the script is failing; if indeed it is. Nathan Nathan Rixham wrote: zend studio with zend debugger? Nathan Nobbe wrote: On Feb 9, 2008 11:48 AM, Mary Anderson [EMAIL PROTECTED] wrote: Hi all, I am getting tired of writing echo statements for almost every parameter, then deleting them while I am writing code. I would really like a debugger which would work with my browser. I have run across an open source one, Xdebug, and would like to hear of other's experience with it. 2.0.2 is, I believe, the latest release. hi mary, using xdebug for debugging involves the selection of a debugging client besides just the debugger itself. with xdebug ive used Eclipse PDT, and Protoeditor. PDT was really smooth because if i did something in the browser like, navigate away from the current page for example; PDT seemed to capture that. The downside of PDT was a lack of directory mapping support (they may have it by now). what this is, is a way to tell your xdebug client where the files on the remote server are, that are on your local system (the ones youre debugging). since PDT lacked this feature, i was unable to set breakpoints, which was very limiting. protoeditor is cool, but i had some problems with it as well; in all it didnt seem nearly as smooth as PDT and it didnt seem to be able to capture navigation away from the current page in the browser, also quite limiting. one issue i had w/ PDT was personal confusion with the controls in the ui. sometimes i would have to close down eclipse just to sort of reset things. in general, i think youll find these tools neat to experiment with, but when i was using them several months back they didnt seem ready for prime time. perhaps i should give them another look.. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Order directory output
On Saturday 09 February 2008 17:47:24 you wrote: The output is: 04.txt 01.txt 03.txt 02.txt 05.txt When the files are named: 01.txt 02.txt 03.txt 04.txt 05.txt jup fifo. first on the filesystem first out. Thanks, -- Steve M. on 2/9/08 5:36 AM Børge Holen ([EMAIL PROTECTED]) wrote: On Saturday 09 February 2008 02:22:28 Shawn McKenzie wrote: Pastor Steve wrote: Hi, thanks for all your help today. I have the following code and I am trying to order the output. Currently it seems really random. Can anyone point me in the right direction? ?php $dir = content/current/breaking_news/; // set pattern $pattern = .txt*|.TXT*; // open directory and parse file list if (is_dir($dir)) { if ($dh = opendir($dir)) { //This is the div that contains the wrap around for the breaking news section. echo div class=\spstory\ style=\font-family: Times New Roman, Times, serif; font-size: 12px; width: 290px;\ div style=\width: 285px; background-color: #CC; padding: 3px;\ span class=\NormalHeadRed\Breaking News/span br /Please check here often for breaking news stories. /div p / span class=\NomalText\ ul; // iterate over file list while (($filename = readdir($dh)) !== false) { // if filename matches search pattern, print it if (ereg($pattern, $filename)) if(strpos($filename,'.')0) { $fh = fopen($dir . $filename, r); $filehead = fgets($fh); fclose($fh); echo li class=\bn_bullet\ a href=\/breaking_news/$filename\$filehead/a /li; } } echo /ulp / /span /div; // close directory closedir($dh); } } ? Thank you, -- Steve Marquez How is the output random? The text from the file, or the order the files are read? I recon its the same problem I faced where files are read in the fifo order instead of alphabetical. or did I miss out on this thread completly? -- --- Børge Holen http://www.arivene.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Better DB Class MySQL
Looking to really beef up my DB class, any suggestions for functions to add that will be more time saving for a web 2.0 app, or ways to improve existing methods? thank you everyone in advance. ?php class db { // Members public $db_user = ; public $db_pass = ; public $db_name = ; public $db_server = ; public $link; public $result_id; // Methods public function __construct() { $this-connect(); } // Connect to MySQL Server public function connect() { $this-link = mysql_connect($this-db_server,$this-db_user,$this- db_pass) or die(Error: Cannot Connect to DataBase); mysql_select_db($this-db_name,$this-link) or die(Error: Cannot Select Database ( . $this-db_name . )); } // MySQL Query public function query($sql) { $this-result_id = mysql_query($sql); return $this-fetch_rows(); } // MySQL Query public function insert($sql) { $this-result_id = mysql_query($sql); return $this-select_id; } // MySQL Fetch Rows public function fetch_rows() { $rows = array(); if($this-result_id){ while($row = mysql_fetch_object($this-result_id)) { $rows[] = $row; } } return $rows; } // MySQL Affected Rows public function num_rows() { return mysql_num_rows($this-link); } // MySQL Affected Rows public function select_id() { return mysql_insert_id($this-link); } // Disconnect from MySQL Server public function disconnect() { mysql_close($this-link); } // Terminator Style Function simply in coolness public function Terminator($tbl) { } // Destruct! public function __destruct() { $this-disconnect(); } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
http://www.php.net/pdo All the cool kids are doing it. On Saturday 09 February 2008, nihilism machine wrote: Looking to really beef up my DB class, any suggestions for functions to add that will be more time saving for a web 2.0 app, or ways to improve existing methods? thank you everyone in advance. ?php class db { // Members public $db_user = ; public $db_pass = ; public $db_name = ; public $db_server = ; public $link; public $result_id; // Methods public function __construct() { $this-connect(); } // Connect to MySQL Server public function connect() { $this-link = mysql_connect($this-db_server,$this-db_user,$this- db_pass) or die(Error: Cannot Connect to DataBase); mysql_select_db($this-db_name,$this-link) or die(Error: Cannot Select Database ( . $this-db_name . )); } // MySQL Query public function query($sql) { $this-result_id = mysql_query($sql); return $this-fetch_rows(); } // MySQL Query public function insert($sql) { $this-result_id = mysql_query($sql); return $this-select_id; } // MySQL Fetch Rows public function fetch_rows() { $rows = array(); if($this-result_id){ while($row = mysql_fetch_object($this-result_id)) { $rows[] = $row; } } return $rows; } // MySQL Affected Rows public function num_rows() { return mysql_num_rows($this-link); } // MySQL Affected Rows public function select_id() { return mysql_insert_id($this-link); } // Disconnect from MySQL Server public function disconnect() { mysql_close($this-link); } // Terminator Style Function simply in coolness public function Terminator($tbl) { } // Destruct! public function __destruct() { $this-disconnect(); } } ? -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
On Feb 9, 2008 7:03 PM, nihilism machine [EMAIL PROTECTED] wrote: Looking to really beef up my DB class, any suggestions for functions to add that will be more time saving for a web 2.0 app, or ways to improve existing methods? thank you everyone in advance. first of all, as a matter of style, its conventional to capitalize class names. so you would change the name to Db. also, conventionally, member functions are not capitalized; so Terminator(), becomes terminator(). next thing is you have no escaping of the queries. you should be wrapping the $sql that gets passed into your query method in mysql_real_escape_string(). the insert() method appears to have a problem; public function insert($sql) { $this-result_id = mysql_query($sql); return $this-select_id; } namely, its returning an instance variable that isnt set anywhere else. i see no method named update() or delete() (or drop() [although im not sure if you really need that]). but im guessing you are probly using insert() for these sorts of queries. you should either create these methods and have them use a common function w/ private access that does the query and stores mysql_affected_rows(), or at the very least rename insert() to something more appropriate. im not sure why you would name a call to mysql_insert_id(), select_id(); it seems better to preserve the original name. you might also want methods that allow iteration over the result set, rather than just a single method which buffers the entire result set into an array and returns it. -nathan
Re: [PHP] Better DB Class MySQL
On Sat, 2008-02-09 at 18:39 -0600, Larry Garfield wrote: http://www.php.net/pdo All the cool kids are doing it. I always told the cool kids to kiss my buttocks. You too can set yourself apart from the sheeple :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urgent !!! Please Help preg_replace !!!!!!!!!!!!!!!!!!!!!
On Sun, 2008-02-10 at 14:33 +0800, LKSunny wrote: //please run this script, you can get what problem i got $html = eof a href=aaa.htmlaaa/a a href=bbb.htmlcfdfd/a a href=aaa.htmlsfs sfsrbbb sfds/a a href=aaa.htmlcc gd c/a a href=aaa.htmlddd 123/a eof; /* i want replace any |a.has bbb./a|, like a href=bbb.htmlcfdfd/a a href=aaa.htmlsfs sfsrbbb sfds/a */ ?php $reps = array ( array ( 'match' = '#a.*/a#Uims', 'check' = '#bbb#', 'replace' = 'X', ), ); foreach( $reps as $criteria ) { if( preg_match_all( $criteria['match'], $html, $matches ) ) { foreach( $matches[0] as $match ) { if( preg_match( $criteria['check'], $match ) ) { $html = str_replace( $match, $criteria['replace'], $html ); } } } } ? This does what you want to $html, but it doesn't do it in a single regex. I'm not sure it can be done with a single regex, and if it can, I doubt it's simple. I don't feel like investigating too far :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php