php-general Digest 6 May 2011 13:01:43 -0000 Issue 7300
php-general Digest 6 May 2011 13:01:43 - Issue 7300 Topics (messages 312693 through 312704): Customize link 312693 by: Michael Simiyu 312694 by: Daniel Brown 312695 by: admin.buskirkgraphics.com 312696 by: Michael Simiyu 312697 by: Jim Lucas Re: php-general Digest 5 May 2011 21:55:09 - Issue 7299 312698 by: e-letter 312703 by: David Robley Upload size limit stays at 8MB 312699 by: James Moe 312700 by: Ross Hansen Parsing a simple sql string in php 312701 by: Ashley Sheridan 312702 by: Stuart Dallas 312704 by: Ken Guest Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Hello, Here is the scenario I have a form with the folloing fields i. Title ii. Category (This is a drop down with a list of categories which have id's - am using wordpress ) iii. upload file field now what i want to do is to be able to customize a link like http://www.mysite.com/addfilecat_id=5 so that when i access the link it has one of the categories in the drop down selected..reason is i dont want users to see the different types of categories So i guess my question is how to configure a meu item in a drop down to be automatically selected in a link... Thanks ---End Message--- ---BeginMessage--- On Thu, May 5, 2011 at 18:10, Michael Simiyu simiyu.mich...@gmail.com wrote: So i guess my question is how to configure a meu item in a drop down to be automatically selected in a link... ?php $cat_ids = array(1,3,5,7,13,15,24,36,81,92); echo 'select name=categories'.PHP_EOL; foreach ($cat_ids as $cid) { echo ' option value='.$cid.''; if (isset($_GET['cat_id']) $_GET['cat_id'] == $cid) { echo ' selected=selected'; } echo ''.$cid.'/option'.PHP_EOL; } echo '/select'.PHP_EOL; ? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ ---End Message--- ---BeginMessage--- If your options are dynamically created you could check the value passed against each option are mark the match with SELECTED; Example Static: Echo option value='5'; If(isset($_GET['cat_id']) $_GET['cat_id'] == 5){ echo ' SELECETED ';} echo 5/option.PHP_EOL; Example Dynamic for($a=1, $a = 15; $a++) { Echo option value='.$a.' ; If(isset($_GET['cat_id']) $_GET['cat_id'] == $a){ echo ' SELECETED ';} echo .$a./option.PHP_EOL; } Just a though Richard L. Buskirk -Original Message- From: Michael Simiyu [mailto:simiyu.mich...@gmail.com] Sent: Thursday, May 05, 2011 6:10 PM To: php-gene...@lists.php.net Subject: [PHP] Customize link Hello, Here is the scenario I have a form with the folloing fields i. Title ii. Category (This is a drop down with a list of categories which have id's - am using wordpress ) iii. upload file field now what i want to do is to be able to customize a link like http://www.mysite.com/addfilecat_id=5 so that when i access the link it has one of the categories in the drop down selected..reason is i dont want users to see the different types of categories So i guess my question is how to configure a meu item in a drop down to be automatically selected in a link... Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Dan, thanks for the reply.this is the code that shows/lists the categories ?php $cats = $download_taxonomies- get_parent_cats(); if (!empty($cats)) { foreach ( $cats as $c ) { echo 'lilabel for=category_'. $c-id.'input type=checkbox name=category_'.$c-id.' id=category_'.$c-id.' '; if (isset($_POST['category_'.$c-id])) echo 'checked=checked'; echo ' / '.$c-id.' - '.$c-name.'/label'; // Do Children if (!function_exists('cat_form_output_children')) { function cat_form_output_children($child) { global $download_taxonomies;
php-general Digest 7 May 2011 02:42:52 -0000 Issue 7301
php-general Digest 7 May 2011 02:42:52 - Issue 7301 Topics (messages 312705 through 312708): Re: mysql error 312705 by: Curtis Maurand Re: Parsing a simple sql string in php 312706 by: Ashley Sheridan semaphores are broken 312707 by: Jeremy Greene Re: Upload size limit stays at 8MB 312708 by: Ross Hansen Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- engine= --C Grega Leskov¹ek wrote: Can smbd please look at this sentence - I got an error and do not know how to fix it - I am still very unfamiliar with MYSQL: CREATE TABLE log ( idlog int auto_increment not null, imepriimek varchar(50), clock timestamp, action varchar(30), onfile varchar(100), filesize float(6,2), uniqueid(idlog) ); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(idlog) )' at line 1 -- When the sun rises I receive and when it sets I forgive - http://moj.skavt.net/gleskovs/ Always in Heart, Grega LeskovÅ¡ek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Ken Guest k...@linux.ie wrote: On Fri, May 6, 2011 at 10:05 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Hiya, has anyone had any experience with parsing a string of sql to break it down into its component parts? At the moment I'm using several regex's to parse a string, which works, but I'm sure there's a more elegant solution. The general idea is to produce a nice looking page giving details of updated fields and values. I'm only concerned with update statements really, and the queries are very simple, operating on one table at a time, with no sub queries or selects. Thanks in advance if anyone is able to suggest anything! I'd suggest at least taking a look at pear's sql parser package - using it might save you some headaches ;) http://pear.php.net/package/SQL_Parser Thanks Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I had seen this but didn't see much in the way of documentation (i only spent 5 mins looking though) and I've tended to steer away from pear after warnings from this very list! I solved the issue in the end with regex's. As the queries were generally fairly basic, it wasn't too hard to write the expressions for them, and so far its working well for my needs. I was just asking here to see if anyone had any experience with something, not to see if they could phrase the Google search in a different way. Thanks though to all who replied. Thanks Ash -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. ---End Message--- ---BeginMessage--- Ok, I tried to use semaphores between php and C++. Where the php script was the client and the C++ app was a server. Client only acquired sems, server only released. This cannot be done with php semaphores. Got around the first two problems: 1) Php semaphore is actually 3 sysV sems. a. Need to have the C++ program create one with 3 2) Php will reset sem 0 - the real sem whenever sem_get() is done. a. Sem 1 is a reference count - number of procs using it, and sem 2 is used to lock access to sem 1. b. Ok, so made C++ set sem 1 to 1. Actually since I know it starts 1st I just blindly do that. For some odd reason, it seems that sem 2 also needs to be set to 0... not sure why. The right way would be to wait till sem 2 is 0, then check if sem 1 0. If so, increment it and do not init sem0. Else, set sem 0 to init value, set sem 1 to 1 and set sem 2 back to 0. However, could not get past the problem that php always sets the UNDO flag. So, when the script exits, the semaphore is reset. That completely messes up the client/server approach. Another amusing note is that the C code that php uses to implement the semaphores uses the wait-for-zero feature of sysv semaphores. Kind of funny that it was seen as needed for even that little effort, but not exposed in php itself J Not to mention all of the other features... So... then. Switch to signals. But to do that correctly, I use a semaphore. In the signal handler, it releases the semaphore. When waiting for a signal in the main loop, I do an acquire. Then I find out that sem_acquire() actually returns **OK** when the underlying semop call gets an EINTR!!! Holy cow. How can a php system call loose an error?! That's just crazy.
[PHP] Re: php-general Digest 5 May 2011 21:55:09 -0000 Issue 7299
Readers, Looking through the mail lists archives, only the following message seems to advise about the possibility to use gnuplot: http://marc.info/?l=php-generalm=96248542218029w=2 Is it possible to start gnuplot using php, to plot a graph from postgresql data. For example, a table is created in the required gnuplot data file format so the command for gnuplot would be something like: plot SELECT * FROM gnuplotdatatable; But can't see a php command to start gnuplot in the first step. Any help please? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upload size limit stays at 8MB
Hello, apache v2.2.15 (Linux/SUSE) phpv5.3.3 linux v2.6.34.7-0.7-desktop #1 SMP I updated /etc/php5/apache2/php.ini to change upload_max_filesize = 2M to upload_max_filesize = 60M. php_info() shows the changed value; echo ini_get(upload_max_filesize) shows the changed value. Yet when I attempt an upload, I get this in the error log: PHP Warning: POST Content-Length of 39246714 bytes exceeds the limit of 8388608 bytes in Unknown on line 0, referer: http://www.sma.com/sma/upload/ Hmm. Unknown on line 0? A bit vague. 8MB max seems a bit less than the 60MB listed. Where else could PHP be getting settings info? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upload size limit stays at 8MB
Hey, There is also an option for post_max_size = xM x being the number specified. This should be located in your php.ini file somewhere. check to make sure that this is set high enough else it could also be causing the issue. To: php-general@lists.php.net Date: Thu, 5 May 2011 21:51:26 -0700 From: ji...@sohnen-moe.com Subject: [PHP] Upload size limit stays at 8MB Hello, apache v2.2.15 (Linux/SUSE) phpv5.3.3 linux v2.6.34.7-0.7-desktop #1 SMP I updated /etc/php5/apache2/php.ini to change upload_max_filesize = 2M to upload_max_filesize = 60M. php_info() shows the changed value; echo ini_get(upload_max_filesize) shows the changed value. Yet when I attempt an upload, I get this in the error log: PHP Warning: POST Content-Length of 39246714 bytes exceeds the limit of 8388608 bytes in Unknown on line 0, referer: http://www.sma.com/sma/upload/ Hmm. Unknown on line 0? A bit vague. 8MB max seems a bit less than the 60MB listed. Where else could PHP be getting settings info? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parsing a simple sql string in php
Hiya, has anyone had any experience with parsing a string of sql to break it down into its component parts? At the moment I'm using several regex's to parse a string, which works, but I'm sure there's a more elegant solution. The general idea is to produce a nice looking page giving details of updated fields and values. I'm only concerned with update statements really, and the queries are very simple, operating on one table at a time, with no sub queries or selects. Thanks in advance if anyone is able to suggest anything! Thanks Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing a simple sql string in php
On Friday, 6 May 2011 at 10:05, Ashley Sheridan wrote: Hiya, has anyone had any experience with parsing a string of sql to break it down into its component parts? At the moment I'm using several regex's to parse a string, which works, but I'm sure there's a more elegant solution. The general idea is to produce a nice looking page giving details of updated fields and values. I'm only concerned with update statements really, and the queries are very simple, operating on one table at a time, with no sub queries or selects. Thanks in advance if anyone is able to suggest anything! I don't have any experience doing it with SQL, but I have written several parsers in my time, and I'd strongly recommend against using regexes to do it. The usual way to approach this problem is to tokenise the input, then take each token at a time and branch where there are several options for what comes next. As you go along, build up a data structure that represents the data you need. Alternatively you could ask Google... http://www.phpclasses.org/package/4916-PHP-Build-a-tree-to-represent-an-SQL-query.html http://code.google.com/p/php-sqlparser/ and more: http://jmp.li/fmy -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php-general Digest 5 May 2011 21:55:09 -0000 Issue 7299
e-letter wrote: Readers, Looking through the mail lists archives, only the following message seems to advise about the possibility to use gnuplot: http://marc.info/?l=php-generalm=96248542218029w=2 Is it possible to start gnuplot using php, to plot a graph from postgresql data. For example, a table is created in the required gnuplot data file format so the command for gnuplot would be something like: plot SELECT * FROM gnuplotdatatable; But can't see a php command to start gnuplot in the first step. Any help please? You might find jpgraph useful. Cheers -- David Robley Pizza IS the four food groups! Today is Sweetmorn, the 53rd day of Discord in the YOLD 3177. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing a simple sql string in php
On Fri, May 6, 2011 at 10:05 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Hiya, has anyone had any experience with parsing a string of sql to break it down into its component parts? At the moment I'm using several regex's to parse a string, which works, but I'm sure there's a more elegant solution. The general idea is to produce a nice looking page giving details of updated fields and values. I'm only concerned with update statements really, and the queries are very simple, operating on one table at a time, with no sub queries or selects. Thanks in advance if anyone is able to suggest anything! I'd suggest at least taking a look at pear's sql parser package - using it might save you some headaches ;) http://pear.php.net/package/SQL_Parser Thanks Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql error
engine= --C Grega Leskov¹ek wrote: Can smbd please look at this sentence - I got an error and do not know how to fix it - I am still very unfamiliar with MYSQL: CREATE TABLE log ( idlog int auto_increment not null, imepriimek varchar(50), clock timestamp, action varchar(30), onfile varchar(100), filesize float(6,2), uniqueid(idlog) ); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(idlog) )' at line 1 -- When the sun rises I receive and when it sets I forgive - http://moj.skavt.net/gleskovs/ Always in Heart, Grega LeskovÅ¡ek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing a simple sql string in php
Ken Guest k...@linux.ie wrote: On Fri, May 6, 2011 at 10:05 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Hiya, has anyone had any experience with parsing a string of sql to break it down into its component parts? At the moment I'm using several regex's to parse a string, which works, but I'm sure there's a more elegant solution. The general idea is to produce a nice looking page giving details of updated fields and values. I'm only concerned with update statements really, and the queries are very simple, operating on one table at a time, with no sub queries or selects. Thanks in advance if anyone is able to suggest anything! I'd suggest at least taking a look at pear's sql parser package - using it might save you some headaches ;) http://pear.php.net/package/SQL_Parser Thanks Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I had seen this but didn't see much in the way of documentation (i only spent 5 mins looking though) and I've tended to steer away from pear after warnings from this very list! I solved the issue in the end with regex's. As the queries were generally fairly basic, it wasn't too hard to write the expressions for them, and so far its working well for my needs. I was just asking here to see if anyone had any experience with something, not to see if they could phrase the Google search in a different way. Thanks though to all who replied. Thanks Ash -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] semaphores are broken
Ok, I tried to use semaphores between php and C++. Where the php script was the client and the C++ app was a server. Client only acquired sems, server only released. This cannot be done with php semaphores. Got around the first two problems: 1) Php semaphore is actually 3 sysV sems. a. Need to have the C++ program create one with 3 2) Php will reset sem 0 - the real sem whenever sem_get() is done. a. Sem 1 is a reference count - number of procs using it, and sem 2 is used to lock access to sem 1. b. Ok, so made C++ set sem 1 to 1. Actually since I know it starts 1st I just blindly do that. For some odd reason, it seems that sem 2 also needs to be set to 0... not sure why. The right way would be to wait till sem 2 is 0, then check if sem 1 0. If so, increment it and do not init sem0. Else, set sem 0 to init value, set sem 1 to 1 and set sem 2 back to 0. However, could not get past the problem that php always sets the UNDO flag. So, when the script exits, the semaphore is reset. That completely messes up the client/server approach. Another amusing note is that the C code that php uses to implement the semaphores uses the wait-for-zero feature of sysv semaphores. Kind of funny that it was seen as needed for even that little effort, but not exposed in php itself J Not to mention all of the other features... So... then. Switch to signals. But to do that correctly, I use a semaphore. In the signal handler, it releases the semaphore. When waiting for a signal in the main loop, I do an acquire. Then I find out that sem_acquire() actually returns **OK** when the underlying semop call gets an EINTR!!! Holy cow. How can a php system call loose an error?! That's just crazy. I do find it interesting that it's not discussed more on the list... but semaphores are kind of silly in php. Jeremy
RE: [PHP] Upload size limit stays at 8MB
Apart from the possible security issues with posting content or information i don't believe that there is any others for posting large amounts of information. Just as long as you are aware that it is all being posted over plain text so if you have any sensitive data you may want to look at setting up a HTTPS. otherwise, glad to know that your issues is solved. :) Date: Fri, 6 May 2011 10:10:31 -0700 From: ji...@sohnen-moe.com To: hansen.r...@live.com.au Subject: Re: [PHP] Upload size limit stays at 8MB -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/05/2011 11:52 PM, Ross Hansen wrote: There is also an option for post_max_size = xM x being the number specified. This should be located in your php.ini file somewhere. check to make sure that this is set high enough else it could also be causing the issue. Okay, that was it. Thanks! Are the any security issues with allowing a large POST size? - -- James Moe moe dot james at sohnen-moe dot com 520.743.3936 -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3EK4cACgkQzTcr8Prq0ZMB7ACdEhMzHq40Gp8GzFjf+9SAeshc NMsAnAhOxVtDDXj7yPSrmh7LjR3UcYlY =ariZ -END PGP SIGNATURE-
[PHP] html formatting in mysql post
Hey Guys, I am using a form to post information to a MySQL table which is then echo(ing) back out to a web page. it will sort of be like facebook where you can post messages and stuff on peoples walls. The only issue is at the moment i can get the formatting to stay. When i echo the table out from mysql it all gets displayed on one line rather than seeing my new lines which i typed in the text box. I do know that this is a HTML error as it was never given the format tags when the content was posted in the table. I have seen something about NL2BR and also something about strip slashes but i am not sure how to incorporate them into my post. Could someone please advise?
Re: [PHP] html formatting in mysql post
On Fri, May 6, 2011 at 22:52, Ross Hansen hansen.r...@live.com.au wrote: Hey Guys, I am using a form to post information to a MySQL table which is then echo(ing) back out to a web page. it will sort of be like facebook where you can post messages and stuff on peoples walls. The only issue is at the moment i can get the formatting to stay. When i echo the table out from mysql it all gets displayed on one line rather than seeing my new lines which i typed in the text box. I do know that this is a HTML error as it was never given the format tags when the content was posted in the table. I have seen something about NL2BR and also something about strip slashes but i am not sure how to incorporate them into my post. Could someone please advise? Well, let's start with an easy question: have you *tried* them? ?php // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ? Error-handling and the remainder of checking is up to you. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Gentle (Friday) Reminder
What do you mean by that? (irony lvl: 100%) Sent from my iPhone On 06-05-2011, at 22:58, Daniel Brown danbr...@php.net wrote: ?php $posting = array('bottom','interspersed','top'); // Feel free to add on $destinations = array('to hell','away','read the archives and see why we don\'t like top-posting','to disneyland then die','anywhere but here'); $point = array_rand($destinations); foreach ($posting as $p) { if ($p == 'top') { // @todo - remind folks of rules: http://links.parasane.net/fb6k echo 'Just remember top-posting on the list means you can go '.$destinations[$point].'.'.PHP_EOL; } } ? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- 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