RE: [PHP] Help me learn! with an explanation of these two functions.
Ok this is starting to get complex! (For me anyway) This is my function: function get_order_numbers() { $conn = db_connect(); $query = select orders.orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); $orderid = $row; $query2 = SELECT * FROM orders WHERE orderid=\$orderid\; $result2 = mysql_query($query2) or die(Error: cannot fetch orderBR$query2BR.mysql_error()); extract(mysql_fetch_array($result2)); } } The SQL works Ok. At least I get no errors now. It's my PHP to display the SQL I think I get a result of 8 errors with the following message. Warning: Wrong datatype in call to extract() in /www/u1255/eadmin/eshop_fns.php on line 40. Where line 40 is: extract(mysql_fetch_array($result2)); I am trying to display the message on another page using: ? include ('eshop_fns.php'); get_order_numbers(); $ship_name = $result2[ship_name]; echo tests and $ship_name; ? What does extract do? I am under the assumption it extracts row information so why a datatype error? Any pointers? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Javascript and PHP
Hi. I'm not sure if is here where i have to ask this, but, if it's not i hope you say to me :D. Well the question is: i want to know how can i make to insert into the $_GET or $_POST arrays, an entry with a value from javascript. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help me learn! with an explanation of these two functions.
At 09:52 06.11.2002, Steve Jackson said: [snip] function get_order_numbers() { $conn = db_connect(); $query = select orders.orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); $orderid = $row; $query2 = SELECT * FROM orders WHERE orderid=\$orderid\; $result2 = mysql_query($query2) or die(Error: cannot fetch orderBR$query2BR.mysql_error()); extract(mysql_fetch_array($result2)); } } The SQL works Ok. At least I get no errors now. It's my PHP to display the SQL I think I get a result of 8 errors with the following message. Warning: Wrong datatype in call to extract() in /www/u1255/eadmin/eshop_fns.php on line 40. Where line 40 is: extract(mysql_fetch_array($result2)); Steve, maybe the second fetch doesn't return anything because the resultset is empty? You should assign the second fetch to a variable and test it before passing it to extract (as with the first fetch): $row2 = mysql_fetch_array($result2); if (is_array($row2)) { extract($row2); // ... } What does extract do? I am under the assumption it extracts row information so why a datatype error? Any pointers? --- [doc] --- int extract ( array var_array [, int extract_type [, string prefix]]) This function is used to import variables from an array into the current symbol table. It takes an associative array var_array and treats keys as variable names and values as variable values. For each key/value pair it will create a variable in the current symbol table, subject to extract_type and prefix parameters. --- [/doc] -- May I suggest getting the Camel Book, or at least consult the EXCELLENT online PHP manual at http://www.php.net/manual/en/. If you read about mysql_fetch_array you'll notice the additional optional parameter result_type. Since you're going to pass the resulting data to extract it helps to specify MYSQL_ASSOC as result_type, this will omit the numerically indexed data from the fetched array, which isn't used by extract() anyway. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/
RE: [PHP] How do I convert an array into a mask?
Michael, I like your idea, and had I designed this site, I would have the bitmask simmilar to what you suggest. However, I'm a contractor modding an existing/legacy site. Basically the way they have it, is that each user has a field in the db that is simply a string/mask of which books a person has access to see. So given the example below, 10110 means that the person can view books 1, 3, and 4, but not 2 or 5. dig? Now, I can brute force this, since there are only a few books. That doesn't lend itself nicely to expansion, but may be my only way. I just have a gut feeling that it can be automated somehow. To turn 1,3,4 into 10110 seems like there is some 'math' there that can work. I also thought there might be a built in PHP function that may point me in the right direction. I'll post my solution when I get it working if it's elegant... Thanks anyways. P.s. thanks for the correction on boolean vs bitwise OR. Duh. I should have known that ;-) -Original Message- Does anyone know of a nice efficient way to convert an array of values into a mask... Here's the deal. Given an array such that: $purchitem[0] = 1; $purchitem[1] = 3; $purchitem[2] = 4; I want to end up with a variable like this: $mask = 10110; Additionally, my theory is that then the person purchases another book later $purchitem[0] = 2; My new mask should be $purchmask = 01000; Then I can load their previous mask from the database and bitwise OR it with the new mask to set the correct permissions. i.e. $newmask = $mask | $purchmask; Or ideally = 0 Can I boolean OR strings like that in the way I 'hope' it will work? Do I need to convert it to an intermediate stage or cast it or anything? Does this make sense? It's for an online book shopping cart. I have the reverse working, where I can split the mask into what books. And I also have the $purchitem[] working. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
At 10:18 06.11.2002, Daevid Vincent said: [snip] doesn't lend itself nicely to expansion, but may be my only way. I just have a gut feeling that it can be automated somehow. To turn 1,3,4 into 10110 seems like there is some 'math' there that can work. I also [snip] It's quite easy using the left-shift operator . Note that the function below only works for values 1-31 on 32bit systems. ?php function makebits($array) { $result = 0; foreach ($array as $seq) { if (is_numeric($seq)) { $i = 1 ($seq-1); // assuming ID's are 1-based $result += $i; } } return $result; } $a = array(1,3,5,9);// 1 0001 0101 = 0x115 echo 'xmp', sprintf('0x%x', makebits($a)), \n/xmp; ? -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] *.PHP save-as dialog
Lee, I think its the AddType line for php that you want to take out of the IfDefine HTH Chris Lee Philip Reilly wrote: Thanks for your reply. I took out the following lines, and restarted Apache, but I still have the same problem... /IfDefine IfDefine HAVE_PHP LoadModule php_module modules/mod_php.so /IfDefine IfDefine HAVE_PHP3 LoadModule php3_modulemodules/libphp3.so /IfDefine IfDefine HAVE_PHP4 LoadModule php4_modulemodules/libphp4.so /IfDefine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript and PHP
[EMAIL PROTECTED] wrote: Well the question is: i want to know how can i make to insert into the $_GET or $_POST arrays, an entry with a value from javascript. All the php processing (on the server) is complete before the javascript processing (on the client) commences, so you would need to submit to a new location with JS giving parameters in the url. These would then appear in the $_GET array for the location you submit to. HTH Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Installation error with 4.2.3
No one replied to this message yet. I am trying to address it again, as probably the previuos newsmessage title wasn't very descriptive. Thanks Daniele = Hi guys, I have very weird problem. I have installed the PHP version 4.2.3 on the LINUX virtual server of my web project. Previously I had the PHP version 4.0.6. The error I get is very weird. When I insert a record with the phpMyAdmin, the first 4 characters of each field don't get saved. Same thing happened with some data entry interfaces I coded! The only difference I can see in the two installation (provided the php.ini file is in the same location): The old version 4.0.6 was installed by the server provider and my virtual server space I can only see the .so file. The new version 4.2.3 is actually inside my virtual server space. Hence, the path I provided in the php configuration is different (I don't have idea if this can influence something). NEW VERSION (4.2.3) configuration run by me './configure' '--with-apxs=/usr/local/apache/1.3/bin/apxs' '--prefix=/usr/home/rockit/usr/local' '--with-mysql=/usr/home/rockit/usr/local/mysql' '--with-xml' '--enable-xslt' '--with-xslt-sablot=/usr/home/rockit/usr/local' '--with-regex=system' '--with-expat-dir=/usr/home/rockit/usr/local' '--with-iconv=/usr/home/rockit/usr/local' '--enable-inline-optimization' '--disable-debug' '--enable-memory-limit' '--enable-sigchild' '--without-pear' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-gdbm=/usr/local' '--enable-sockets' '--enable-versioning' '--with-ttf=/usr/local' '--enable-ftp' '--with-gd=/usr/local' '--with-zlib' '--enable-gd-native-ttf' OLD VERSION (4.0.6) configuration run by the server provider './configure' '--enable-inline-optimization' '--with-apxs=/usr/local/apache/1.3/bin/apxs' '--with-config-file-path=/usr/local/lib' '--disable-debug' '--enable-memory-limit' '--enable-sigchild' '--with-gettext' '--without-pear' '--with-regex=system' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-iconv=/usr/local' '--with-gdbm=/usr/local' '--with-dbm=/usr/local' '--enable-sockets' '--enable-versioning' '--with-freetype-dir=/usr/local' '--with-ttf=/usr/local' '--enable-ftp' '--with-curl=/usr/local/curl' '--with-openssl=/usr/local/openssl' '--with-gd=/usr/local' '--with-freetype-dir=/usr/local' '--with-ttf=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-t1lib=/usr/local' '--with-zlib' '--enable-gd-native-ttf' '--with-imap' '--with-mcrypt=/usr/local' '--with-mhash=/usr/local' '--with-dom=/usr/local' '--with-mysql=/usr/local/mysql' '--with-zlib' '--with-zlib' I must admit that I didn't not include all parameter as the old installation, as I didn't know most options and thought is not needed. In the new installation I instead provided additional XML parameter (after installing the correspond modules, which all seem to work fine). Hints on problem are very well welcome! Daniele -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help me learn! with an explanation of these two functions.
On Wednesday 06 November 2002 16:52, Steve Jackson wrote: Ok this is starting to get complex! (For me anyway) This is my function: function get_order_numbers() { $conn = db_connect(); $query = select orders.orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); According to your query it should return a single result (assuming your orderid is unique -- and it should be), and that single result contains a single field called orderid. Use print_r($row) to see exactly what it contains (good for reference and debugging). extract($row) would assign to $orderid the value of $row['orderid'] (ie $orderid = $row['orderid']) ... $orderid = $row; ... thus, I don't know why you have this line here. Remove it. $query2 = SELECT * FROM orders WHERE orderid=\$orderid\; This fails because $row is an array and you assigned that to $orderid. What does extract do? I am under the assumption it extracts row information so why a datatype error? rtfm for details and examples. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Take that, you hostile sons-of-bitches! -- James Coburn, in the finale of _The_President's_Analyst_ */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] *.PHP save-as dialog
On Wednesday 06 November 2002 01:50, Lee Philip Reilly wrote: Thanks for your reply. I took out the following lines, and restarted Apache, but I still have the same problem... /IfDefine IfDefine HAVE_PHP LoadModule php_module modules/mod_php.so /IfDefine IfDefine HAVE_PHP3 LoadModule php3_modulemodules/libphp3.so /IfDefine IfDefine HAVE_PHP4 LoadModule php4_modulemodules/libphp4.so /IfDefine You're looking at the wrong thing. IIRC you compiled php as CGI, those lines are only relevant if you're using PHP as a module. I'm not sure, but I think you have to look the the ExecCGI option and use the AddHandler directive to tell apache to treat files ending with '.php' as a cgi program. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Men love to wonder, and that is the seed of science. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Foreach ...... Help
I am Newbie in PHP My Problem It's Too Hard to Explain but i'll try its.. I have Two Text Fields The First Text Field i call it InputX, the amount of InputX is Constant, and The Second Text Field I Call it InputY, Generatable Field I have the Button usefull for Generated InputY (so If I Click The Button It Will Produce amount of InputY). i call the Button AddRow I need to insert data from that form to the server, the script will save the value of Fields (InputX and INPUTY) by once submit. And the amount of value of data saved depent on how many InputY I have. This The sample of Value Of The Fields will saved into the server, if user click 5x AddRow's Button. INPUTXVALUE INPUTYVALUE INDEXSUB1 INDEX SUB2 INDEX SUB3 INDEX SUB4 INDEX SUBX i have done before with my asp script. and it's Worked. % i = 0 Inputx = request(Inputx) dim vary(100) for each y in request(InputY) vary(i) = y i = i + 1 next for each x in request(inputY) insertq = Insert into Nsoftware(X, Y) values (' Inputx ',' vary(i) ') set save = conn.execute(insertq) i = i + 1 next % I try this script with php, but i found an Error. ?php $vary(100); $i = 0; foreach($InputY as $y){ $vary($i) = $y; $i++; } foreach($Nama_Software as $x){ $insertq = Insert into NSoftware (X, Y) values ('$InputX','$vary($i)'); echo $insertq.br; mysql_query($insertq); $i++; } Sorry it's to many CopyPasting.., -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Foreach ...... Help
Hi Remon, I try this script with php, but i found an Error. It would be helpful if you could show us this error message. $vary(100); At the very least, you should change this line to $vary = array(); Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL GMT -- Local time
This might help http://www.mysql.com/doc/en/Date_and_time_functions.html Here is an example that uses date functions. The following query selects all records with a date_col value from within the last 30 days: mysql SELECT something FROM tbl_name WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) = 30; Pete Jason wrote: My logging application is feeding a MySQL database with data records that are time stamped with GMT time. I would like to query the database for records matching local time(eg. all records created on oct 17,2002 local time). I would prefer if the records could be formated in local time when returned from MySQL. What is the best way to do this. Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Install mysql option without recompile PHP ?
Hi, I already have the 4.2.2 PHP version running on my server. But it was compiled without mysql. I want to add this option to use mysql. Must I to recompile my PHP with mysql option, or is there a simpler solution ? Thanks a lot. *---* Audrey Bihouee INSERM U533 Faculté de médecine, 1, rue Gaston Veil 44035 Nantes Cedex 1 Tel : 02.40.41.29.86 *---* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
So given the example below, 10110 means that the person can view books 1, 3, and 4, but not 2 or 5. dig? Explain that to me... I know binary, but I can't see how that equates to 1, 3, and 4. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Handling
Hello, I have tried session handling..after starting the session i am trying to get the value by this command session_start(); echo $varname; but it is displaying this error.. Warning: Cannot send session cookie - headers already sent by (output started Can anyone tell me how to go about with this ?? Regards, Uma -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Handling
You must call session_start before any output to the browser. A blank line or space outside of PHP blocks is considered output. The error message tells you exactly where the output started. Read the manual for more information, it's all covered. ---John Holmes... -Original Message- From: Uma Shankari T. [mailto:umashankari;lantana.tenet.res.in] Sent: Wednesday, November 06, 2002 6:59 AM To: PHP Subject: [PHP] Session Handling Hello, I have tried session handling..after starting the session i am trying to get the value by this command session_start(); echo $varname; but it is displaying this error.. Warning: Cannot send session cookie - headers already sent by (output started Can anyone tell me how to go about with this ?? Regards, Uma -- 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] Permissions
Hi I want to make a secure site. The username , password and permission of the users must be stored in database. I only want certain icons (navigation bars) to be available to certain users. How would i be able to do this with permissions ? Thanks Shaun -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
Hi John, So given the example below, 10110 means that the person can view books 1, 3, and 4, but not 2 or 5. dig? Explain that to me... I know binary, but I can't see how that equates to 1, 3, and 4. Because you know binary :-) The above is a series of yes/no flags, not a binary number. Reading from left to right: book 1 : yes book 2 : no book 3 : yes book 4 : yes book 5 : no Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
Hi John, So given the example below, 10110 means that the person can view books 1, 3, and 4, but not 2 or 5. dig? Explain that to me... I know binary, but I can't see how that equates to 1, 3, and 4. Because you know binary :-) The above is a series of yes/no flags, not a binary number. Reading from left to right: book 1 : yes book 2 : no book 3 : yes book 4 : yes book 5 : no Cheers Jon Ok, so knowing binary and now knowing that, :) Couldn't you just treat the number as a string and tear it apart to see what permissions the user has? ? $var = 10110; $l = strlen($var); for($x=0;$x$l;$x++) { if($var{$x}) { echo Permission for book $x is goodbr\n; } else { echo Permission for book $x is badbr\n; } } ? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
That's the EASY part John! The hard part is converting the array (which was a checkbox array from a form submission) into the binary string (as per the original post) Here's the deal. Given an array such that: $purchitem[0] = 1; //purchased book #1 checkbox enabled $purchitem[1] = 3; //purchased book #3 checkbox enabled $purchitem[2] = 4; //purchased book #4 checkbox enabled I want to end up with a variable like this: $mask = 10110; Get it now? ;-) -Original Message- From: John W. Holmes [mailto:holmes072000;charter.net] Sent: Wednesday, November 06, 2002 4:19 AM To: 'Jon Haworth'; [EMAIL PROTECTED] Subject: RE: [PHP] How do I convert an array into a mask? Hi John, So given the example below, 10110 means that the person can view books 1, 3, and 4, but not 2 or 5. dig? Explain that to me... I know binary, but I can't see how that equates to 1, 3, and 4. Because you know binary :-) The above is a series of yes/no flags, not a binary number. Reading from left to right: book 1 : yes book 2 : no book 3 : yes book 4 : yes book 5 : no Cheers Jon Ok, so knowing binary and now knowing that, :) Couldn't you just treat the number as a string and tear it apart to see what permissions the user has? ? $var = 10110; $l = strlen($var); for($x=0;$x$l;$x++) { if($var{$x}) { echo Permission for book $x is goodbr\n; } else { echo Permission for book $x is badbr\n; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP driven frame
top frame: form target=bottom_frame action=show_form.php select name=form onChange=this.form.submit() option value= -- choose a form -- /option option value=form1 first form /option option value=form2 second form /option /select input type=submit /form bottom frame (show_form.php): switch($_GET['form']){ case 'form1': include 'form1.php'; break; case 'form2': include 'form2.php'; break; case '': echo 'choose a form'; break; } I showed you just the basics, don't forget to name the bottom frame bottom_frame (or change the target). This can be done also on a simple page Chris Rehm wrote: Good point, lack of javascript is a consideration. The request is for a form where the second half format is dependent on the first half. In other words, they make some choices on the top that determine what the form on the bottom will be. But the guy who wants this, wants it to be one screen. Marek Kilimajer wrote: Did you get a request for a two part form, or for a form on 2 pages? The problem I see is with browsers without javascript (either turned of or not implemented) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
That's the EASY part John! The hard part is converting the array (which was a checkbox array from a form submission) into the binary string (as per the original post) Here's the deal. Given an array such that: $purchitem[0] = 1; //purchased book #1 checkbox enabled $purchitem[1] = 3; //purchased book #3 checkbox enabled $purchitem[2] = 4; //purchased book #4 checkbox enabled I want to end up with a variable like this: $mask = 10110; Get it now? ;-) Got it... Are there always going to be X digits in the code? If so, this would work. ? $purchitem[0] = 1; $purchitem[1] = 3; $purchitem[2] = 4; $mask = ''; $length = 5; $y = 0; for($x=1;$x$length+1;$x++) { if($purchitem[$y] == $x) { $mask .= '1'; $y++; } else { $mask .= '0'; } } echo $mask; ? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to do check boxes correclty?
Karl James wrote: Good Afternoon People I am trying to create a site where you can add/delete players From a roster So what I need help is how to automatically format the check Boxes to appear in every row use a table, name your checkboxes 'player[]' with value set to the player's id And to know how to do the add/delete part use a select where you can choose an action, for the add part, use a separate form (may be on the same page) with inputs you need If anyone can come online with me and talk to me that would Be tremendous if they have any free time on there hands. Thanks Karl james -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined symbol: curl-global-init
Do you have libcurl intaled? Ernest E Vogelsinger wrote: Hi list, maybe someone has a simple answer to this: I am running Apache 1.3.22 with libphp4.so. Everything's fine, but when starting php from the command line I get: php: relocation error: php: undefined symbol: curl-global-init Any idea what I should try? Thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generically accessing member variables problem
If I understand you, you need to have a basic class with the one function and subclass it. Then you can reference the array as $this-$passed_in_array_name John Kenyon wrote: I'm trying to write a function I can plop in a bunch of different classes without having to modify it. Basically I have classes like: class Example { var $array1; var $array2; var $array3; etc. } and I want to have a function in that class that looks something like this: function do_something_to_array($passed_in_array_name) { //this is what I've done so far, but which isn't working $arr = '$this-' . $passed_in_array_name; // now I want $passed_in_array_name to be evaluated as an array eval (\$arr = \$arr\;); // however even if 'array1' is the passed in value $arr is not the // same as $this-array1 ... } As a side note there is another aspect of this that confuses me -- if I do a print_r($arr) before the eval it returns the string '$this-array1', if I do it after it returns Array (which is what it seems it should do. However, if I then pass $arr to a function that requires an array as an argument, like array_push, for example, I get an error that says that function takes an array. Can anyone explain this to me? The only guess I have is that my eval function is turning it into a string which reads as Array instead of either a String object or the value of the string. More important though is the first problem of generically accesing a member variable based on the passed in name of the variable. In other words I want to be able to choose which array I operate on by passing in the name of that array. Any help on this problem is appreciated. I know there must be a way to do this. Please let me know if I haven't formulated the problem clearly enough. jck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] addslashes/stripslashes
thanks guys, got it working now. Removed Addslashes and it works fine. 1lt John W. Holmes wrote: I am trying to develop a search for my database. I used addslashes when entering the data, and then use addslashes with the search but nothing comes up: Select * from tblContacts, tblCountries WHERE (tblContacts.CountryCode=tblCountries.CountryID) AND (Organization LIKE '%o\'mallies%' ) I check in the database and o'mallies is indeed there as o\'mallies. And a search for just mallies works fine. If you see it in the database as o\'mallies, then you are running addslashes() twice on the data you are inserting. If you insert o\'mallies into the database, the \ is only there to tell the database that the following character is escaped. In this case, the ' is not the end of the string, but something that should be included in the data that's put into the database. The actual \ isn't put in the database. So, with that said, you can fix your code and find out where you are addslashes() twice. You can run some queries to replace \' in your database with ', too. Or you can just search for o\\\'mallies in your database, which will search for a literal \ and a literal ' in the data. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Socket Programming Problem
I have a web server and want to make it as a file provider... Works similiar to the BBSHowever, the problem is appeared... How can I trigger the user to download those file while they requested?? What can i do after fsock_open() ? thx a lot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
Ernest, close but you have it reversed for my needs (i.e. true binary form). Notice that my LSB is to the left, not right. As Evan Nemerson pointed out to me, the decbin(), bindec(), Dec2Bin() and Bin2Dec() functions shed some light. What I need is the equivillant functions but with a way to flip the order of the bits from LSB to MSB. I believe that is called little endian and big endian? I've been playing with one function to convert my purchitem[] to a decimal value, then use the decbin() to get a string, then reverse it... Seems cumbersome but mebbe that's the solution? function Array2Dec($array) { $decimal = 0; while ( list($Key, $Val) = each($array) ) { //notice the ($Val - 1) because //our array starts at index 0, not 1 $decBit = pow(2, ($Val - 1)); $decimal += $decBit; echo brarray[.$Key.] = .$Val. :: .$decBit; } return $decimal; } function reverseString($myString) { $charArray = preg_split('//', $myString, -1, PREG_SPLIT_NO_EMPTY); $revchars = array_reverse($charArray); $revString = ; while ( list($Key, $Val) = each($revchars) ) { $revString .= $Val; } return $revString; } -Original Message- From: Ernest E Vogelsinger [mailto:ernest;vogelsinger.at] Sent: Wednesday, November 06, 2002 1:28 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] How do I convert an array into a mask? At 10:18 06.11.2002, Daevid Vincent said: [snip] doesn't lend itself nicely to expansion, but may be my only way. I just have a gut feeling that it can be automated somehow. To turn 1,3,4 into 10110 seems like there is some 'math' there that can work. I also [snip] It's quite easy using the left-shift operator . Note that the function below only works for values 1-31 on 32bit systems. ?php function makebits($array) { $result = 0; foreach ($array as $seq) { if (is_numeric($seq)) { $i = 1 ($seq-1); // assuming ID's are 1-based $result += $i; } } return $result; } $a = array(1,3,5,9);// 0001 0001 0101 = 0x115 echo 'xmp', sprintf('0x%x', makebits($a)), \n/xmp; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Permissions
You can use array with the user permissions (stored in a session variable), and use it someway like if($_SESSION['perm']['do_that']) echo 'a href=do_that.phpDo that/a'; Shaun wrote: Hi I want to make a secure site. The username , password and permission of the users must be stored in database. I only want certain icons (navigation bars) to be available to certain users. How would i be able to do this with permissions ? Thanks Shaun -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
Oooh! I think you're on to something there. Nice! Hey, what's the symbol for? I see in the manual the is a reference (like a pointer in C I assume), but I can't find the explained. if($purchitem[$y] == $x) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Handling
On Wed, 6 Nov 2002, John W. Holmes wrote: JWHYou must call session_start before any output to the browser. A blank JWHline or space outside of PHP blocks is considered output. The error JWHmessage tells you exactly where the output started. Read the manual for JWHmore information, it's all covered. Hello, Actually i have started some javascript where its pointing as error..other than that i didn;t leave any line space..Can any one please tell me how to do this.. Regards Uma -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ceil() function
I need a function that rounds up fractions (0.10) not an integer like ceil, or what parameters do I need to give to ceil() to round up fractions? I hope you understood me. Thanxs. MArcelo
RE: [PHP] How do I convert an array into a mask?
Oooh! I think you're on to something there. Nice! Hey, what's the symbol for? I see in the manual the is a reference (like a pointer in C I assume), but I can't find the explained. if($purchitem[$y] == $x) It'll suppress warnings and errors. If the $purchitem does not have a key 4 or 5, like in your example, then you'll get a warning for undefined offset, depending on your error reporting level. This just suppresses that. If you do it this way, you may want to sort $purchitem if you can't guarantee it's going to be in ascending order. Or you can use in_array() and not care about the order. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] ceil() function
I need a function that rounds up fractions (0.10) not an integer like ceil, or what parameters do I need to give to ceil() to round up fractions? I hope you understood me. Thanxs. Marcelo How about round()? www.php.net/round ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Handling
JWHYou must call session_start before any output to the browser. A blank JWHline or space outside of PHP blocks is considered output. The error JWHmessage tells you exactly where the output started. Read the manual for JWHmore information, it's all covered. Hello, Actually i have started some javascript where its pointing as error..other than that i didn;t leave any line space..Can any one please tell me how to do this.. Regards Uma Okay anything outside of the ? And ? php tags is considered output to the browser. Session_start must be before all of this. In other words, you file should start like this: ? session_start(); //other PHP stuff ? html ... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 4.3.0 and Zend Engine 2
I have read from various sources that Zend Engine 2 will make an appearance in PHP 5.0. It's a pretty significant update, and as such, I doubt it would be smart to implement it in the middle of a major series (4.x). Mind you, it's been a while since I've read anything on ZE2, so things may have changed by now... the PHP powers that be would only be able to give me a definitive answer. -- Aaron Gould [EMAIL PROTECTED] Web Developer Parts Canada - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, November 05, 2002 8:31 PM Subject: [PHP] PHP 4.3.0 and Zend Engine 2 Can anybody tell me if PHP 4.3.0 will use Zend Engine 2? Thanks, matt westgate -- 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] Installation error with 4.2.3
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey, I think your problem has something to do with --enable-mbstr-enc-trans. I remember hearing about problems with that.check the archives(I think it was on PHP-DEV). HTH! ~Paul On Wednesday 06 November 2002 05:04 am, Daniele Baroncelli wrote: No one replied to this message yet. I am trying to address it again, as probably the previuos newsmessage title wasn't very descriptive. Thanks Daniele = Hi guys, I have very weird problem. I have installed the PHP version 4.2.3 on the LINUX virtual server of my web project. Previously I had the PHP version 4.0.6. The error I get is very weird. When I insert a record with the phpMyAdmin, the first 4 characters of each field don't get saved. Same thing happened with some data entry interfaces I coded! The only difference I can see in the two installation (provided the php.ini file is in the same location): The old version 4.0.6 was installed by the server provider and my virtual server space I can only see the .so file. The new version 4.2.3 is actually inside my virtual server space. Hence, the path I provided in the php configuration is different (I don't have idea if this can influence something). NEW VERSION (4.2.3) configuration run by me './configure' '--with-apxs=/usr/local/apache/1.3/bin/apxs' '--prefix=/usr/home/rockit/usr/local' '--with-mysql=/usr/home/rockit/usr/local/mysql' '--with-xml' '--enable-xslt' '--with-xslt-sablot=/usr/home/rockit/usr/local' '--with-regex=system' '--with-expat-dir=/usr/home/rockit/usr/local' '--with-iconv=/usr/home/rockit/usr/local' '--enable-inline-optimization' '--disable-debug' '--enable-memory-limit' '--enable-sigchild' '--without-pear' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-gdbm=/usr/local' '--enable-sockets' '--enable-versioning' '--with-ttf=/usr/local' '--enable-ftp' '--with-gd=/usr/local' '--with-zlib' '--enable-gd-native-ttf' OLD VERSION (4.0.6) configuration run by the server provider './configure' '--enable-inline-optimization' '--with-apxs=/usr/local/apache/1.3/bin/apxs' '--with-config-file-path=/usr/local/lib' '--disable-debug' '--enable-memory-limit' '--enable-sigchild' '--with-gettext' '--without-pear' '--with-regex=system' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-iconv=/usr/local' '--with-gdbm=/usr/local' '--with-dbm=/usr/local' '--enable-sockets' '--enable-versioning' '--with-freetype-dir=/usr/local' '--with-ttf=/usr/local' '--enable-ftp' '--with-curl=/usr/local/curl' '--with-openssl=/usr/local/openssl' '--with-gd=/usr/local' '--with-freetype-dir=/usr/local' '--with-ttf=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-t1lib=/usr/local' '--with-zlib' '--enable-gd-native-ttf' '--with-imap' '--with-mcrypt=/usr/local' '--with-mhash=/usr/local' '--with-dom=/usr/local' '--with-mysql=/usr/local/mysql' '--with-zlib' '--with-zlib' I must admit that I didn't not include all parameter as the old installation, as I didn't know most options and thought is not needed. In the new installation I instead provided additional XML parameter (after installing the correspond modules, which all seem to work fine). Hints on problem are very well welcome! Daniele - -- ~Paul Nicholson Design Specialist @ WebPower Design The webthe way you want it! [EMAIL PROTECTED] It said uses Windows 98 or better, so I loaded Linux! Registered Linux User #183202 using Register Linux System # 81891 -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9yRVvDyXNIUN3+UQRAmRaAJ4+XnqM9eIkG2XKeXI3Pam3emXl7wCfUmnH sXth4YcEhlJJ5LiZOTdFNA8= =kkzH -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Installation error with 4.2.3
Are you aware of register_globals = off? It might be the problem. You can set register_globals = on in php.ini or you better use $_POST, $_GET, $_SERVER ... eg. $fname - $_POST[finame] or $_GET[fname] Daniele Baroncelli [EMAIL PROTECTED] wrote in message news:20021106100419.63359.qmail;pb1.pair.com... No one replied to this message yet. I am trying to address it again, as probably the previuos newsmessage title wasn't very descriptive. Thanks Daniele = Hi guys, I have very weird problem. I have installed the PHP version 4.2.3 on the LINUX virtual server of my web project. Previously I had the PHP version 4.0.6. The error I get is very weird. When I insert a record with the phpMyAdmin, the first 4 characters of each field don't get saved. Same thing happened with some data entry interfaces I coded! The only difference I can see in the two installation (provided the php.ini file is in the same location): The old version 4.0.6 was installed by the server provider and my virtual server space I can only see the .so file. The new version 4.2.3 is actually inside my virtual server space. Hence, the path I provided in the php configuration is different (I don't have idea if this can influence something). NEW VERSION (4.2.3) configuration run by me './configure' '--with-apxs=/usr/local/apache/1.3/bin/apxs' '--prefix=/usr/home/rockit/usr/local' '--with-mysql=/usr/home/rockit/usr/local/mysql' '--with-xml' '--enable-xslt' '--with-xslt-sablot=/usr/home/rockit/usr/local' '--with-regex=system' '--with-expat-dir=/usr/home/rockit/usr/local' '--with-iconv=/usr/home/rockit/usr/local' '--enable-inline-optimization' '--disable-debug' '--enable-memory-limit' '--enable-sigchild' '--without-pear' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-gdbm=/usr/local' '--enable-sockets' '--enable-versioning' '--with-ttf=/usr/local' '--enable-ftp' '--with-gd=/usr/local' '--with-zlib' '--enable-gd-native-ttf' OLD VERSION (4.0.6) configuration run by the server provider './configure' '--enable-inline-optimization' '--with-apxs=/usr/local/apache/1.3/bin/apxs' '--with-config-file-path=/usr/local/lib' '--disable-debug' '--enable-memory-limit' '--enable-sigchild' '--with-gettext' '--without-pear' '--with-regex=system' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-iconv=/usr/local' '--with-gdbm=/usr/local' '--with-dbm=/usr/local' '--enable-sockets' '--enable-versioning' '--with-freetype-dir=/usr/local' '--with-ttf=/usr/local' '--enable-ftp' '--with-curl=/usr/local/curl' '--with-openssl=/usr/local/openssl' '--with-gd=/usr/local' '--with-freetype-dir=/usr/local' '--with-ttf=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-t1lib=/usr/local' '--with-zlib' '--enable-gd-native-ttf' '--with-imap' '--with-mcrypt=/usr/local' '--with-mhash=/usr/local' '--with-dom=/usr/local' '--with-mysql=/usr/local/mysql' '--with-zlib' '--with-zlib' I must admit that I didn't not include all parameter as the old installation, as I didn't know most options and thought is not needed. In the new installation I instead provided additional XML parameter (after installing the correspond modules, which all seem to work fine). Hints on problem are very well welcome! Daniele -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php4.2.2 remembers last GET and POST vars inHTTP_SESSION_VARS also
but in the php.ini i have register_globals = on PHP 4.2.* has register_globals = off as a default. You variables has to be $_POST[fname] or $_POST[fname] or $_SERVER[PHP_SELF] etc., or you can simple incides one file eg. //extract.php ? extract($_SERVER); extract($_ENV); extract($_GET); extract($_POST); extract($_REQUEST); ? in your old codes... require_once extract.php; Alexander Piavka [EMAIL PROTECTED] wrote in message news:Pine.GSO.4.33.0211061433030.21449-20;indigo... Hi, we have upgraded from php4.0.6 to php4.2.2 The problem is that php4.2.2 remembers last GET and POST vars in HTTP_SESSION_VARS also. This ruins the functionality of many programs we are running. both 4.0.6 and 4.2.2 were configured and compiled with exactly the same parameters and we are using the same php.ini conf (which is attached in the mail) In the features added between 4.0.6 and 4.2.2 we did not notice any changes that make such a change in php behaviour. Please advise how can we fix this behaviour without making changes in the code. Thanks a lot ps. these are configure options for php4.0.6 and php4.2.2 we used. ./configure --prefix=/usr/local/web/progs/php-4.0.6 --with-db3 --with-db --w ith-jpeg-dir -with-tiff-dir \ --with-jpeg-dir --with-png-dir --enable-force-cgi-redirect --enable-discar d-path --with-openssl \ --with-zlib --with-bz2 --enable-ftp --with-gettext --enable-sockets --enab le-shared \ --with-gnu-ld --enable-versioning --enable-static --with-config-file-path= /usr/local/web/apache-php/conf \ --enable-magic-quotes --enable-track-vars --with-apxs=/usr/local/web/apach e-php/bin/apxs \ --with-tsrm-pthreads --enable-yp --with-kerberos --with-imap --with-imap-s sl --without-dmalloc \ --enable-trans-sid --enable-mbstr-enc-trans --enable-mbstring ./configure --prefix=/usr/local/web/progs/php-4.2.2 --with-db3 --with-db -- with-jpeg-dir -with-tiff-dir \ --with-jpeg-dir --with-png-dir --enable-force-cgi-redirect --enable-discar d-path --with-openssl \ --with-zlib --with-bz2 --enable-ftp --with-gettext --enable-sockets --enab le-shared \ --with-gnu-ld --enable-versioning --enable-static --with-config-file-path= /usr/local/web/apache-php/conf \ --enable-magic-quotes --enable-track-vars --with-apxs=/usr/local/web/apach e-php/bin/apxs \ --with-tsrm-pthreads --enable-yp --with-kerberos --with-imap --with-imap-s sl --without-dmalloc \ --enable-trans-sid --enable-mbstr-enc-trans --enable-mbstring -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Piavlo XanderAl BGU CS Lab Evil Admin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] xml
[snip] What the hell is XML anyway? [/snip] Extensible Markup Language, a derivitave of SGML (Standard Generalized Markup Language). You can read all about it at http://www.w3c.org HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Grammar/how toes?
[snip] Where is there a good place to learn How and what the ( ) means and what to put in qoautes Basically the right way to properly code? [/snip] If you want to learn PHP start with http://www.php.net . Also there are many good books on the subject of programming which illustrate many methods of coding. Search http://www.amazon.com for computer programming languages. HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help me learn! with an explanation of these two functions.
On Wednesday 06 November 2002 16:52, Steve Jackson wrote: Ok this is starting to get complex! (For me anyway) This is my function: function get_order_numbers() { $conn = db_connect(); $query = select orders.orderid from orders, email where orders.orderid = email.orderid and email.checked='no'; $result = mysql_query($query) or die(Error: cannot select orderidBR$queryBR.mysql_error()); while( $row = mysql_fetch_array($result)) { extract($row); According to your query it should return a single result (assuming your orderid is unique -- and it should be), and that single result contains a single field called orderid. Use print_r($row) to see exactly what it contains (good for reference and debugging). It doesn't contain a single result. It returns 16 order numbers (which is correct - 8 should be in the table emails with no checked and therefore the query has worked and pulled out 8 from the orders table also). What I want the function to do is say OK where the orderid's match pull out all the address details for each orderid and display what I want displayed accordingly. At the moment I get this array returned by using print_r($row). Array ( [0] = 100040 [orderid] = 100040 ) Array ( [0] = 100041 [orderid] = 100041 ) Array ( [0] = 100043 [orderid] = 100043 ) Array ( [0] = 100044 [orderid] = 100044 ) Array ( [0] = 100046 [orderid] = 100046 ) Array ( [0] = 100050 [orderid] = 100050 ) Array ( [0] = 100051 [orderid] = 100051 ) Array ( [0] = 100052 [orderid] = 100052 ) Where do I go from here? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xml
Just read things here: http://www.phpbeginner.com/ray/xml http://www.vbxml.com/xml/articles/whatisxml/ http://www.zvon.org http://www.xml.com You should learn it if haven't done so yet -- Maxim Maletsky [EMAIL PROTECTED] Jay Blanchard [EMAIL PROTECTED] wrote... : [snip] What the hell is XML anyway? [/snip] Extensible Markup Language, a derivitave of SGML (Standard Generalized Markup Language). You can read all about it at http://www.w3c.org HTH! Jay -- 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] php and electronic pay system
Hello, does anyone have experience with implementation of electronic pay system for website based on PHP? Can you give me directions about this? -- Best regards, Martin Hudec mailto:corwin;corwin.sk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] New to PHP, and stuck
I'm working myself through Julie C. Meloni's book PHP and now I'm stuck at chapter 12. My script gives me this error: You have an error in your SQL syntax near '()' at line 1 even tho I've even tried replacing my own work with the file from the book's companion-files. I'd be very happy if someone would take the time to look through this and tell me what the problem might be. Hard to move forward when I don't understand this. Here's the script: ? //indicate the database you want to use $db_name =testDB; //connect to database $connection = mysql_connect(localhost,john,doe99) or die(mysql_error()); $db = mysql_select_db($db_name,$connection) or die(mysql_error()); //start creating the SQL statement $sql =CREATE TABLE $_POST[table_name] ((; //continue the SQL statement for each new field for ($i =0;$i count($_POST[field_name]);$i++){ $sql .= $_POST[field_name][$i]..$_POST[field_type][$i]; if ($_POST [field_length][$i] != ) { $sql .= (.$_POST [field_length][$i].),; } else { $sql .= ,; } } //clean up the end of the string $sql = substr($sql,0,-1); $sql .= ); //execute the query $result = mysql_query($sql,$connection) or die(mysql_error()); //get a good message for display upon success if ($result) { $msg =P.$_POST[table_name]. has been created!/P; } ? HTML HEAD TITLECreate a Database Table:Step 3/TITLE /HEAD BODY h1Adding table to ? echo $db_name; ?.../h1 ? echo $msg; ? /BODY /HTML -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] New to PHP, and stuck
I am not php expert but why are there two (( after your create table? -Original Message- From: Markus Jäntti [mailto:janmark;bodo.kommune.no] Sent: Wednesday, November 06, 2002 8:34 AM To: [EMAIL PROTECTED] Subject: [PHP] New to PHP, and stuck I'm working myself through Julie C. Meloni's book PHP and now I'm stuck at chapter 12. My script gives me this error: You have an error in your SQL syntax near '()' at line 1 even tho I've even tried replacing my own work with the file from the book's companion-files. I'd be very happy if someone would take the time to look through this and tell me what the problem might be. Hard to move forward when I don't understand this. Here's the script: ? //indicate the database you want to use $db_name =testDB; //connect to database $connection = @mysql_connect(localhost,john,doe99) or die(mysql_error()); $db = @mysql_select_db($db_name,$connection) or die(mysql_error()); //start creating the SQL statement $sql =CREATE TABLE $_POST[table_name] ((; //continue the SQL statement for each new field for ($i =0;$i count($_POST[field_name]);$i++){ $sql .= $_POST[field_name][$i]..$_POST[field_type][$i]; if ($_POST [field_length][$i] != ) { $sql .= (.$_POST [field_length][$i].),; } else { $sql .= ,; } } //clean up the end of the string $sql = substr($sql,0,-1); $sql .= ); //execute the query $result = mysql_query($sql,$connection) or die(mysql_error()); //get a good message for display upon success if ($result) { $msg =P.$_POST[table_name]. has been created!/P; } ? HTML HEAD TITLECreate a Database Table:Step 3/TITLE /HEAD BODY h1Adding table to ? echo $db_name; ?.../h1 ? echo $msg; ? /BODY /HTML -- 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] undefined symbol: curl-global-init
At 13:39 06.11.2002, Marek Kilimajer said: [snip] Do you have libcurl intaled? Ernest E Vogelsinger wrote: Hi list, maybe someone has a simple answer to this: I am running Apache 1.3.22 with libphp4.so. Everything's fine, but when starting php from the command line I get: php: relocation error: php: undefined symbol: curl-global-init Any idea what I should try? [snip] Yes, I have (located in /usr/lib). With the apache module, as I said, PHP works, even curl calls. I'm not really a Linux guru, but I found that /usr/lib is nowhere mentioned in the environment (# env). Shouldn't this? -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: New to PHP, and stuck
Markus JäNtti wrote: I'm working myself through Julie C. Meloni's book PHP and now I'm stuck at chapter 12. My script gives me this error: You have an error in your SQL syntax near '()' at line 1 even tho I've even tried replacing my own work with the file from the book's companion-files. I'd be very happy if someone would take the time to look through this and tell me what the problem might be. Hard to move forward when I don't understand this. The $_POST array exists of keys and values. The keys are strings (in the case of $_POST), so you'll have to access them like strings. Use $_POST['table_name'] instead of $_POST[table_name]. The same goed also for $_POST[field_name], $_POST[field_type] and $_POST[field_length]. HTH Erwin ? //indicate the database you want to use $db_name =testDB; //connect to database $connection = mysql_connect(localhost,john,doe99) or die(mysql_error()); $db = mysql_select_db($db_name,$connection) or die(mysql_error()); //start creating the SQL statement $sql =CREATE TABLE $_POST[table_name] ((; //continue the SQL statement for each new field for ($i =0;$i count($_POST[field_name]);$i++){ $sql .= $_POST[field_name][$i]..$_POST[field_type][$i]; if ($_POST [field_length][$i] != ) { $sql .= (.$_POST [field_length][$i].),; } else { $sql .= ,; } } //clean up the end of the string $sql = substr($sql,0,-1); $sql .= ); //execute the query $result = mysql_query($sql,$connection) or die(mysql_error()); //get a good message for display upon success if ($result) { $msg =P.$_POST[table_name]. has been created!/P; } ? HTML HEAD TITLECreate a Database Table:Step 3/TITLE /HEAD BODY h1Adding table to ? echo $db_name; ?.../h1 ? echo $msg; ? /BODY /HTML -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] New to PHP, and stuck
ok, nevermind, I think I see why... -Original Message- From: Edward Peloke [mailto:epeloke;echoman.com] Sent: Wednesday, November 06, 2002 9:20 AM To: Markus Jäntti; [EMAIL PROTECTED] Subject: RE: [PHP] New to PHP, and stuck I am not php expert but why are there two (( after your create table? -Original Message- From: Markus Jäntti [mailto:janmark;bodo.kommune.no] Sent: Wednesday, November 06, 2002 8:34 AM To: [EMAIL PROTECTED] Subject: [PHP] New to PHP, and stuck I'm working myself through Julie C. Meloni's book PHP and now I'm stuck at chapter 12. My script gives me this error: You have an error in your SQL syntax near '()' at line 1 even tho I've even tried replacing my own work with the file from the book's companion-files. I'd be very happy if someone would take the time to look through this and tell me what the problem might be. Hard to move forward when I don't understand this. Here's the script: ? //indicate the database you want to use $db_name =testDB; //connect to database $connection = @mysql_connect(localhost,john,doe99) or die(mysql_error()); $db = @mysql_select_db($db_name,$connection) or die(mysql_error()); //start creating the SQL statement $sql =CREATE TABLE $_POST[table_name] ((; //continue the SQL statement for each new field for ($i =0;$i count($_POST[field_name]);$i++){ $sql .= $_POST[field_name][$i]..$_POST[field_type][$i]; if ($_POST [field_length][$i] != ) { $sql .= (.$_POST [field_length][$i].),; } else { $sql .= ,; } } //clean up the end of the string $sql = substr($sql,0,-1); $sql .= ); //execute the query $result = mysql_query($sql,$connection) or die(mysql_error()); //get a good message for display upon success if ($result) { $msg =P.$_POST[table_name]. has been created!/P; } ? HTML HEAD TITLECreate a Database Table:Step 3/TITLE /HEAD BODY h1Adding table to ? echo $db_name; ?.../h1 ? echo $msg; ? /BODY /HTML -- 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] New to PHP, and stuck
The first thing I do when confronted with this kind of problem is to print out the sql statement and carefully look through it. So if you have not done this yet, comment out the $result = statement. Above that add an echo $sql; Now look through the sql statement and make sure all fields are there and there is no syntax problem with your query, this is most likley the case. If you are using mysql I would recommend downloading phpMyAdmin which is a php GUI interface to mysql, once this is running, you can simply cut and paste the sql statement into the phpMyAdmin query box and try to run it from there, it will tell you where your syntax is wrong. HTH, Steve Bradwell MIS Department. If you give someone a program, you will frustrate them for a day. If you teach them how to program, you will frustrate them for a lifetime. -Original Message- From: Markus Jäntti [mailto:janmark;bodo.kommune.no] Sent: Wednesday, November 06, 2002 8:34 AM To: [EMAIL PROTECTED] Subject: [PHP] New to PHP, and stuck I'm working myself through Julie C. Meloni's book PHP and now I'm stuck at chapter 12. My script gives me this error: You have an error in your SQL syntax near '()' at line 1 even tho I've even tried replacing my own work with the file from the book's companion-files. I'd be very happy if someone would take the time to look through this and tell me what the problem might be. Hard to move forward when I don't understand this. Here's the script: ? //indicate the database you want to use $db_name =testDB; //connect to database $connection = @mysql_connect(localhost,john,doe99) or die(mysql_error()); $db = @mysql_select_db($db_name,$connection) or die(mysql_error()); //start creating the SQL statement $sql =CREATE TABLE $_POST[table_name] ((; //continue the SQL statement for each new field for ($i =0;$i count($_POST[field_name]);$i++){ $sql .= $_POST[field_name][$i]..$_POST[field_type][$i]; if ($_POST [field_length][$i] != ) { $sql .= (.$_POST [field_length][$i].),; } else { $sql .= ,; } } //clean up the end of the string $sql = substr($sql,0,-1); $sql .= ); //execute the query $result = mysql_query($sql,$connection) or die(mysql_error()); //get a good message for display upon success if ($result) { $msg =P.$_POST[table_name]. has been created!/P; } ? HTML HEAD TITLECreate a Database Table:Step 3/TITLE /HEAD BODY h1Adding table to ? echo $db_name; ?.../h1 ? echo $msg; ? /BODY /HTML -- 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] New to PHP, and stuck
Also, you should echo out $sql so you can see what is actually created. It will probably be obvious what the error is. ---John Holmes... - Original Message - From: Edward Peloke [EMAIL PROTECTED] To: Markus Jäntti [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 9:19 AM Subject: RE: [PHP] New to PHP, and stuck I am not php expert but why are there two (( after your create table? -Original Message- From: Markus Jäntti [mailto:janmark;bodo.kommune.no] Sent: Wednesday, November 06, 2002 8:34 AM To: [EMAIL PROTECTED] Subject: [PHP] New to PHP, and stuck I'm working myself through Julie C. Meloni's book PHP and now I'm stuck at chapter 12. My script gives me this error: You have an error in your SQL syntax near '()' at line 1 even tho I've even tried replacing my own work with the file from the book's companion-files. I'd be very happy if someone would take the time to look through this and tell me what the problem might be. Hard to move forward when I don't understand this. Here's the script: ? //indicate the database you want to use $db_name =testDB; //connect to database $connection = @mysql_connect(localhost,john,doe99) or die(mysql_error()); $db = @mysql_select_db($db_name,$connection) or die(mysql_error()); //start creating the SQL statement $sql =CREATE TABLE $_POST[table_name] ((; //continue the SQL statement for each new field for ($i =0;$i count($_POST[field_name]);$i++){ $sql .= $_POST[field_name][$i]..$_POST[field_type][$i]; if ($_POST [field_length][$i] != ) { $sql .= (.$_POST [field_length][$i].),; } else { $sql .= ,; } } //clean up the end of the string $sql = substr($sql,0,-1); $sql .= ); //execute the query $result = mysql_query($sql,$connection) or die(mysql_error()); //get a good message for display upon success if ($result) { $msg =P.$_POST[table_name]. has been created!/P; } ? HTML HEAD TITLECreate a Database Table:Step 3/TITLE /HEAD BODY h1Adding table to ? echo $db_name; ?.../h1 ? echo $msg; ? /BODY /HTML -- 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] session vs. header
I think I have to re-explain the problem completely. I want to use this script in a login form. Once, someone is authenticated, then I register variables for indentifying him/her through session. After I register those variables I want to redirect him/her to a page, which required authenticated users (and it's done by registering variables through session). Due to this, I decide to use header: location. Futhermore, I use IE 5.5, Apache 1.3.26, PHP 4.2.1 [, MySQL 3.23.51] which running on Windows ME. Here is the script (register globals is off, due to security and default setting in php.ini). ?php $user = $_POST['user']; $user = $_POST['password']; if (authenticate($user)) { session_start(); $_SESSION['user'] = $user; $_SESSION['password'] = $password; header('Location: http://www.mysite.com/member.php'); exit(); } else { header('Location: http://www.mysite.com/login.php'); exit(); } ? When I try this code with an authenticated user, it seemed browser don't redirect to the page I specify above. The progress bar looked like searching something then it led to an error. I don't know why this could happen. Am I missing something? Thank you. huge junk mail [EMAIL PROTECTED] wrote:Can someone tell me why I can't have $_SESSION['foo'] = 'content of foo'; following by header('Location: http://www.mysite.com'); Someone from www.php.net told me that it can confuse browser (http://bugs.php.net/19991). But, still I can't the idea why it can happen. Does register session means sending a 'header: location' too? Thanks. = Regards, mahara __ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Regards, mahara - Do you Yahoo!? HotJobs - Search new jobs daily now
RE: [PHP] How do I convert an array into a mask?
At 13:43 06.11.2002, Daevid Vincent said: [snip] Ernest, close but you have it reversed for my needs (i.e. true binary form). Notice that my LSB is to the left, not right. Ah, ic, you want a string like 1100101 - that's easy :) Note that I do _not_ pass the array by reference here since I modify it (using asort). function make_a_special_bitlike_string($array) { $result = ''; sort($array, SORT_NUMERIC); $max = $array[count($array)-1]; for ($i = 1; $i = $max; ++$i) { if (in_array($i, $array)) $result .= '1'; else $result .= '0'; } return $result; } if you need this as a number, simply return (int)$result, but beware that this breaks if there are more than 32 digits (highest value 32). -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php and electronic pay system
At 14:50 06.11.2002, Martin Hudec said: [snip] Hello, does anyone have experience with implementation of electronic pay system for website based on PHP? Can you give me directions about this? [snip] Usually these sites have an interface based on SSL to POST data to, optionally calling back any URL you submit (at least FirePay works this way). You might consider using curl to SSL-post data to the CC aquirer. Most clearing houses are offering prefab PHP solutions, with and/or without a little shop solution. Try to check the docs with your aquirer. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP, and stuck
At 14:34 06.11.2002, Markus Jäntti said: [snip] $sql =CREATE TABLE $_POST[table_name] ((; [snip] If you are including an array expression within a string, you should enclose it in curly braces, like this: $sql =CREATE TABLE {$_POST[table_name]} ((; -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php4.2.2 remembers last GET and POST vars in HTTP_SESSION_VARS also
Hi, we have upgraded from php4.0.6 to php4.2.2 The problem is that php4.2.2 remembers last GET and POST vars in HTTP_SESSION_VARS also. This ruins the functionality of many programs we are running. both 4.0.6 and 4.2.2 were configured and compiled with exactly the same parameters and we are using the same php.ini conf (which is attached in the mail) In the features added between 4.0.6 and 4.2.2 we did not notice any changes that make such a change in php behaviour. Please advise how can we fix this behaviour without making changes in the code. Thanks a lot ps. these are configure options for php4.0.6 and php4.2.2 we used. ./configure --prefix=/usr/local/web/progs/php-4.0.6 --with-db3 --with-db --with-jpeg-dir -with-tiff-dir \ --with-jpeg-dir --with-png-dir --enable-force-cgi-redirect --enable-discard-path --with-openssl \ --with-zlib --with-bz2 --enable-ftp --with-gettext --enable-sockets --enable-shared \ --with-gnu-ld --enable-versioning --enable-static --with-config-file-path=/usr/local/web/apache-php/conf \ --enable-magic-quotes --enable-track-vars --with-apxs=/usr/local/web/apache-php/bin/apxs \ --with-tsrm-pthreads --enable-yp --with-kerberos --with-imap --with-imap-ssl --without-dmalloc \ --enable-trans-sid --enable-mbstr-enc-trans --enable-mbstring ./configure --prefix=/usr/local/web/progs/php-4.2.2 --with-db3 --with-db --with-jpeg-dir -with-tiff-dir \ --with-jpeg-dir --with-png-dir --enable-force-cgi-redirect --enable-discard-path --with-openssl \ --with-zlib --with-bz2 --enable-ftp --with-gettext --enable-sockets --enable-shared \ --with-gnu-ld --enable-versioning --enable-static --with-config-file-path=/usr/local/web/apache-php/conf \ --enable-magic-quotes --enable-track-vars --with-apxs=/usr/local/web/apache-php/bin/apxs \ --with-tsrm-pthreads --enable-yp --with-kerberos --with-imap --with-imap-ssl --without-dmalloc \ --enable-trans-sid --enable-mbstr-enc-trans --enable-mbstring [PHP] ; Language Options ; ; Enable the PHP scripting language engine under Apache. engine = On ; Allow the ? tag. Otherwise, only ?php and script tags are recognized. short_open_tag = On ; Allow ASP-style % % tags. asp_tags = On ; The number of significant digits displayed in floating point numbers. precision= 14 ; Enforce year 2000 compliance (will cause problems with non-compliant browsers) y2k_compliance = Off ; Output buffering allows you to send header lines (including cookies) even ; after you send body content, at the price of slowing PHP's output layer a ; bit. You can enable output buffering during runtime by calling the output ; buffering functions. You can also enable output buffering for all files by ; setting this directive to On. output_buffering = Off ; You can redirect all of the output of your scripts to a function. For ; example, if you set output_handler to ob_gzhandler, output will be ; transparently compressed for browsers that support gzip or deflate encoding. ; Setting an output handler automatically turns on output buffering. output_handler = ; Transparent output compression using the zlib library ; Valid values for this option are 'off', 'on', or a specific buffer size ; to be used for compression (default is 4KB) zlib.output_compression = Off ; Implicit flush tells PHP to tell the output layer to flush itself ; automatically after every output block. This is equivalent to calling the ; PHP function flush() after each and every call to print() or echo() and each ; and every HTML block. Turning this option on has serious performance ; implications and is generally recommended for debugging purposes only. implicit_flush = Off ; Whether to enable the ability to force arguments to be passed by reference ; at function call time. This method is deprecated and is likely to be ; unsupported in future versions of PHP/Zend. The encouraged method of ; specifying which arguments should be passed by reference is in the function ; declaration. You're encouraged to try and turn this option Off and make ; sure your scripts work properly with it in order to ensure they will work ; with future versions of the language (you will receive a warning each time ; you use this feature, and the argument will be passed by value instead of by ; reference). allow_call_time_pass_reference = Off ; ; Safe Mode ; safe_mode = Off safe_mode_exec_dir = ; Setting certain environment variables may be a potential security breach. ; This directive contains a comma-delimited list of prefixes. In Safe Mode, ; the user may only alter environment variables whose names begin with the ; prefixes supplied here. By default, users will only be able to set ; environment variables that begin with PHP_ (e.g. PHP_FOO=BAR). ; ; Note: If this directive is empty, PHP will let the user modify ANY ; environment variable! safe_mode_allowed_env_vars = PHP_ ; This directive contains a
[PHP] Re: php4.2.2 remembers last GET and POST vars in HTTP_SESSION_VARS also
PHP 4.2.* has register_globals = off as a default. You variables has to be $_POST[fname] or $_POST[fname] or $_SERVER[PHP_SELF] etc., or you can simple incides one file eg. //extract.php ? extract($_SERVER); extract($_ENV); extract($_GET); extract($_POST); extract($_REQUEST); ? in your old codes... require_once extract.php; Alexander Piavka [EMAIL PROTECTED] wrote in message news:Pine.GSO.4.33.0211061433030.21449-20;indigo... Hi, we have upgraded from php4.0.6 to php4.2.2 The problem is that php4.2.2 remembers last GET and POST vars in HTTP_SESSION_VARS also. This ruins the functionality of many programs we are running. both 4.0.6 and 4.2.2 were configured and compiled with exactly the same parameters and we are using the same php.ini conf (which is attached in the mail) In the features added between 4.0.6 and 4.2.2 we did not notice any changes that make such a change in php behaviour. Please advise how can we fix this behaviour without making changes in the code. Thanks a lot ps. these are configure options for php4.0.6 and php4.2.2 we used. ./configure --prefix=/usr/local/web/progs/php-4.0.6 --with-db3 --with-db --w ith-jpeg-dir -with-tiff-dir \ --with-jpeg-dir --with-png-dir --enable-force-cgi-redirect --enable-discar d-path --with-openssl \ --with-zlib --with-bz2 --enable-ftp --with-gettext --enable-sockets --enab le-shared \ --with-gnu-ld --enable-versioning --enable-static --with-config-file-path= /usr/local/web/apache-php/conf \ --enable-magic-quotes --enable-track-vars --with-apxs=/usr/local/web/apach e-php/bin/apxs \ --with-tsrm-pthreads --enable-yp --with-kerberos --with-imap --with-imap-s sl --without-dmalloc \ --enable-trans-sid --enable-mbstr-enc-trans --enable-mbstring ./configure --prefix=/usr/local/web/progs/php-4.2.2 --with-db3 --with-db -- with-jpeg-dir -with-tiff-dir \ --with-jpeg-dir --with-png-dir --enable-force-cgi-redirect --enable-discar d-path --with-openssl \ --with-zlib --with-bz2 --enable-ftp --with-gettext --enable-sockets --enab le-shared \ --with-gnu-ld --enable-versioning --enable-static --with-config-file-path= /usr/local/web/apache-php/conf \ --enable-magic-quotes --enable-track-vars --with-apxs=/usr/local/web/apach e-php/bin/apxs \ --with-tsrm-pthreads --enable-yp --with-kerberos --with-imap --with-imap-s sl --without-dmalloc \ --enable-trans-sid --enable-mbstr-enc-trans --enable-mbstring -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined symbol: curl-global-init
Ernest E Vogelsinger wrote: At 13:39 06.11.2002, Marek Kilimajer said: [snip] Do you have libcurl intaled? Ernest E Vogelsinger wrote: Hi list, maybe someone has a simple answer to this: I am running Apache 1.3.22 with libphp4.so. Everything's fine, but when starting php from the command line I get: php: relocation error: php: undefined symbol: curl-global-init Any idea what I should try? [snip] Yes, I have (located in /usr/lib). With the apache module, as I said, PHP works, even curl calls. I'm not really a Linux guru, but I found that /usr/lib is nowhere mentioned in the environment (# env). Shouldn't this? No, this is not neccessery. Maybe you don't have the right version. Where did you get apache and php rpms? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I convert an array into a mask?
Hi, Wednesday, November 6, 2002, 2:56:33 PM, you wrote: DV Does anyone know of a nice efficient way to convert an array of values DV into a mask... DV Here's the deal. Given an array such that: DV $purchitem[0] = 1; DV $purchitem[1] = 3; DV $purchitem[2] = 4; DV I want to end up with a variable like this: DV $mask = 10110; DV Additionally, my theory is that then the person purchases another book DV later DV $purchitem[0] = 2; DV My new mask should be $purchmask = 01000; DV Then I can load their previous mask from the database and boolean OR it DV with the new mask to set the correct permissions. i.e. DV $newmask = $mask | $purchmask; DV Or ideally = 0 DV Can I boolean OR strings like that in the way I 'hope' it will work? Do DV I need to convert it to an intermediate stage or cast it or anything? DV Does this make sense? It's for an online book shopping cart. I have the DV reverse working, where I can split the mask into what books. And I also DV have the $purchitem[] working. This should do it: $purchitem[0] = 1; $purchitem[1] = 3; $purchitem[2] = 4; $s = '0'; while(list($key,$val) = each($purchitem)){ $s[$val-1] = '1'; } echo s = $s br; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I convert an array into a mask?
-Original Message- From: Daevid Vincent [mailto:daevid;daevid.com] Sent: 06 November 2002 12:23 To: [EMAIL PROTECTED] That's the EASY part John! The hard part is converting the array (which was a checkbox array from a form submission) into the binary string (as per the original post) Here's the deal. Given an array such that: $purchitem[0] = 1; //purchased book #1 checkbox enabled $purchitem[1] = 3; //purchased book #3 checkbox enabled $purchitem[2] = 4; //purchased book #4 checkbox enabled I want to end up with a variable like this: $mask = 10110; Get it now? ;-) Nah, that's dead easy: $mask = str_repeat(0, number_of_books_to_be_tracked); foreach($purchitem as $book_no): $mask{$book_no} = 1; endforeach; Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined symbol: curl-global-init
Where does ldd libphp4.so point to? Ernest E Vogelsinger wrote: At 15:41 06.11.2002, Marek Kilimajer spoke out and said: [snip] Yes, I have (located in /usr/lib). With the apache module, as I said, PHP works, even curl calls. I'm not really a Linux guru, but I found that /usr/lib is nowhere mentioned in the environment (# env). Shouldn't this? No, this is not neccessery. Maybe you don't have the right version. Where did you get apache and php rpms? [snip] Both apache and php are compiled from the tarballs since RedHat doesn't provide rpms with the latest versions. server-version sez: Apache/1.3.22 (Unix) (Red-Hat/Linux) mod_ssl/2.8.5 OpenSSL/0.9.6b DAV/1.0.2 PHP/4.2.2 mod_perl/1.26 # ls -al /usr/lib/libcurl* -rw-r--r-- 1 root root 196084 Jun 20 08:28 /usr/lib/libcurl.a -rwxr-xr-x 1 root root719 Jun 20 08:28 /usr/lib/libcurl.la lrwxrwxrwx 1 root root 16 Aug 4 19:47 /usr/lib/libcurl.so - libcurl.so.2.0.2 -rw-rw-r-- 1 root root 95928 Aug 4 18:54 /usr/lib/libcurl.so.1 lrwxrwxrwx 1 root root 16 Aug 4 19:47 /usr/lib/libcurl.so.2 - libcurl.so.2.0.2 -rwxr-xr-x 1 root root 152214 Jun 20 08:28 /usr/lib/libcurl.so.2.0.2 grep curl_global_init /usr/lib/libcurl* returns: Binary file /usr/lib/libcurl.a matches Binary file /usr/lib/libcurl.so matches Binary file /usr/lib/libcurl.so.2 matches Binary file /usr/lib/libcurl.so.2.0.2 matches Any idea? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined symbol: curl-global-init
At 16:25 06.11.2002, Marek Kilimajer spoke out and said: [snip] Where does ldd libphp4.so point to? [snip] Oops: # ldd libphp4.so ldd: ./libphp4.so: No such file or directory I found libphp4.so in /etc/httpd/modules (the correct path for apache extensions on RedHat), and in /usr/lib/apache (from the default compile). -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/
Re: [PHP] session vs. header
What I've done : 1. Allow the user to login 2. Use the login.php page as its own 'form action' 3. Let the login form decide when to redirect the user to the 'destination' page. 4. force the destination page (welcome.php) to do additional authentication checking by comparing the users input to some other piece of information (session variable, cookie, database info, etc...) Pseudo code for login page ? php if $user_input = something || $more_user_info=somethingelse { header ('Location: http://www.mysite.com/welcome.php'); } ? HTML what ever the login page looks like /html Pseudo code for welcome.php: ? php if $user_input != something || $more_user_info!=somethingelse { header ('Location: http://www.mysite.com/login.php'); } ? HTML what ever the welcome page looks like /html -Original Message- From: huge junk mail [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, November 06, 2002 9:03 AM Subject: Re: [PHP] session vs. header I think I have to re-explain the problem completely. I want to use this script in a login form. Once, someone is authenticated, then I register variables for indentifying him/her through session. After I register those variables I want to redirect him/her to a page, which required authenticated users (and it's done by registering variables through session). Due to this, I decide to use header: location. Futhermore, I use IE 5.5, Apache 1.3.26, PHP 4.2.1 [, MySQL 3.23.51] which running on Windows ME. Here is the script (register globals is off, due to security and default setting in php.ini). ?php $user = $_POST['user']; $user = $_POST['password']; if (authenticate($user)) { session_start(); $_SESSION['user'] = $user; $_SESSION['password'] = $password; header('Location: http://www.mysite.com/member.php'); exit(); } else { header('Location: http://www.mysite.com/login.php'); exit(); } ? When I try this code with an authenticated user, it seemed browser don't redirect to the page I specify above. The progress bar looked like searching something then it led to an error. I don't know why this could happen. Am I missing something? Thank you. huge junk mail [EMAIL PROTECTED] wrote:Can someone tell me why I can't have $_SESSION['foo'] = 'content of foo'; following by header('Location: http://www.mysite.com'); Someone from www.php.net told me that it can confuse browser (http://bugs.php.net/19991). But, still I can't the idea why it can happen. Does register session means sending a 'header: location' too? Thanks. = Regards, mahara __ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Regards, mahara - Do you Yahoo!? HotJobs - Search new jobs daily now -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined symbol: curl-global-init
At 16:25 06.11.2002, Marek Kilimajer spoke out and said: [snip] Where does ldd libphp4.so point to? [snip] Been too fast when hitting the reply button... # ldd /etc/http/modules/libphp4.so libdl.so.2 = /lib/libdl.so.2 (0x40153000) libpam.so.0 = /lib/libpam.so.0 (0x40157000) libexpat.so.0 = /usr/lib/libexpat.so.0 (0x4015f000) libmm.so.11 = /usr/lib/libmm.so.11 (0x4017c000) libgmp.so.3 = /usr/lib/libgmp.so.3 (0x40181000) libgd.so.1.8 = /usr/lib/libgd.so.1.8 (0x401a3000) libfreetype.so.6 = /usr/lib/libfreetype.so.6 (0x401d5000) libjpeg.so.62 = /usr/lib/libjpeg.so.62 (0x40209000) libz.so.1 = /usr/lib/libz.so.1 (0x40228000) libm.so.6 = /lib/i686/libm.so.6 (0x40236000) libxml2.so.2 = /usr/lib/libxml2.so.2 (0x40259000) libgdbm.so.2 = /usr/lib/libgdbm.so.2 (0x402fe000) libcrypto.so.2 = /lib/libcrypto.so.2 (0x40305000) libssl.so.2 = /lib/libssl.so.2 (0x403c9000) libcurl.so.2 = /usr/lib/libcurl.so.2 (0x403f6000) libbz2.so.1 = /usr/lib/libbz2.so.1 (0x40418000) libcrypt.so.1 = /lib/libcrypt.so.1 (0x40428000) libresolv.so.2 = /lib/libresolv.so.2 (0x40456000) libnsl.so.1 = /lib/libnsl.so.1 (0x40468000) libc.so.6 = /lib/i686/libc.so.6 (0x4047e000) libpng.so.2 = /usr/lib/libpng.so.2 (0x405ba000) /lib/ld-linux.so.2 = /lib/ld-linux.so.2 (0x8000) BUT ]# ldd /usr/bin/php libpam.so.0 = /lib/libpam.so.0 (0x40028000) libssl.so.2 = /lib/libssl.so.2 (0x4003) libcrypto.so.2 = /lib/libcrypto.so.2 (0x4005d000) libdl.so.2 = /lib/libdl.so.2 (0x40121000) libz.so.1 = /usr/lib/libz.so.1 (0x40125000) libresolv.so.2 = /lib/libresolv.so.2 (0x40133000) libexpat.so.0 = /usr/lib/libexpat.so.0 (0x40146000) libmm.so.11 = /usr/lib/libmm.so.11 (0x40163000) libpspell.so.4 = /usr/lib/libpspell.so.4 (0x40168000) libltdl.so.3 = /usr/lib/libltdl.so.3 (0x40182000) libpspell-modules.so.1 = /usr/lib/libpspell-modules.so.1 (0x40188000) libstdc++-libc6.2-2.so.3 = /usr/lib/libstdc++-libc6.2-2.so.3 (0x4018a000) libc.so.6 = /lib/i686/libc.so.6 (0x401cd000) libgmp.so.3 = /usr/lib/libgmp.so.3 (0x40309000) libgd.so.1.8 = /usr/lib/libgd.so.1.8 (0x4032a000) libxml2.so.2 = /usr/lib/libxml2.so.2 (0x4035c000) libdb-3.2.so = /lib/libdb-3.2.so (0x4040) libgdbm.so.2 = /usr/lib/libgdbm.so.2 (0x404a7000) libcurl.so.1 = /usr/lib/libcurl.so.1 (0x404af000) libbz2.so.1 = /usr/lib/libbz2.so.1 (0x404c9000) libcrypt.so.1 = /lib/libcrypt.so.1 (0x404d9000) libttf.so.2 = /usr/lib/libttf.so.2 (0x40506000) libm.so.6 = /lib/i686/libm.so.6 (0x4053) libfreetype.so.6 = /usr/lib/libfreetype.so.6 (0x40553000) libpng.so.2 = /usr/lib/libpng.so.2 (0x40588000) libjpeg.so.62 = /usr/lib/libjpeg.so.62 (0x405aa000) libnsl.so.1 = /lib/libnsl.so.1 (0x405c9000) libgssapi_krb5.so.2 = /usr/kerberos/lib/libgssapi_krb5.so.2 (0x405df000) libkrb5.so.3 = /usr/kerberos/lib/libkrb5.so.3 (0x405f2000) libk5crypto.so.3 = /usr/kerberos/lib/libk5crypto.so.3 (0x4064a000) libcom_err.so.3 = /usr/kerberos/lib/libcom_err.so.3 (0x4065c000) /lib/ld-linux.so.2 = /lib/ld-linux.so.2 (0x4000) libssl.so.0 = /usr/lib/libssl.so.0 (0x4065f000) libcrypto.so.0 = /usr/lib/libcrypto.so.0 (0x4068c000) -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/
Re: [PHP] session vs. header
I believe the php code gets executed before html code is processed. -Original Message- From: dwalker [EMAIL PROTECTED] To: huge junk mail [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, November 06, 2002 10:44 AM Subject: Re: [PHP] session vs. header What I've done : 1. Allow the user to login 2. Use the login.php page as its own 'form action' 3. Let the login form decide when to redirect the user to the 'destination' page. 4. force the destination page (welcome.php) to do additional authentication checking by comparing the users input to some other piece of information (session variable, cookie, database info, etc...) Pseudo code for login page ? php if $user_input = something || $more_user_info=somethingelse { header ('Location: http://www.mysite.com/welcome.php'); } ? HTML what ever the login page looks like /html Pseudo code for welcome.php: ? php if $user_input != something || $more_user_info!=somethingelse { header ('Location: http://www.mysite.com/login.php'); } ? HTML what ever the welcome page looks like /html -Original Message- From: huge junk mail [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, November 06, 2002 9:03 AM Subject: Re: [PHP] session vs. header I think I have to re-explain the problem completely. I want to use this script in a login form. Once, someone is authenticated, then I register variables for indentifying him/her through session. After I register those variables I want to redirect him/her to a page, which required authenticated users (and it's done by registering variables through session). Due to this, I decide to use header: location. Futhermore, I use IE 5.5, Apache 1.3.26, PHP 4.2.1 [, MySQL 3.23.51] which running on Windows ME. Here is the script (register globals is off, due to security and default setting in php.ini). ?php $user = $_POST['user']; $user = $_POST['password']; if (authenticate($user)) { session_start(); $_SESSION['user'] = $user; $_SESSION['password'] = $password; header('Location: http://www.mysite.com/member.php'); exit(); } else { header('Location: http://www.mysite.com/login.php'); exit(); } ? When I try this code with an authenticated user, it seemed browser don't redirect to the page I specify above. The progress bar looked like searching something then it led to an error. I don't know why this could happen. Am I missing something? Thank you. huge junk mail [EMAIL PROTECTED] wrote:Can someone tell me why I can't have $_SESSION['foo'] = 'content of foo'; following by header('Location: http://www.mysite.com'); Someone from www.php.net told me that it can confuse browser (http://bugs.php.net/19991). But, still I can't the idea why it can happen. Does register session means sending a 'header: location' too? Thanks. = Regards, mahara __ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Regards, mahara - Do you Yahoo!? HotJobs - Search new jobs daily now -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript and PHP
Hi, Wednesday, November 6, 2002, 2:52:31 AM, you wrote: vaue Hi. I'm not sure if is here where i have to ask this, but, if it's vaue not i hope you say to me :D. vaue Well the question is: i want to know how can i make to insert into vaue the $_GET or $_POST arrays, an entry with a value from javascript. vaue Thanks This is a post method: script language=JavaScript function doit(){ testval = Hello; document.form1.result.value = testval; document.form1.submit(); } /script form name=form1 action=?echo $_SERVER['PHP_SELF']? method=post input type=hidden name=result input type=button value=Submit onclick=doit(); /form should end up with $_POST['result'] = Hello -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help me learn! with an explanation of these two functions.
On Wednesday 06 November 2002 21:46, Steve Jackson wrote: It doesn't contain a single result. It returns 16 order numbers (which is correct - 8 should be in the table emails with no checked and therefore the query has worked and pulled out 8 from the orders table also). What I want the function to do is say OK where the orderid's match pull out all the address details for each orderid and display what I want displayed accordingly. At the moment I get this array returned by using print_r($row). Array ( [0] = 100040 [orderid] = 100040 ) Array ( [0] = 100041 [orderid] = 100041 ) Array ( [0] = 100043 [orderid] = 100043 ) Array ( [0] = 100044 [orderid] = 100044 ) Array ( [0] = 100046 [orderid] = 100046 ) Array ( [0] = 100050 [orderid] = 100050 ) Array ( [0] = 100051 [orderid] = 100051 ) Array ( [0] = 100052 [orderid] = 100052 ) Where do I go from here? Well, like I said in my previous post if you remove the line: $orderid = $row; then your second query *should* work. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* New members are urgently needed in the Society for Prevention of Cruelty to Yourself. Apply within. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Converting variables to integer
I have a bunch of form variables that I need to process as integers. The problem is that some users are writing in values with commas - e.g. 100,000, and that isn't read as an integer. There's more than one variable so I don't want to have to do a string replace for each one. Is there a general way to curb this problem? Thanks, Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Running functions as other than nobody
I need to chmod files which are owned by a nother user than nobody with a php script runing from a browser. lets say i have a file called image.gif and I want to chmod(imgage.gif, 0777); and I want to run it as user: myuser with passwd: passwd. Can I do this? Regards, David
Re: [PHP] Running functions as other than nobody
There was actually a brief thread about this last night. If you're using Apache, you could look into suexec--this may or may not be a possibility depending on the degree of control that you have on your server. Marco -- php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmer Come visit us at http://www.phparch.com! ---BeginMessage--- I need to chmod files which are owned by a nother user than nobody with a php script runing from a browser. lets say i have a file called image.gif and I want to chmod(imgage.gif, 0777); and I want to run it as user: myuser with passwd: passwd. Can I do this? Regards, David ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] publishing php mysql website on cd-rom
My organization has a need to publish some of our web content on a CD-ROM. I'm in search of suggestions on how to publish our dynamic content (php/mysql templates) in some sort of runtime configuration that would let users browse the site from cd. What's involved with this? Is there such a thing as runtime mySQL? What would it take to serve PHP from a CD? Help! I don't know where to begin and am looking for advice. Thanks, Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] publishing php mysql website on cd-rom
That would be a bit difficult--you would have licensing issues, particularly with MySQL, unless you actually distribute the sources. Would publishing all the files in static format be an option? -- php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmer Come visit us at http://www.phparch.com! ---BeginMessage--- My organization has a need to publish some of our web content on a CD-ROM. I'm in search of suggestions on how to publish our dynamic content (php/mysql templates) in some sort of runtime configuration that would let users browse the site from cd. What's involved with this? Is there such a thing as runtime mySQL? What would it take to serve PHP from a CD? Help! I don't know where to begin and am looking for advice. Thanks, Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generically accessing member variables problem
Thank you for replying, but I don't think I've made my problem clear enough. Let me give it another shot. What I want is a function that takes the name of an array as a parameter so that it can be popped into any class that has arrays in it and work without modification. The problem I am having is in converting the passed in array name to the form which the class would recognize as its own member variable, i.e. $this-passed_in_array_name. In other words, it comes in as a string, just the name of the array, I append $this- to it, but it still isn't getting interpreted the same as if I had written the call explicitely to $this-memberarray. Does this make any more sense? jck Marek Kilimajer wrote: If I understand you, you need to have a basic class with the one function and subclass it. Then you can reference the array as $this-$passed_in_array_name John Kenyon wrote: I'm trying to write a function I can plop in a bunch of different classes without having to modify it. Basically I have classes like: class Example { var $array1; var $array2; var $array3; etc. } and I want to have a function in that class that looks something like this: function do_something_to_array($passed_in_array_name) { //this is what I've done so far, but which isn't working $arr = '$this-' . $passed_in_array_name; // now I want $passed_in_array_name to be evaluated as an array eval (\$arr = \$arr\;); // however even if 'array1' is the passed in value $arr is not the // same as $this-array1 ... } As a side note there is another aspect of this that confuses me -- if I do a print_r($arr) before the eval it returns the string '$this-array1', if I do it after it returns Array (which is what it seems it should do. However, if I then pass $arr to a function that requires an array as an argument, like array_push, for example, I get an error that says that function takes an array. Can anyone explain this to me? The only guess I have is that my eval function is turning it into a string which reads as Array instead of either a String object or the value of the string. More important though is the first problem of generically accesing a member variable based on the passed in name of the variable. In other words I want to be able to choose which array I operate on by passing in the name of that array. Any help on this problem is appreciated. I know there must be a way to do this. Please let me know if I haven't formulated the problem clearly enough. jck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] publishing php mysql website on cd-rom
That is going to be very hard to do...you might want to look at doing it all static...however, what are u going to do about the database connections... IMHO, i would take the php site and make it static and then put it on a CD-ROM...it might be out of date, however, it might be the fastest way for ya. Do you want them to access your site from the CD-ROM pages? You could create special pages on your site that the CD-ROM pages call. But that would require the user of the disc to have internet access. But running PHP from a cd-rom will probably not work unless you are doing some commandline cgi stuff...and i dont even want to think how that would work for ya... i would probably do something where static html pages pull data from your site... HTH... On Wed, 2002-11-06 at 16:44, ROBERT MCPEAK wrote: My organization has a need to publish some of our web content on a CD-ROM. I'm in search of suggestions on how to publish our dynamic content (php/mysql templates) in some sort of runtime configuration that would let users browse the site from cd. What's involved with this? Is there such a thing as runtime mySQL? What would it take to serve PHP from a CD? Help! I don't know where to begin and am looking for advice. Thanks, Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- .: B i g D o g :. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] publishing php mysql website on cd-rom
I dunno if its an old wives tail but I have heard that you can get apache/mysql and php running from a CD. You would of course need to turn off all logging etc. Do a bit off google bashing. John On Wednesday 06 Nov 2002 9:50 am, .: B i g D o g :. wrote: That is going to be very hard to do...you might want to look at doing it all static...however, what are u going to do about the database connections... IMHO, i would take the php site and make it static and then put it on a CD-ROM...it might be out of date, however, it might be the fastest way for ya. Do you want them to access your site from the CD-ROM pages? You could create special pages on your site that the CD-ROM pages call. But that would require the user of the disc to have internet access. But running PHP from a cd-rom will probably not work unless you are doing some commandline cgi stuff...and i dont even want to think how that would work for ya... i would probably do something where static html pages pull data from your site... HTH... On Wed, 2002-11-06 at 16:44, ROBERT MCPEAK wrote: My organization has a need to publish some of our web content on a CD-ROM. I'm in search of suggestions on how to publish our dynamic content (php/mysql templates) in some sort of runtime configuration that would let users browse the site from cd. What's involved with this? Is there such a thing as runtime mySQL? What would it take to serve PHP from a CD? Help! I don't know where to begin and am looking for advice. Thanks, Bob -- 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] publishing php mysql website on cd-rom
Theoretically it is possible, but fact stays - you won't ever make it work well. So, try to find an alternative for this. Usually, this choice is made by the managers that know nothing about how webcontent works. -- Maxim Maletsky [EMAIL PROTECTED] ROBERT MCPEAK [EMAIL PROTECTED] wrote... : My organization has a need to publish some of our web content on a CD-ROM. I'm in search of suggestions on how to publish our dynamic content (php/mysql templates) in some sort of runtime configuration that would let users browse the site from cd. What's involved with this? Is there such a thing as runtime mySQL? What would it take to serve PHP from a CD? Help! I don't know where to begin and am looking for advice. Thanks, Bob -- 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] generically accessing member variables problem
You can do: ${this-$passed_in_array_name} not sure right now of the correct syntaxing, I never do that - normally I'd pass the element key. -- Maxim Maletsky [EMAIL PROTECTED] John Kenyon [EMAIL PROTECTED] wrote... : Thank you for replying, but I don't think I've made my problem clear enough. Let me give it another shot. What I want is a function that takes the name of an array as a parameter so that it can be popped into any class that has arrays in it and work without modification. The problem I am having is in converting the passed in array name to the form which the class would recognize as its own member variable, i.e. $this-passed_in_array_name. In other words, it comes in as a string, just the name of the array, I append $this- to it, but it still isn't getting interpreted the same as if I had written the call explicitely to $this-memberarray. Does this make any more sense? jck Marek Kilimajer wrote: If I understand you, you need to have a basic class with the one function and subclass it. Then you can reference the array as $this-$passed_in_array_name John Kenyon wrote: I'm trying to write a function I can plop in a bunch of different classes without having to modify it. Basically I have classes like: class Example { var $array1; var $array2; var $array3; etc. } and I want to have a function in that class that looks something like this: function do_something_to_array($passed_in_array_name) { //this is what I've done so far, but which isn't working $arr = '$this-' . $passed_in_array_name; // now I want $passed_in_array_name to be evaluated as an array eval (\$arr = \$arr\;); // however even if 'array1' is the passed in value $arr is not the // same as $this-array1 ... } As a side note there is another aspect of this that confuses me -- if I do a print_r($arr) before the eval it returns the string '$this-array1', if I do it after it returns Array (which is what it seems it should do. However, if I then pass $arr to a function that requires an array as an argument, like array_push, for example, I get an error that says that function takes an array. Can anyone explain this to me? The only guess I have is that my eval function is turning it into a string which reads as Array instead of either a String object or the value of the string. More important though is the first problem of generically accesing a member variable based on the passed in name of the variable. In other words I want to be able to choose which array I operate on by passing in the name of that array. Any help on this problem is appreciated. I know there must be a way to do this. Please let me know if I haven't formulated the problem clearly enough. jck -- 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] Trouble with php-4.2.3, apache-1.3.27, sablotron 0.96
Hi, Wednesday, November 6, 2002, 2:50:42 PM, you wrote: EN -BEGIN PGP SIGNED MESSAGE- EN Hash: SHA1 EN I'm trying to get XSLT working with PHP, and after slowly working my way EN through several other problems, I've found one that I can't figure out. EN Software: EN PHP 4.2.3 EN Apache 1.3.27 EN Sablotron 0.96 EN GCC 3.2 EN Linux 2.4.19-lsm1 EN ./configure \ EN - --enable-xml \ EN - --enable-xslt \ EN - --enable-ftp \ EN - --enable-sockets \ EN - --enable-pcntl \ EN - --with-apxs=/usr/local/apache/bin/apxs \ EN - --with-xslt-sablot \ EN make \ EN sudo make install EN Everything seems to work fine (except for a lot of EN cc1: warning: changing search order for system directory /usr/local/include EN cc1: warning: as it has already been specified as a non-system directory EN 's that appear when using gcc-3.2), but when I try to EN /usr/local/apache/bin/apachectl restart, I get this: EN Syntax error on line 205 of /usr/local/apache/conf/httpd.conf: EN Cannot load /usr/local/apache/libexec/libphp4.so into server: EN /usr/local/lib/libsablot.so.0: undefined symbol: __gxx_personality_v0 EN /usr/local/apache/bin/apachectl start: httpd could not be started EN Any ideas??? EN -BEGIN PGP SIGNATURE- EN Version: GnuPG v1.0.7 (GNU/Linux) EN iD8DBQE9yJ/J/rncFku1MdIRAkhnAKClykcWMUwiWbslAYklx3xm1qsjSQCdFAXh EN roJ+kMyayqdY1UXxL6S5xuQ= EN =1Zaw EN -END PGP SIGNATURE- You probably need this patch http://download-2.gingerall.cz/download/sablot/Sablot-0.96.1.patch You can also use LDFLAGS=-lstdc++ before configuring PHP more info at http://php.benscom.com/manual/en/ref.xslt.php -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generically accessing member variables problem
Thanks, that may be what I was looking for. jck Maxim Maletsky wrote: You can do: ${this-$passed_in_array_name} not sure right now of the correct syntaxing, I never do that - normally I'd pass the element key. -- Maxim Maletsky [EMAIL PROTECTED] John Kenyon [EMAIL PROTECTED] wrote... : Thank you for replying, but I don't think I've made my problem clear enough. Let me give it another shot. What I want is a function that takes the name of an array as a parameter so that it can be popped into any class that has arrays in it and work without modification. The problem I am having is in converting the passed in array name to the form which the class would recognize as its own member variable, i.e. $this-passed_in_array_name. In other words, it comes in as a string, just the name of the array, I append $this- to it, but it still isn't getting interpreted the same as if I had written the call explicitely to $this-memberarray. Does this make any more sense? jck Marek Kilimajer wrote: If I understand you, you need to have a basic class with the one function and subclass it. Then you can reference the array as $this-$passed_in_array_name John Kenyon wrote: I'm trying to write a function I can plop in a bunch of different classes without having to modify it. Basically I have classes like: class Example { var $array1; var $array2; var $array3; etc. } and I want to have a function in that class that looks something like this: function do_something_to_array($passed_in_array_name) { //this is what I've done so far, but which isn't working $arr = '$this-' . $passed_in_array_name; // now I want $passed_in_array_name to be evaluated as an array eval (\$arr = \$arr\;); // however even if 'array1' is the passed in value $arr is not the // same as $this-array1 ... } As a side note there is another aspect of this that confuses me -- if I do a print_r($arr) before the eval it returns the string '$this-array1', if I do it after it returns Array (which is what it seems it should do. However, if I then pass $arr to a function that requires an array as an argument, like array_push, for example, I get an error that says that function takes an array. Can anyone explain this to me? The only guess I have is that my eval function is turning it into a string which reads as Array instead of either a String object or the value of the string. More important though is the first problem of generically accesing a member variable based on the passed in name of the variable. In other words I want to be able to choose which array I operate on by passing in the name of that array. Any help on this problem is appreciated. I know there must be a way to do this. Please let me know if I haven't formulated the problem clearly enough. jck -- 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[2]: [PHP] generically accessing member variables problem
Hi, Thursday, November 7, 2002, 3:11:12 AM, you wrote: MM You can do: ${this-$passed_in_array_name} MM not sure right now of the correct syntaxing, I never do that - normally MM I'd pass the element key. MM -- MM Maxim Maletsky MM [EMAIL PROTECTED] MM John Kenyon [EMAIL PROTECTED] wrote... : Thank you for replying, but I don't think I've made my problem clear enough. Let me give it another shot. What I want is a function that takes the name of an array as a parameter so that it can be popped into any class that has arrays in it and work without modification. The problem I am having is in converting the passed in array name to the form which the class would recognize as its own member variable, i.e. $this-passed_in_array_name. In other words, it comes in as a string, just the name of the array, I append $this- to it, but it still isn't getting interpreted the same as if I had written the call explicitely to $this-memberarray. Does this make any more sense? jck Marek Kilimajer wrote: If I understand you, you need to have a basic class with the one function and subclass it. Then you can reference the array as $this-$passed_in_array_name John Kenyon wrote: I'm trying to write a function I can plop in a bunch of different classes without having to modify it. Basically I have classes like: class Example { var $array1; var $array2; var $array3; etc. } and I want to have a function in that class that looks something like this: function do_something_to_array($passed_in_array_name) { //this is what I've done so far, but which isn't working $arr = '$this-' . $passed_in_array_name; // now I want $passed_in_array_name to be evaluated as an array eval (\$arr = \$arr\;); // however even if 'array1' is the passed in value $arr is not the // same as $this-array1 ... } As a side note there is another aspect of this that confuses me -- if I do a print_r($arr) before the eval it returns the string '$this-array1', if I do it after it returns Array (which is what it seems it should do. However, if I then pass $arr to a function that requires an array as an argument, like array_push, for example, I get an error that says that function takes an array. Can anyone explain this to me? The only guess I have is that my eval function is turning it into a string which reads as Array instead of either a String object or the value of the string. More important though is the first problem of generically accesing a member variable based on the passed in name of the variable. In other words I want to be able to choose which array I operate on by passing in the name of that array. Any help on this problem is appreciated. I know there must be a way to do this. Please let me know if I haven't formulated the problem clearly enough. jck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Amazing what you learn on this list :) This works: class Example { var $array1 = array(); var $array2 = array(); var $array3 = array(); function add2array($array_name,$val){ $this-{$array_name}[] = $val; } } $t = new Example(); $t-add2array('array1',25); $t-add2array('array2',26); $t-add2array('array3',Hello); echo 'pre'; print_r($t); echo '/pre'; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generically accessing member variables problem
Tom Rogers [EMAIL PROTECTED] wrote... : Amazing what you learn on this list :) This works: class Example { var $array1 = array(); var $array2 = array(); var $array3 = array(); function add2array($array_name,$val){ $this-{$array_name}[] = $val; } } $t = new Example(); $t-add2array('array1',25); $t-add2array('array2',26); $t-add2array('array3',Hello); echo 'pre'; print_r($t); echo '/pre'; Yet, this is not a such elegant way doing it. It can be helpful in a lot of cases, but most often, element key is enough. Try rethinking your logic: class Example { var $array = array(); function add2array($element_name, $val){ $this-$array[$element_name] = $val; } } $t = new Example(); $t-add2array('array1',25); $t-add2array('array2',26); $t-add2array('array3',Hello); echo 'pre'; print_r($t); echo '/pre'; Cleaner and more scalable, no? -- Maxim Maletsky [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Code Advice
I (think I) have come up with an interesting little solution for pages that have/can potentially have a lot of get vars, and I just wanted to throw it by everyone to see if I know what I'm talking about... Instead of having a whole bunch of ... if (isset($_GET['var'])) $var = $_GET['var'] .. lines on top of each page.. does this code look feasable to you? - $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } - It SEEMS to work so far, I just don't want to throw this into a production environment if something's all screwy, so I figure I'll get a few hundred pairs of eyes.. I'm sure someone else probably thought of such a thing, I was just tired of having a page of 'if $_GET''s everywhere, and its scalable with just adding a word to the array, instead of two new lines. Any potential bugs? --Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] generically accessing member variables problem
Hi, Thursday, November 7, 2002, 3:45:34 AM, you wrote: MM Yet, this is not a such elegant way doing it. It can be helpful in a lot MM of cases, but most often, element key is enough. Try rethinking your MM logic: MM class Example { MM var $array = array(); MM function add2array($element_name, $val){ MM $this-$array[$element_name] = $val; MM } MM } MM $t = new Example(); $t-add2array('array1',25); $t-add2array('array2',26); $t-add2array('array3',Hello); MM echo 'pre'; MM print_r($t); MM echo '/pre'; MM Cleaner and more scalable, no? Yes and to fit the original 3 seperate arrays it would be function add2array($element_name, $val){ $this-$array[$element_name][] = $val; } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generically accessing member variables problem
Tom Rogers [EMAIL PROTECTED] wrote... : Hi, Thursday, November 7, 2002, 3:45:34 AM, you wrote: MM Yet, this is not a such elegant way doing it. It can be helpful in a lot MM of cases, but most often, element key is enough. Try rethinking your MM logic: MM class Example { MM var $array = array(); MM function add2array($element_name, $val){ MM $this-$array[$element_name] = $val; MM } MM } MM $t = new Example(); $t-add2array('array1',25); $t-add2array('array2',26); $t-add2array('array3',Hello); MM echo 'pre'; MM print_r($t); MM echo '/pre'; MM Cleaner and more scalable, no? Yes and to fit the original 3 seperate arrays it would be function add2array($element_name, $val){ $this-$array[$element_name][] = $val; } No, because you pass it the name and data. This way every name will become element's name containing the relevant data. Your way just makes it an associative array without a way of directly accessing it. -- Maxim Maletsky [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generically accessing member variables problem
See below: MM class Example { MM var $array = array(); MM function add2array($element_name, $val){ MM $this-$array[$element_name] = $val; MM } MM } MM $t = new Example(); $t-add2array('array1',25); $t-add2array('array2',26); $t-add2array('array3',Hello); MM echo 'pre'; MM print_r($t); MM echo '/pre'; MM Cleaner and more scalable, no? Yes and to fit the original 3 seperate arrays it would be function add2array($element_name, $val){ $this-$array[$element_name][] = $val; } No, because you pass it the name and data. This way every name will become element's name containing the relevant data. Your way just makes it an associative array without a way of directly accessing it. -- Maxim Maletsky [EMAIL PROTECTED] But my problem is that I have several arrays already and I want to be able to act on a specific array depending on the name I pass in. I don't see how your solution solves that issue. jck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generically accessing member variables problem
You pass it the name of the element, and whatever the data inside. You do not need to add other sub-elements to it automatically, as you would need to be searching through the elements later for the right data. Whatever your need is - it's a good idea using arrays, and add other arrays into it. But, it is a bad idea cloning variables and auto-assign array's elements when you know that you will need that specific piece you store alone. -- Maxim Maletsky [EMAIL PROTECTED] John Kenyon [EMAIL PROTECTED] wrote... : See below: MM class Example { MM var $array = array(); MM function add2array($element_name, $val){ MM $this-$array[$element_name] = $val; MM } MM } MM $t = new Example(); $t-add2array('array1',25); $t-add2array('array2',26); $t-add2array('array3',Hello); MM echo 'pre'; MM print_r($t); MM echo '/pre'; MM Cleaner and more scalable, no? Yes and to fit the original 3 seperate arrays it would be function add2array($element_name, $val){ $this-$array[$element_name][] = $val; } No, because you pass it the name and data. This way every name will become element's name containing the relevant data. Your way just makes it an associative array without a way of directly accessing it. -- Maxim Maletsky [EMAIL PROTECTED] But my problem is that I have several arrays already and I want to be able to act on a specific array depending on the name I pass in. I don't see how your solution solves that issue. jck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] publishing php mysql website on cd-rom
It's a database site, containing thousands of records, similar to a products catalog like Amazon, for example. Publishing as static pages is not a viable option, and would greatly limit the search functionality. There must be a way to do this! Thanks for all the feedback. Maxim Maletsky [EMAIL PROTECTED] 11/06/02 12:10PM Theoretically it is possible, but fact stays - you won't ever make it work well. So, try to find an alternative for this. Usually, this choice is made by the managers that know nothing about how webcontent works. -- Maxim Maletsky [EMAIL PROTECTED] ROBERT MCPEAK [EMAIL PROTECTED] wrote... : My organization has a need to publish some of our web content on a CD-ROM. I'm in search of suggestions on how to publish our dynamic content (php/mysql templates) in some sort of runtime configuration that would let users browse the site from cd. What's involved with this? Is there such a thing as runtime mySQL? What would it take to serve PHP from a CD? Help! I don't know where to begin and am looking for advice. Thanks, Bob -- 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] Code Advice
The method that you have described below is going to produce a numerical Key which is going to result in several errors. -Kevin - Original Message - From: Jason Young [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 10:52 AM Subject: [PHP] Code Advice I (think I) have come up with an interesting little solution for pages that have/can potentially have a lot of get vars, and I just wanted to throw it by everyone to see if I know what I'm talking about... Instead of having a whole bunch of ... if (isset($_GET['var'])) $var = $_GET['var'] .. lines on top of each page.. does this code look feasable to you? - $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } - It SEEMS to work so far, I just don't want to throw this into a production environment if something's all screwy, so I figure I'll get a few hundred pairs of eyes.. I'm sure someone else probably thought of such a thing, I was just tired of having a page of 'if $_GET''s everywhere, and its scalable with just adding a word to the array, instead of two new lines. Any potential bugs? --Jason -- 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] Code Advice
-Original Message- From: Kevin Stone [mailto:kevin;helpelf.com] Sent: 06 November 2002 18:32 The method that you have described below is going to produce a numerical Key which is going to result in several errors. Huh? What on earth does this mean? -Kevin - Original Message - From: Jason Young [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 10:52 AM Subject: [PHP] Code Advice I (think I) have come up with an interesting little solution for pages that have/can potentially have a lot of get vars, and I just wanted to throw it by everyone to see if I know what I'm talking about... Instead of having a whole bunch of ... if (isset($_GET['var'])) $var = $_GET['var'] .. lines on top of each page.. does this code look feasable to you? - $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } Yes, I suppose this is a step up from extract(). Looks fine to me, except that I'd use foreach ($get_allow as $key=$val) rather than the while() -- comes down to personal preference, I suppose. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting variables to integer
function str2int($str) { $str = str_replace(',', $str); // http://www.php.net/manual/en/function.str-replace.php settype($str, integer); // http://www.php.net/manual/en/function.settype.php if (is_int($str)) // http://www.php.net/manual/en/function.is-int.php return $str; else return false; } Loop through your form variables and call this function. Good luck, -Kevin - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 9:05 AM Subject: [PHP] Converting variables to integer I have a bunch of form variables that I need to process as integers. The problem is that some users are writing in values with commas - e.g. 100,000, and that isn't read as an integer. There's more than one variable so I don't want to have to do a string replace for each one. Is there a general way to curb this problem? Thanks, Doug -- 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] Code Advice
At 18:52 06.11.2002, Jason Young spoke out and said: [snip] I (think I) have come up with an interesting little solution for pages that have/can potentially have a lot of get vars, and I just wanted to throw it by everyone to see if I know what I'm talking about... Instead of having a whole bunch of ... if (isset($_GET['var'])) $var = $_GET['var'] .. lines on top of each page.. does this code look feasable to you? - $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } - [snip] You're doing this to filter out parameters, and to emulate register_globals, right? To allow only a specific set of variables for $_GET, this loop may present an elegant solution: foreach ($_GET as $name = $value) { if (!in_array(strtolower($name), $get_allow)) unset($_GET[$name]); } Note that I'm using strtolower for array lookup. Ever had a headache with posted parameters, as to where to look for the value, in _GET or _POST? Try this: foreach ($_POST as $name = $value) $_GET[$name] = $value; Your application may safely use only the $_GET array after this, the POSTed variables correctly overriding their GET counterparts. The = reference is there for optimization - faster and less memory-consuming. Wnat to have these global after all? foreach ($_GET as $name = $value) { global $$name; $$name = $value; } Have fun, -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/
Re: [PHP] Code Advice
All I have to go by is what I see. The method was this.. ? $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } ? The array $get_allow has numerical indicies. Looping through that in the method described is going to set an integer to $key. So your first error is going to be that $_GET[0] is Undefined. Second error is going to be $$key is an invalid variable name. -Kevin - Original Message - From: Ford, Mike [LSS] [EMAIL PROTECTED] To: 'Kevin Stone' [EMAIL PROTECTED]; [EMAIL PROTECTED]; Jason Young [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 11:50 AM Subject: RE: [PHP] Code Advice -Original Message- From: Kevin Stone [mailto:kevin;helpelf.com] Sent: 06 November 2002 18:32 The method that you have described below is going to produce a numerical Key which is going to result in several errors. Huh? What on earth does this mean? -Kevin - Original Message - From: Jason Young [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 10:52 AM Subject: [PHP] Code Advice I (think I) have come up with an interesting little solution for pages that have/can potentially have a lot of get vars, and I just wanted to throw it by everyone to see if I know what I'm talking about... Instead of having a whole bunch of ... if (isset($_GET['var'])) $var = $_GET['var'] .. lines on top of each page.. does this code look feasable to you? - $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } Yes, I suppose this is a step up from extract(). Looks fine to me, except that I'd use foreach ($get_allow as $key=$val) rather than the while() -- comes down to personal preference, I suppose. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting variables to integer
This should work for you, this recursive function loops the array, if it gets array again, calls itself function convert2int($var) { foreach($var as $k = $v ) { if(is_array($v)) { $var[$k]=convert2int($v); } else { $var[$k]=str_replace(',',$v); } } return $var; } $_POST=convert2int($_POST); [EMAIL PROTECTED] wrote: I have a bunch of form variables that I need to process as integers. The problem is that some users are writing in values with commas - e.g. 100,000, and that isn't read as an integer. There's more than one variable so I don't want to have to do a string replace for each one. Is there a general way to curb this problem? Thanks, Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code Advice
At 19:50 06.11.2002, Ford, Mike [LSS] spoke out and said: [snip] -Original Message- From: Kevin Stone [mailto:kevin;helpelf.com] Sent: 06 November 2002 18:32 The method that you have described below is going to produce a numerical Key which is going to result in several errors. Huh? What on earth does this mean? [snip] $get_allow = array('eat','it','all'); This results in an array as [0] = 'eat', [1] = 'it', [2] = 'all' while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } At execution, $key will hold the values 0,1,2. The last line of the loop will expand to $0 = $val, $1 = $val, $2 = $val. All of these are invalid identifiers (may not start with a number). The more, it does absolutely not what the coder intended. The correct loop would be while (list($key,$val)=each($get_allow)) { if (isset($_GET[$val])) { global $$val; $$val = $_GET[$val]; } } The key element is not necessary here. -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/
Re: [PHP] Converting variables to integer
Ooops my str_replace() function needs one more parameter. str_replace(',', '', $str); -Kevin - Original Message - From: Kevin Stone [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 11:45 AM Subject: Re: [PHP] Converting variables to integer function str2int($str) { $str = str_replace(',', $str); // http://www.php.net/manual/en/function.str-replace.php settype($str, integer); // http://www.php.net/manual/en/function.settype.php if (is_int($str)) // http://www.php.net/manual/en/function.is-int.php return $str; else return false; } Loop through your form variables and call this function. Good luck, -Kevin - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 9:05 AM Subject: [PHP] Converting variables to integer I have a bunch of form variables that I need to process as integers. The problem is that some users are writing in values with commas - e.g. 100,000, and that isn't read as an integer. There's more than one variable so I don't want to have to do a string replace for each one. Is there a general way to curb this problem? Thanks, Doug -- 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] Code Advice
-Original Message- From: Kevin Stone [mailto:kevin;helpelf.com] Sent: 06 November 2002 18:50 To: [EMAIL PROTECTED] Subject: Re: [PHP] Code Advice All I have to go by is what I see. The method was this.. ? $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } ? The array $get_allow has numerical indicies. Looping through that in the method described is going to set an integer to $key. So your first error is going to be that $_GET[0] is Undefined. Second error is going to be $$key is an invalid variable name. Mea culpa -- you're quite right, and I should read more carefully! (Well, it is 7pm and going home time) This should, of course, be done like this: $get_allow = array(..); foreach ($get_allow as $key): if (isset($_GET($key)): $$key = $_GET[$key]; endif; endforeach; Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Code Advice
-Original Message- From: Ernest E Vogelsinger [mailto:ernest;vogelsinger.at] Sent: 06 November 2002 18:49 To: [EMAIL PROTECTED] Subject: Re: [PHP] Code Advice Ever had a headache with posted parameters, as to where to look for the value, in _GET or _POST? Try this: foreach ($_POST as $name = $value) $_GET[$name] = $value; Your application may safely use only the $_GET array after this, the POSTed variables correctly overriding their GET counterparts. The = reference is there for optimization - faster and less memory-consuming. Uh... isn't this what $_REQUEST is for?? Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code Advice
look well through the code you posted, it had a bug :) But we got your idea - it can be a solution for limiting input. Yet, you need to also know a way to unset unwanted variables. That can only be done by accessing $_GET or $HTTP_GET_VARS (if GET method). -- Maxim Maletsky [EMAIL PROTECTED] Ford, Mike [LSS] [EMAIL PROTECTED] wrote... : -Original Message- From: Kevin Stone [mailto:kevin;helpelf.com] Sent: 06 November 2002 18:32 The method that you have described below is going to produce a numerical Key which is going to result in several errors. Huh? What on earth does this mean? -Kevin - Original Message - From: Jason Young [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 10:52 AM Subject: [PHP] Code Advice I (think I) have come up with an interesting little solution for pages that have/can potentially have a lot of get vars, and I just wanted to throw it by everyone to see if I know what I'm talking about... Instead of having a whole bunch of ... if (isset($_GET['var'])) $var = $_GET['var'] .. lines on top of each page.. does this code look feasable to you? - $get_allow = array('foo', 'bar', 'add', 'takeovertheworld'); while (list($key,$val)=each($get_allow)) { if (isset($_GET[$key])) $$key = $val; } Yes, I suppose this is a step up from extract(). Looks fine to me, except that I'd use foreach ($get_allow as $key=$val) rather than the while() -- comes down to personal preference, I suppose. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generically accessing member variables problem
I am not really sure I understand what you are saying here, and I would like to. Let me first say that I think the syntax you came up with earlier will solve my immediate problem, but if I could design this in a better way I'd like to know. Let me give you a few more details: I have a large class that contains multiple instances of various different classes, in turn, each of these instances could contain multiple instances of other classes. A big tree. In order to keep track of the various instances of the classes I use arrays, so each class that contains instances of other classes keeps like classes within an array. Sometimes a class has multiple arrays, each holding instances of a different type of class. Each of these classes is being used to generate html forms and I want to have a way to have the user check a checkbox and remove a particular instance of a class. I want to have one function that I can plop into each class (in some cases it may be possible to have children inherit the function from a parent class) and which will delete the correct instance of the correct class by passing in the name of the array the instance is held in and its index in that array. I hope this provides you with a little more context and if your advice still pertains, please explain it if you would. jck Maxim Maletsky wrote: You pass it the name of the element, and whatever the data inside. You do not need to add other sub-elements to it automatically, as you would need to be searching through the elements later for the right data. Whatever your need is - it's a good idea using arrays, and add other arrays into it. But, it is a bad idea cloning variables and auto-assign array's elements when you know that you will need that specific piece you store alone. -- Maxim Maletsky [EMAIL PROTECTED] John Kenyon [EMAIL PROTECTED] wrote... : See below: MM class Example { MM var $array = array(); MM function add2array($element_name, $val){ MM $this-$array[$element_name] = $val; MM } MM } MM $t = new Example(); $t-add2array('array1',25); $t-add2array('array2',26); $t-add2array('array3',Hello); MM echo 'pre'; MM print_r($t); MM echo '/pre'; MM Cleaner and more scalable, no? Yes and to fit the original 3 seperate arrays it would be function add2array($element_name, $val){ $this-$array[$element_name][] = $val; } No, because you pass it the name and data. This way every name will become element's name containing the relevant data. Your way just makes it an associative array without a way of directly accessing it. -- Maxim Maletsky [EMAIL PROTECTED] But my problem is that I have several arrays already and I want to be able to act on a specific array depending on the name I pass in. I don't see how your solution solves that issue. jck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php