Re: [PHP] inserting ´ in a db
Pick one: http://si2.php.net/manual/en/function.htmlentities.php http://si2.php.net/manual/en/function.addslashes.php http://si.php.net/mysql_escape_string Aleksandar Yamil Ortega wrote: Hi list, good day. I have a simple script that inserts text on a mysql table, that has a field named description and the type is text. Everting works fine, except when I try to insert a text that includes a simple quote. For example Yamil´s car I send the character string to a variable and then insert into a query. But the mysql says that something is wrong with the query because the quote after the l looks like the end of the string, and “s car” doesn`t look like a valid part of the query. Can anyone help me out, how to handle this error? Thanks Yamil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions running out of storage space - Increase memory?
Dan wrote: After thinking about this a while I also thought of making my own cache. The problem with that is would it be any faster or have any less strain on the server than having multiple requests/connections to the database? A lot depends on the amount of data and the overall load on the web-server. If you do the query once, then store the result in a file, and then keep reading that file for the next cachetime seconds, the file will most probably remain in memory, so accessing it will be fast and without IO. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Alternate Colors in Rows
On Wed, 2007-10-03 at 22:12 -0400, Nathan Nobbe wrote: On 10/3/07, Robert Cummings [EMAIL PROTECTED] wrote: Hopefully you're using a decent browser (almost anything other than IE -- I recommend Opera :) opera is the best for straight browsing. ive found i could have 40 to 50 tabs open with no noticeable perforrmace hit. firefox bogs badly after about 20 tabs and i find some of the features arent as smart as opera. sadly though i think firefox is the best for development. web developer and firebug are 2 priceless tools for development. plus the view source on firefox is much better than other browsers. Opera let's you define what you use to view source. I use my editor joe and so it's all nice and highlighted. I view source in the same way I edit HTML. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: the opposite of a join?
On Thu, 2007-10-04 at 11:56 +1000, Chris wrote: Robert Cummings wrote: On Thu, 2007-10-04 at 11:23 +1000, Chris wrote: Robert Cummings wrote: On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote: This is only from my own personal testing. Mind you that I have only been using PostgreSQL for a year or so. But one problem that I have always ran into with MySQL is that when JOIN'ing tables that have large data sets is a PITA. Were you doing left joins when you experienced those problems? Left joins are usually very fast. If indexed properly of course ;) Yes, but you're not going to get a performance improvement if you use anything else if the table isn't properly indexed. A subselect could win out in terms of performance especially if the table in the subselect is reasonably small (eg all fits into memory). But if it fits in memory then it's probably already in memory for a left join also. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Alternate Colors in Rows
At 1:44 PM -0500 10/3/07, Steve Marquez wrote: Greetings, I am attempting to alternate the colors of the container DIV. Anyone know how to do this? Hi Steve: Easy and simple. First, keep presentation separate from data. In other words, use css to define a css-class, like so: .row0 { background-color: yellow; } .row1 { background-color: #809FFF; } Second, embed php into your table, like so: tr class=row?php echo($i++ 1 );? You can see a working demo here: http://webbytedd.com/b/color-rows/ Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any known security issues with IMAP?
On 10/4/07, Chris [EMAIL PROTECTED] wrote: Don O'Neil wrote: I'm not sure how opening an email inbox can hijack pages but maybe someone more creative than I can show me.. I don't know about the IMAP/POP3 itself, but if you are displaying the messages in a web browser for something like building your own web-mail client, the messages themselves would make YOUR pages just as vulnerable to all kinds of cross-site scripting (XSS) attacks and the like as they would be by accepting input from a web form. (I think someone recently posted this link in another thread: http://phpsec.org/projects/guide/ ) So yes, if you don't use diligence to filter that stuff out before you send it to the browser, someone could study your mail interface well enough to do anything they want by impersonating the user viewing the messages -- just for starters. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL Identifying worst-performing codes
Hello friends, There is a tool call idera (SQL diagnostic manager). Basically it is a performance monitoring and diagnostics tool. It has a feature; Identifying of worst-performing codes - Identifies performance bottlenecks such as the worst-performing stored procedures, long-running queries, most frequently run queries, SQL Statements and SQL batches http://www.idera.com/Products/SQLdm/Features.aspx I'm looking for a same like tool for MySQL. Is anyone have any ideas. Thanks in advance, Best Regards, Lasitha DOTW DISCLAIMER: This e-mail and any attachments are strictly confidential and intended for the addressee only. If you are not the named addressee you must not disclose, copy or take any action in reliance of this transmission and you should notify us as soon as possible. If you have received it in error, please contact the message sender immediately. This e-mail and any attachments are believed to be free from viruses but it is your responsibility to carry out all necessary virus checks and DOTW accepts no liability in connection therewith. This e-mail and all other electronic (including voice) communications from the sender's company are for informational purposes only. No such communication is intended by the sender to constitute either an electronic record or an electronic signature or to constitute any agreement by the sender to conduct a transaction by electronic means. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session_start is slow occasionally
Hi i have a site that is relatively high loaded (~20 reloads/sec) and i am trying to optimize it. So i have started timing sections of the php scripts to find out which is the slowest so i optimize it first. I write the times to a database( timings are done on the live server). So now when a user reloads the page (timings are set on only one of the pages) i write to the database how long it took and how long different sections take. That way i noticed thar occasionally that page takes extremely long to generate (there are occasions of 300sec), but generally it takes between 0.05 and 0.2 sec to generate. I started moving the sections to determine where the problem lies and it turned out that these three lines take that long from time to time: ini_set(session.gc_maxlifetime, 2400); session_name('x'); session_start(); I measured each of them and seems that session_start is the problem(had a few ~11 sec loads, but not something this big yet, of which ~10.5 is taking session_start) Does anyone know what is going on? Sessions are stored in /tmp/sessions/ which is 100MB ram drive and at the moment when this occurs it was ~68% used with ~12000 files in it. And i have one more question. How does apache handle high loads? Does it suspend the php script when there are no resources and resume it when it frees some, or it doesn't pick it up at all? Thank you - Pinpoint customers who are looking for what you sell.
RE: [PHP] MySQL Identifying worst-performing codes
[snip] There is a tool call idera (SQL diagnostic manager). Basically it is a performance monitoring and diagnostics tool. It has a feature; Identifying of worst-performing codes - Identifies performance bottlenecks such as the worst-performing stored procedures, long-running queries, most frequently run queries, SQL Statements and SQL batches http://www.idera.com/Products/SQLdm/Features.aspx I'm looking for a same like tool for MySQL. Is anyone have any ideas. [/snip] Have you thought about asking this on the MySQL list? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Karma Rating the new way of rating anything? Your opinion on this please.
Hey, i just made a post on digg: http://digg.com/programming/Karma_Rating_the_new_way_of_rating_anything which links to this: http://magedb.wordpress.com/2007/10/04/karma-rating-new-type-of-rating/ (feel free to click the links) It's about a new rating method that i just made up that might have alot potential. but that's where i want your opinion. So what do you guys think on of this idea? Posted in on this list because it's gonna be written in PHP. Thanx, Mark. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] socket_read() hangs with FTP
Hello. I'm tried an example from PHP manual with simple TCP/IP Client. I'm create a socket to FTP server, then read data from socket [PHP] while ($out = socket_read($socket, 2048)) { echo $out; } [/PHP] when all data are read, socket_read() don't return an empty string, it's hangs. Can you tell me, how to write work with it? Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with eAccelerator 0.9.5.2
Hi, I am new to eAccelerator... when I use purge or clean the apache error log says: * File does not exist: /var/www/PHPE6F78DE9-13E4-4dee-8518-5FA2DACEA803, referer: https://pitufina/eaccelerator.php * It does everytime I use eaccelerator_purge() or eaccelerator_clean() ... The error is always the same. Does anyone have any clue on why is this? My eAccelerator config is as follow: extension=eaccelerator.so eaccelerator.shm_size=16 eaccelerator.cache_dir=/tmp/eaccelerator eaccelerator.enable=1 eaccelerator.optimizer=1 eaccelerator.check_mtime=1 eaccelerator.debug=0 eaccelerator.filter= eaccelerator.shm_max=0 eaccelerator.shm_ttl=0 eaccelerator.shm_prune_period=0 eaccelerator.shm_only=0 eaccelerator.compress=1 eaccelerator.compress_level=9 eaccelerator.allowed_admin_path=/var/www -- I am in a closed security enviroment so do not complain about admin privileges to all root The command php -v returns: PHP 5.2.3-1+b1 (cli) (built: Jun 21 2007 20:58:46) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator with Xdebug v2.0.0, Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, by Derick Rethans Thanks... -- .---. | Miguel J. Jiménez | | Programador Senior| | Área de Internet | | [EMAIL PROTECTED]| :---: | ISOTROL, S.A. | | Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta. | | Parque Tecnológico Cartuja '93, 41092 Sevilla (ESP). | | Teléfono: +34 955 036 800 (ext.1805) - Fax: +34 955 036 849 | | http://www.isotrol.com| :---: | Una bandera une a los habitantes de un pais bajo unos ideales| | comunes y es por eso por lo que todos ellos deben aceptarlos de | | buena gana y no ser forzados a ello pues entonces dicha bandera | | no serviría de nada. - Emperador Ming, Flash Gordon (1x07)(2007) | '---' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Super bizarre changing variable!!
I'm running the following code: $query3 = DELETE FROM table1 WHERE referer=$referer ORDER BY creation LIMIT $numtodelete; $result3 = mysql_query($query3); $string = $total found, $n kept, $numtodelete extras removed ($query3); $x = mysql_query(insert into table2 (friend_id,data) values ($referer,'$string')); I created the table2 log file just so I could see what the hell is going on. Here is a typical entry in table2: FRIEND_ID = 8388607 DATA = 908 found, 100 kept, 808 extras removed (DELETE FROM table1 WHERE referer=69833818 ORDER BY creation LIMIT 808) Notice that the value in FRIEND_ID, which was set with $referer, is DIFFERENT than the value of $referer shown in DATA! How the flying f*^%k is this possible??? I've been tearing my hair out for 3 days over this. Almost all records show 8388607 in that FRIEND_ID field. Once in a blue moon, a different value is shown, which does match the value in DATA. So it's displaying this erroneous behavior 95% of the time but not always. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] http://go-pear.org?
I'm trying to install Pear on OSX, but http://go-pear.org/ doesn't seem to be resolving. Pear manual states I should: curl http://go-pear.org/ | php but this fails and dig go-pear.org reveals that the name does not resolve. Is there a package somewehre I can download and install? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ssl in socket functions
Hello guys, I have one small question and would greatly appreciate if you resolve it. Can I create ssl connection through the socket functions (not fsockopen)? Thanking in advance, Sergey Ignatenko. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Super bizarre changing variable!!
Brian Dunning wrote: I'm running the following code: $query3 = DELETE FROM table1 WHERE referer=$referer ORDER BY creation LIMIT $numtodelete; $result3 = mysql_query($query3); $string = $total found, $n kept, $numtodelete extras removed ($query3); $x = mysql_query(insert into table2 (friend_id,data) values ($referer,'$string')); I created the table2 log file just so I could see what the hell is going on. Here is a typical entry in table2: FRIEND_ID = 8388607 DATA = 908 found, 100 kept, 808 extras removed (DELETE FROM table1 WHERE referer=69833818 ORDER BY creation LIMIT 808) Notice that the value in FRIEND_ID, which was set with $referer, is DIFFERENT than the value of $referer shown in DATA! How the flying f*^%k is this possible??? I've been tearing my hair out for 3 days over this. Almost all records show 8388607 in that FRIEND_ID field. Once in a blue moon, a different value is shown, which does match the value in DATA. So it's displaying this erroneous behavior 95% of the time but not always. I've been trying to follow your code here but the results you are showing are in no way related to queries you are running. You've said FRIEND_ID = 8388607, but all you are saying here is that you've picked a random row from your table2 and it's not the same as the referer in your $string value this could easily be the case. You should echo out both $query3 and string and the other query you run inline and compare these three values for inconsistencies... PS I really home the value stored in $referer has already been properly escaped with e.g. mysql_real_escape_string. Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] inserting ´ in a db
You need to escape the single quote, an easy way to do this is to run the text thru the addslashes() filter. Obviously you can't run your entire query thru the filter thru the filter because most of your quotes need to be identified by the db. Here is what I do. $query = insert table1(col1, col2, col3) values( .sprintf(%01d,$intval)., \.addslashes($stringvalue).\, ._CONSTANTINTVALUE.) ; Addslashes makes other troublesome values become harmless as well and can be used to prevent SQL injection hacks. If someone injects a SQL query into your data it will not be processed, but will be stored in the DB string variable. Course in this case you need to be careful that if you copy the table contents you don't then execute the imbedded query. Hope this helps, Warren Vail -Original Message- From: Yamil Ortega [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 03, 2007 7:45 PM To: php-general@lists.php.net Subject: [PHP] inserting ´ in a db Hi list, good day. I have a simple script that inserts text on a mysql table, that has a field named description and the type is text. Everting works fine, except when I try to insert a text that includes a simple quote. For example Yamil´s car I send the character string to a variable and then insert into a query. But the mysql says that something is wrong with the query because the quote after the l looks like the end of the string, and s car doesn`t look like a valid part of the query. Can anyone help me out, how to handle this error? Thanks Yamil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with eAccelerator 0.9.5.2
I would check for an eaccelerator mailing list. Personally I never use the web interface. Cheers, Rob. On Thu, 2007-10-04 at 17:29 +0200, Miguel J. Jiménez wrote: Hi, I am new to eAccelerator... when I use purge or clean the apache error log says: * File does not exist: /var/www/PHPE6F78DE9-13E4-4dee-8518-5FA2DACEA803, referer: https://pitufina/eaccelerator.php * It does everytime I use eaccelerator_purge() or eaccelerator_clean() ... The error is always the same. Does anyone have any clue on why is this? My eAccelerator config is as follow: extension=eaccelerator.so eaccelerator.shm_size=16 eaccelerator.cache_dir=/tmp/eaccelerator eaccelerator.enable=1 eaccelerator.optimizer=1 eaccelerator.check_mtime=1 eaccelerator.debug=0 eaccelerator.filter= eaccelerator.shm_max=0 eaccelerator.shm_ttl=0 eaccelerator.shm_prune_period=0 eaccelerator.shm_only=0 eaccelerator.compress=1 eaccelerator.compress_level=9 eaccelerator.allowed_admin_path=/var/www -- I am in a closed security enviroment so do not complain about admin privileges to all root The command php -v returns: PHP 5.2.3-1+b1 (cli) (built: Jun 21 2007 20:58:46) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator with Xdebug v2.0.0, Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, by Derick Rethans Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] inserting ´ in a db
On Thu, 2007-10-04 at 10:18 -0700, Warren Vail wrote: You need to escape the single quote, an easy way to do this is to run the text thru the addslashes() filter. Obviously you can't run your entire query thru the filter thru the filter because most of your quotes need to be identified by the db. Here is what I do. $query = insert table1(col1, col2, col3) values( .sprintf(%01d,$intval)., \.addslashes($stringvalue).\, ._CONSTANTINTVALUE.) ; Addslashes makes other troublesome values become harmless as well and can be used to prevent SQL injection hacks. If someone injects a SQL query into your data it will not be processed, but will be stored in the DB string variable. Course in this case you need to be careful that if you copy the table contents you don't then execute the imbedded query. AddSlashes() is crap. You have a security hole due to using the improper escape mechanism for your database. USE THE CORRECT ESCAPE MECHANISM FOR YOU DATABASE! Do not ever advocate use of the addSlashes() function for database queries unless it is the ONLY option available. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Super bizarre changing variable!!
$referer is always an integer, 6 to 10 digits long. To clarify: the value of $referer is changing between line 1, where $query3 is being set, and line 4, where it's being written into my debugging log table2. I can't see any way that $referer could be different in those two places. On Oct 4, 2007, at 9:10 AM, Colin Guthrie wrote: Brian Dunning wrote: I'm running the following code: $query3 = DELETE FROM table1 WHERE referer=$referer ORDER BY creation LIMIT $numtodelete; $result3 = mysql_query($query3); $string = $total found, $n kept, $numtodelete extras removed ($query3); $x = mysql_query(insert into table2 (friend_id,data) values ($referer,'$string')); I created the table2 log file just so I could see what the hell is going on. Here is a typical entry in table2: FRIEND_ID = 8388607 DATA = 908 found, 100 kept, 808 extras removed (DELETE FROM table1 WHERE referer=69833818 ORDER BY creation LIMIT 808) Notice that the value in FRIEND_ID, which was set with $referer, is DIFFERENT than the value of $referer shown in DATA! How the flying f*^%k is this possible??? I've been tearing my hair out for 3 days over this. Almost all records show 8388607 in that FRIEND_ID field. Once in a blue moon, a different value is shown, which does match the value in DATA. So it's displaying this erroneous behavior 95% of the time but not always. I've been trying to follow your code here but the results you are showing are in no way related to queries you are running. You've said FRIEND_ID = 8388607, but all you are saying here is that you've picked a random row from your table2 and it's not the same as the referer in your $string value this could easily be the case. You should echo out both $query3 and string and the other query you run inline and compare these three values for inconsistencies... PS I really home the value stored in $referer has already been properly escaped with e.g. mysql_real_escape_string. Col -- 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] Re: MySQL Identifying worst-performing codes
Lasitha Alawatta wrote: There is a tool call “idera” (SQL diagnostic manager). Basically it is a performance monitoring and diagnostics tool. It has a feature; Identifying of worst-performing codes – Identifies performance bottlenecks such as the worst-performing stored procedures, long-running queries, most frequently run queries, SQL Statements and SQL batches You can just turn on the MySQL option log slow queries and it logs them for you. Make those more efficient and you've already taken care of a lot of the low hanging fruit for db optimisation. Col. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] inserting ´ in a db
Rob, Your opinion would have meant more had you offered a solution. The only hole that I am aware of is the likelihood that the imbedded query could get executed accidentally later. If the database is mysql, there is finally a mysql function for filtering and mysql_real_escape_string(), if I am not mistaken, should render attempts to store SQL in the database harmless. For other databases, you should look for something specific, but for the problem you described, addslashes() should work just fine. http://dev.mysql.com/tech-resources/articles/guide-to-php-security-ch3.pdf Warren -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, October 04, 2007 10:28 AM To: Warren Vail Cc: 'Yamil Ortega'; php-general@lists.php.net Subject: RE: [PHP] inserting ´ in a db On Thu, 2007-10-04 at 10:18 -0700, Warren Vail wrote: You need to escape the single quote, an easy way to do this is to run the text thru the addslashes() filter. Obviously you can't run your entire query thru the filter thru the filter because most of your quotes need to be identified by the db. Here is what I do. $query = insert table1(col1, col2, col3) values( .sprintf(%01d,$intval)., \.addslashes($stringvalue).\, ._CONSTANTINTVALUE.) ; Addslashes makes other troublesome values become harmless as well and can be used to prevent SQL injection hacks. If someone injects a SQL query into your data it will not be processed, but will be stored in the DB string variable. Course in this case you need to be careful that if you copy the table contents you don't then execute the imbedded query. AddSlashes() is crap. You have a security hole due to using the improper escape mechanism for your database. USE THE CORRECT ESCAPE MECHANISM FOR YOU DATABASE! Do not ever advocate use of the addSlashes() function for database queries unless it is the ONLY option available. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- 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] inserting ´ in a db
On Thu, 2007-10-04 at 10:55 -0700, Warren Vail wrote: Rob, Your opinion would have meant more had you offered a solution. The only hole that I am aware of is the likelihood that the imbedded query could get executed accidentally later. If the database is mysql, there is finally a mysql function for filtering and mysql_real_escape_string(), if I am not mistaken, should render attempts to store SQL in the database harmless. For other databases, you should look for something specific, but for the problem you described, addslashes() should work just fine. http://dev.mysql.com/tech-resources/articles/guide-to-php-security-ch3.pdf Sorry... http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Super bizarre changing variable!!
Hi Brian, Thursday, October 4, 2007, 4:50:09 PM, you wrote: I'm running the following code: $query3 = DELETE FROM table1 WHERE referer=$referer ORDER BY creation LIMIT $numtodelete; $result3 = mysql_query($query3); $string = $total found, $n kept, $numtodelete extras removed ($query3); $x = mysql_query(insert into table2 (friend_id,data) values ($referer,'$string')); I created the table2 log file just so I could see what the hell is going on. Here is a typical entry in table2: FRIEND_ID = 8388607 DATA = 908 found, 100 kept, 808 extras removed (DELETE FROM table1 WHERE referer=69833818 ORDER BY creation LIMIT 808) Notice that the value in FRIEND_ID, which was set with $referer, is DIFFERENT than the value of $referer shown in DATA! How the flying f*^%k is this possible??? I've been tearing my hair out for 3 days over this. Almost all records show 8388607 in that FRIEND_ID field. Once in a blue moon, a different value is shown, which does match the value in DATA. So it's displaying this erroneous behavior 95% of the time but not always. What data type do the referer / friend_id columns have in MySQL? int? tinyint? etc Also show all of your code - there is no way that the value changes between lines 1 and 4 in the code above, which means you've missed something out (probably for post brevitys sake) Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Super bizarre changing variable!!
Brian Dunning wrote: I'm running the following code: $query3 = DELETE FROM table1 WHERE referer=$referer ORDER BY creation LIMIT $numtodelete; $result3 = mysql_query($query3); $string = $total found, $n kept, $numtodelete extras removed ($query3); $x = mysql_query(insert into table2 (friend_id,data) values ($referer,'$string')); I created the table2 log file just so I could see what the hell is going on. Here is a typical entry in table2: FRIEND_ID = 8388607 DATA = 908 found, 100 kept, 808 extras removed (DELETE FROM table1 WHERE referer=69833818 ORDER BY creation LIMIT 808) Notice that the value in FRIEND_ID, which was set with $referer, is DIFFERENT than the value of $referer shown in DATA! How the flying f*^%k is this possible??? I've been tearing my hair out for 3 days over this. Almost all records show 8388607 in that FRIEND_ID field. Once in a blue moon, a different value is shown, which does match the value in DATA. So it's displaying this erroneous behavior 95% of the time but not always. Sorry, I reread it and what you say makes sense now I am tired!! OK, I give. It's odd and confusing :) Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows
This was a joke right? You don't seriously do this in r.l. just to alternate row colors I hope? -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 03, 2007 6:36 PM To: Jim Lucas Cc: Steve Marquez; PHP eMail List Subject: Re: [PHP] Alternate Colors in Rows In the following example I show a simple OOP example (because I felt like it) and illustrate why using CSS classes is the most powerful way to do row style cycling. Hopefully you're using a decent browser (almost anything other than IE -- I recommend Opera :) but if not then IE7 will suffice to illustrate hover properly (finally). ?php class SillyCycle { var $period = 2; var $index = -1; function SillyCycle( $period=2 ) { $this-period = (int)$period; $this-reset(); } function reset() { $this-index = -1; } function getIndex() { if( $this-period ) { return ($this-index = (++$this-index % $this-period)) + 1; } return 1; } } $cycle = new SillyCycle(); ? html head style table.example { border: solid 1px #44; } table.example th, table.example td { padding: 2px 4px 2px 4px; text-align: center; } table.example th { background: #d8d8d8; } table.example tr.cycle_1 td { background: #e8e8e8; } table.example tr.cycle_2 td { background: #e0e0e0; } table.example tr.cycle_1:hover td { background: #e8; } table.example tr.cycle_2:hover td { background: #e0; } /style /head body table class=example cellspacing=1 tr thCol 1/th thCol 2/th thCol 3/th /tr ?php for( $i = 1; $i = 50; $i++ ) { ? tr class=cycle_?php echo $cycle-getIndex() ? td?php echo $i ?/td td:)/td td;)/td /tr ?php } ? /table /body /html -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- 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] Re: Super bizarre changing variable!!
Brian Dunning wrote: I'm running the following code: $query3 = DELETE FROM table1 WHERE referer=$referer ORDER BY creation LIMIT $numtodelete; $result3 = mysql_query($query3); $string = $total found, $n kept, $numtodelete extras removed ($query3); $x = mysql_query(insert into table2 (friend_id,data) values ($referer,'$string')); I created the table2 log file just so I could see what the hell is going on. Here is a typical entry in table2: FRIEND_ID = 8388607 DATA = 908 found, 100 kept, 808 extras removed (DELETE FROM table1 WHERE referer=69833818 ORDER BY creation LIMIT 808) Notice that the value in FRIEND_ID, which was set with $referer, is DIFFERENT than the value of $referer shown in DATA! How the flying f*^%k is this possible??? I've been tearing my hair out for 3 days over this. Almost all records show 8388607 in that FRIEND_ID field. Once in a blue moon, a different value is shown, which does match the value in DATA. So it's displaying this erroneous behavior 95% of the time but not always. Sorry, I reread it and what you say makes sense now I am tired!! OK, I give. It's odd and confusing :) Col Are you showing us the real code? (I only came in on this post) From your posted code, I think your DATA value should be the literal 7 characters $string. _ Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare! http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews
[PHP] Generating PDF files (XSLT, ps, XSL-FO, FOP, etc)
Hello, I'm currently researching a bit on a possible PDF export format for some of my application's output. So far, what I get is this: - some packages allow PDF generation (FPDF, EZPDF, etc) from nothing - some packages allow generation of PDF from HTML, using the ps format - some packages allow generation of PDF from XML, using XSL-FO and FOP Somehow, I'm having difficulties understanding why you can make a PDF out of nothing (using only a set of PHP classes) but you can't generate a PDF using XML and XSLT, although XSLT is, to my understanding, made to enable export in various formats from the same XML file. It seems that in this case (exporting from XML to PDF), you need to first convert the XML to a XSL-FO format (using XSLT) and then convert that XSL-FO format into PDF, and the only way to do that last step at the moment seems to be to use Apache's FOP project, which requires Java and a server-side component that you are unlikely to be authorized to install on a low-cost hosting server. Does anybody have a good insight on all this and could tell me what's wrong and why there seems to be a missing link between XML and PDF...? Thanks in advance, Yannick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows
On Thu, 2007-10-04 at 12:28 -0700, Daevid Vincent wrote: This was a joke right? You don't seriously do this in r.l. just to alternate row colors I hope? This certainly was NOT a joke. I do use CSS classes. As for using a PHP class to implement the cycle-- No, I don't do that IRL. As I said in my post: I show a simple OOP example (because I felt like it) There's nothing wrong with using a class though. Some people like that kind of encapsulation. If you're hung up on the use of CSS classes to do something simple. Imagine a site with hundreds of pages, many of which contain tables with alternating row styling. By using classes, I've ensured a single location to update the way my rows are presented across the entire site. I don't need to touch the markup or code to change how they look. This is how separation of markup and styling is supposed to work. If you didn't know that then you may need to go read about CSS. If you thought you knew about CSS and still disagree, then you need to go reread about CSS because you didn't absorb it properly the first time. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows
You can choose to view source with IE in other editors too. I use Editplus with IE7. berber -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, October 04, 2007 2:50 PM To: Nathan Nobbe Cc: Jim Lucas; Steve Marquez; PHP eMail List Subject: Re: [PHP] Alternate Colors in Rows On Wed, 2007-10-03 at 22:12 -0400, Nathan Nobbe wrote: On 10/3/07, Robert Cummings [EMAIL PROTECTED] wrote: Hopefully you're using a decent browser (almost anything other than IE -- I recommend Opera :) opera is the best for straight browsing. ive found i could have 40 to 50 tabs open with no noticeable perforrmace hit. firefox bogs badly after about 20 tabs and i find some of the features arent as smart as opera. sadly though i think firefox is the best for development. web developer and firebug are 2 priceless tools for development. plus the view source on firefox is much better than other browsers. Opera let's you define what you use to view source. I use my editor joe and so it's all nice and highlighted. I view source in the same way I edit HTML. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- 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] Alternate Colors in Rows
My comment was not about the CSS -- if you saw my earlier post, I actually told the OP to never hardcode color/style if possible: -Original Message- Sent: Wednesday, October 03, 2007 12:58 PM Add this to your default.css file... Or to the page... style TR.dataRow1 { background-color: #e8f5f7; } /* light */ TR.dataRow2 { background-color: #dce8ea; } /* dark */ /style Then just do this: TR class='?= ($r = !$r) ? dataRow1 : dataRow2 ?' Forget all that $i++ and (mod) % stuff... And NEVER hardcode the colors in the page. Use CSS ! What I was shocked at was the use of a class to do what takes not even an entire line of code to accomplish. You realize that the object-oriented-ness (word?) and the overhead of a class is silly right? Even calling a function is slow. Something like alternating table rows generally is used when you have lots of tabular data to show, therefore shaving off a few microseconds here and there actually adds up. We have pages that render thousands of rows, and if it takes 2 or 3 seconds less to show, that is significant and noticeable. I'm sure you were just trying to be funny or illustrate a point, but what concerns me is that some people take OO WAY too far -- Ruby is an example. Sometimes it is NOT the best way to implement something and is actually detrimental. Since the OP seemed sorta newb, I fear that he would be learning bad habits and not get that you were being facetious about the PHP example... Anyways, this is a dead horse. D.Vin http://daevid.com -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, October 04, 2007 1:04 PM To: Daevid Vincent Cc: 'PHP eMail List' Subject: RE: [PHP] Alternate Colors in Rows On Thu, 2007-10-04 at 12:28 -0700, Daevid Vincent wrote: This was a joke right? You don't seriously do this in r.l. just to alternate row colors I hope? This certainly was NOT a joke. I do use CSS classes. As for using a PHP class to implement the cycle-- No, I don't do that IRL. As I said in my post: I show a simple OOP example (because I felt like it) There's nothing wrong with using a class though. Some people like that kind of encapsulation. If you're hung up on the use of CSS classes to do something simple. Imagine a site with hundreds of pages, many of which contain tables with alternating row styling. By using classes, I've ensured a single location to update the way my rows are presented across the entire site. I don't need to touch the markup or code to change how they look. This is how separation of markup and styling is supposed to work. If you didn't know that then you may need to go read about CSS. If you thought you knew about CSS and still disagree, then you need to go reread about CSS because you didn't absorb it properly the first time. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading files from Win 2003 Server
Hi, I have a script located on an Ubuntu box and I am trying to read files located on a Win 2003 Server. I have 'mounted', if that's the right term to use, a connection from Ubuntu to Server 2003 and can read the files fine via the desktop, etc. If the Win Server name is say 'WinServer' and the shared directory I want to read from on it is called say 'SharedDirectory' and the user name is 'User', I notice the reference to that folder on the Ubuntu desktop is as follows: smb://[EMAIL PROTECTED]/SharedDirectory But I am at a loss as to how I should refer to the path for this connection within my PHP script. Any help would be most appreciated. If it's any additional help, I would be using the connection to read files only, and not add/edit/delete them. Thanks Alexis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Alternate Colors in Rows
On Thu, 2007-10-04 at 22:14 +0200, WeberSites LTD wrote: You can choose to view source with IE in other editors too. I use Editplus with IE7. That wasn't the reason I pimped Opera though. I would NEVER use IEX as my development browser. I do all my HTML for Opera, then I check it in Firefox, then I check it in IE and tweak as necessary. IE is crap. It still doesn't support many of the useful features of CSS and often when it does, they don't work according to standard. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?
left join where item in right table is null "Chris" [EMAIL PROTECTED] 10/3/2007 10:32:01 PM Aleksandar Vojnovic wrote: I would also suggest to limit yourself to things you actually need not to select the whole table.In this case you can't because you're looking for records that exist in one table that don't exist in another.Apart from looking at the whole table in each case how else would you do that?-- Postgresql php tutorialshttp://www.designmagick.com/-- PHP General Mailing List (http://www.php.net/)To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Super bizarre changing variable!!
Richard Davey wrote: What data type do the referer / friend_id columns have in MySQL? int? tinyint? etc Ahh of course. That'll be it. The different tables will have different definitions of the friend_id field and one will be overflowing! Well spotted Richard wood for the trees for me today! Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: http://go-pear.org?
Steve Brown wrote: I'm trying to install Pear on OSX, but http://go-pear.org/ doesn't seem to be resolving. Pear manual states I should: curl http://go-pear.org/ | php but this fails and dig go-pear.org reveals that the name does not resolve. Is there a package somewehre I can download and install? If you're using PHP 5.1.0 or newer, grab http://pear.php.net/go-pear.phar Otherwise use http://peear.php.net/go-pear The best list for general PEAR questions is [EMAIL PROTECTED] Thanks, Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Core dumps with --with-openssl
I just tried rebuilding my apache php to the latest version and now whenever I try to start it it core dumps. If I remove the --with-openssl and build with 4.4.6 of php at least it starts. I can't even get my old version to build now... Is there a work-around for this? The setup is as follows: apache 1.3.39 php 4.4.7 openssl 0.9.8e FreeBSD 6.1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any known security issues with IMAP?
Andrew Ballard wrote: On 10/4/07, Chris [EMAIL PROTECTED] wrote: Don O'Neil wrote: I'm not sure how opening an email inbox can hijack pages but maybe someone more creative than I can show me.. I don't know about the IMAP/POP3 itself, but if you are displaying the messages in a web browser for something like building your own web-mail client, the messages themselves would make YOUR pages just as vulnerable to all kinds of cross-site scripting (XSS) attacks and the like as they would be by accepting input from a web form. (I think someone recently posted this link in another thread: http://phpsec.org/projects/guide/ ) So yes, if you don't use diligence to filter that stuff out before you send it to the browser, someone could study your mail interface well enough to do anything they want by impersonating the user viewing the messages -- just for starters. Good point - I should have been more explicit. I was thinking more about processing messages and doing something with the content rather than displaying them in any way. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?
John A DAVIS wrote: left join where item in right table is null That's still going to look at all records in both tables: 1) so it can work out if there is a match from table 1 to table 2 2) so it can then remember to display any records that don't have a match I was thinking more that if you have something like this: select * from table1 where id not in (select id from table2); The db might take that and turn it into: select * from table1 where id not in (id1,id2,id3); But it doesn't really matter. Either way you end up with full table or index scans (depending on the db and engine you are using if mysql) of both table1 and table2. myisam tables might just be able to use an index to do this sort of work, innodb will have to do a table scan because it's mvcc (as will postgres and others). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A two flavored post
Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? TIA for any replies. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session_start is slow occasionally
al jo wrote: Hi i have a site that is relatively high loaded (~20 reloads/sec) and i am trying to optimize it. So i have started timing sections of the php scripts to find out which is the slowest so i optimize it first. I write the times to a database( timings are done on the live server). So now when a user reloads the page (timings are set on only one of the pages) i write to the database how long it took and how long different sections take. That way i noticed thar occasionally that page takes extremely long to generate (there are occasions of 300sec), but generally it takes between 0.05 and 0.2 sec to generate. I started moving the sections to determine where the problem lies and it turned out that these three lines take that long from time to time: ini_set(session.gc_maxlifetime, 2400); session_name('x'); session_start(); I measured each of them and seems that session_start is the problem(had a few ~11 sec loads, but not something this big yet, of which ~10.5 is taking session_start) Does anyone know what is going on? Sessions are stored in /tmp/sessions/ which is 100MB ram drive and at the moment when this occurs it was ~68% used with ~12000 files in it. My suggestion is check the php source for what session_start does. Maybe it scans the directory to make sure it's going to generate a unique id and even though it's on a ram drive it's taking a while because of the number of files already there. That's just a completely wild guess though ;) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On Thu, 2007-10-04 at 22:33 -0400, tedd wrote: Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? Use an onclick= event handler. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A two flavored post
On 10/4/07, tedd [EMAIL PROTECTED] wrote: Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? the question is when is the variable you want to append available to the javascript. as soon as you get the variable in the javascript the next thing you can do is append it to the value of the href attribute of the a tag. html head script type=text/javascript window.onload = function() { var someLinkHref = document.getElementById('someLink').href; someLinkHref += anotherVar=8; alert(someLinkHref); } /script /head body a id=someLink href=http://somesite.com?a=5; click here /a /body /html if you want to use the onclick event handler as rob suggested, you could stash the variable in the Window global object, then reference it in the implementation of the onclick function (though i still have mixed feelings about that approach [the Window object part that is]). -nathan -nathan
Re: [PHP] A two flavored post
A simple example would be a href=img.php?s=?php echo($value);? onclick=this.href += 'othervalue=x';Click here/a On 10/4/07, Robert Cummings [EMAIL PROTECTED] wrote: On Thu, 2007-10-04 at 22:33 -0400, tedd wrote: Hi gang: I asked this question on the javascript list, but for some reason it's taking forever to post there. So, I figured that I would ask here as well. I'm currently sending data (the value of s) to another script via the html statement: a href=img.php?s=?php echo($value);?Click here/a However, I need to add another variable, namely a javascript variable, to the GET string. How can I send both a php and a javascript variable together at the same time? Use an onclick= event handler. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- 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] error messages
Hi I'm a newbie to php and i would like to know a way of viewing runtime errors on the browser. Currently when an error occurs nothing is displayed on the browser. Is there any way of viewing all error messages on the browser itself. Thanks -- View this message in context: http://www.nabble.com/error-messages-tf4573258.html#a13053817 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error messages
On Thu, 2007-10-04 at 22:38 -0700, tbt wrote: I'm a newbie to php and i would like to know a way of viewing runtime errors on the browser. Currently when an error occurs nothing is displayed on the browser. Is there any way of viewing all error messages on the browser itself. You can up the error_reporting level in your php.ini, or you can simply put the following line at the top of your script: ini_set(error_reporting, E_ALL); or for an even stricter setting: ini_set(error_reporting, E_STRICT); --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php