[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-general&m=96248542218029&w=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 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" wrote: >On Fri, May 6, 2011 at 10:05 AM, 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'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?
[PHP] Gentle (Friday) Reminder
http://links.parasane.net/fb6k echo 'Just remember top-posting on the list means you can go '.$destinations[$point].'.'.PHP_EOL; } } ?> -- 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] html formatting in mysql post
On Fri, May 6, 2011 at 22:52, Ross Hansen 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? Error-handling and the remainder of checking is up to you. -- 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 wrote: > >$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; > >} >} > ?> > > -- > > 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