Re: [PHP] Pear Pager
weetat wrote: Hi all , Thanks all in this newsgroup for your help. I have question regarding PEAR Pager . http://pear.php.net/support/lists.php -- 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] php sessions and Google
On 6/7/06, tedd [EMAIL PROTECTED] wrote: Can someone shed some light on this for me? How can one do sessions and make Google bots happy? I think what they're getting at is don't use session id's unless they're logged in. -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file from database work local, but not on server
Thank you for pointing out the security issue, I am aware of that. Was sloppy not to use %d instead of %s as I did. The database is exactly the same, and the data is correct in $Row['filename']. I did create a copy and put it onto an other server, and there it worked ok. Some files did work well, while others did not work at all. Is there anyone with reference of a small example of binary storage and retrieval from database? I have performed working solutions for images before, but this should support any file extensions (with exceptions of course). Best regards, Peter Lauri -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Thursday, June 08, 2006 8:00 AM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] file from database work local, but not on server Peter Lauri wrote: Best group member, This code works fine on my local machine: $Query = sprintf(SELECT * FROM filestorage WHERE id=%s LIMIT 1, $_GET['fileid']); $Result = mysql_query($Query); if (mysql_num_rows ($Result)0) { $Row = @mysql_fetch_array ($Result); $file_type = $Row[filetype]; $file = $Row[filedata]; header (Content-type: $file_type); header(Content-Disposition: attachment; filename=fil.substr($Row['filename'], strrpos($Row['filename'], '.'))); '.')).' print $file; } But when I run it on my server it does not start the download, and the file name is the location of the script instead of what I state as file name. The first thing you should do is read this site: http://www.phpsec.org I could pass all sorts of bad things to $_GET['fileid'] and it will ruin your database. At least make it: (int)$_GET['fileid']; so if it's non-numeric, it will get converted to 0. Can we assume the database is exactly the same and it's not that $row['filename'] has the wrong data in it? -- 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] File downloads
Thanks to Tedd, Barry, George and others for help over download file problem. I'm going to receive an ACK if the file downloads correctly. In absence of such an ACK, a script would quitely remove the temporary files after a fixed interval of time. Temporary files have unique filenames. New problem: Is there a way for the server to notify the client that a new file has become available for download, provided the client was online in the past X minutes? This could be done if 1. The client queries the server after a set interval of time. I DO NOT WANT THIS FOR SOME SILLY REASON. 2. The connection is kept alive (?). With my current knowledge of PHP, I am not able to manage this. Cookies or sessions? Can't find a related example directly dealing with this issue. All wild ideas/links/examples are welcome. What changes would be required in Apache conf file (if any)? Thanks Regards KM On 6/7/06, tedd [EMAIL PROTECTED] wrote: At 8:42 AM + 6/7/06, kartikay malhotra wrote: Dear All, I have a HTTP server + MySQL database. Everytime a file is requested for download, my PHP script loads the content from the database into a temporary file (on the server). I then pass a URL to the client, with a link to this file. The client can thus download the file at any time. However, I can foresee many problems with this approach. One is, when to delete the temporary file? Also with more than one client, this approach would have to be refined. Security is also an issue: One user may read another's files. Can anyone kindly give me an alternative approach? I reiterate, I cannot supply static URLs as the downloadable file is generated on-demand. Thanks Regards KM KM: Thinking off the top of my head (not always the best for me) -- why not give the user a static url AND a key? The static url would have a php program sitting there waiting for a user to come along and provide the correct key. After which, your program would then create the file (in a random named folder); provide the user with a link; and clean-up after he's done. That way you have the control over what's happening. The key approach handles security and when to clean-up. hth's 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] Re: php java intregration
hi, i have not tried it in linux, but the stuff worked for me in windows, here are my notes: * PHP 5.1.4 * PECL 5.1.4 (use php_java.dll and php_java.jar from the zip file, this is an extra download) here is my php.ini ; configuration to enable php_java.dll [Java] extension=php_java.dll java.class.path = C:\PHP\ext\php_java.jar java.home = C:\Java\jdk1.5.0_06 java.library = C:\Java\jdk1.5.0_06\jre\bin\server\jvm.dll java.library.path = C:\PHP\ext you will need to append more paths to java.class.path directive if you use any extra jars in you application. the extension works fine except its kinda slow on my server - i am yet to find out why... let me know if its any better for you. thanks, vedanta On 6/8/06, Lalit Khairnar [EMAIL PROTECTED] wrote: Hi Vedanta We re also trying to use Bridge for the same. but we are stucked while configuring the .jar file on WINDOWS could u please send us the procedure to do in perfect way We are using Xampp installer and php 5.1.1 ,apache , and jdk 1.5 please reply soon -- Lalit P.Khairnar V2Solutions A New Vision to Solution Cell:09969131384 India:+91-22-56733201 Ext:642 / 643 US:1-408-253-2838 http://www.v2solutions.com -- *~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~* Vedanta Barooah YM! - vedanta2006 Skype - vedanta2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Restrict uploaded scripts
Hi! I'm trying to create a CMS where it should be posible to upload script modules. Those modules should mostly be made by myself, but it is posible for others to create scripts too. My question is, is it posible to restrict the modules to their own directory so they don't overwrite some of the other modules or the CMS itself? The php scripts should prefeable be used through require or similar, not by a direct web request to the script. Mathias Bundgaard Svensson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Gzinflate on a string that has been base_64 encoded in Windows
Greetings! I have a long piece of string that is apparently a PNG image which has been base_64 decoded in an XML file. I can retreive this string without problem. The string is in $mystra $pngdata = base64_decode($mystra); $pngdata = gzinflate($pngdata); When i try to gzinflate it , i get a warning that says data error and if i write pngdata to a binary file using fopen, there is 0 bytes (because of the warning). If i just write the base_64 decoded data to a binary file, then I can't open the file as a gziped file. (it is not a valid gzip'ed file) From the person who sent me the XML file, what I was told the base_64 decoded data will give me the deflated binary array for the image, which I would need to inflate using an InflaterInputStream, and as a result, I will get the PNG file that is represented in $mystra. I probably need to add some PNG headers to it and/or explode the base_64 decoded data and then add headers to it. I am getting quite lost here. Can anyone provide some hints please? Regards Venky
[PHP] popup window from php page
Hello, How do I open a popup window from php code when a web page is loaded? Does it require javascript usage? Thanks -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XPath avg(), min(), max() functions not found
Hi all. I'm trying to use XPath avg(), min() and max() functions without success. Others functions like count() or sum() works correctly. Here is the code I'm using (PHP 5.1): ?php $xml_str = ' stats cards card name=My card type name=visits25/type type name=clicks7/type /card card name=My other card type name=visits50/type type name=clicks3/type /card /cards /stats '; $xml_doc = new DOMDocument(); $xml_doc-loadXML($xml_str); $xpath = new DOMXPath($xml_doc); $cards_avg = $xpath-evaluate(avg(//card/[EMAIL PROTECTED]'visits'])); var_dump($cards_avg); $cards_sum = $xpath-evaluate(sum(//card/[EMAIL PROTECTED]'visits'])); var_dump($cards_sum); ? I receive the following output: [EMAIL PROTECTED]:/tmp$ php test.php PHP Warning: DOMXPath::evaluate(): xmlXPathCompOpEval: function avg not found in /tmp/test.php on line 23 Warning: DOMXPath::evaluate(): xmlXPathCompOpEval: function avg not found in /tmp/test.php on line 23 PHP Warning: DOMXPath::evaluate(): Unregistered function in /tmp/test.php on line 23 Warning: DOMXPath::evaluate(): Unregistered function in /tmp/test.php on line 23 object(DOMNodeList)#5 (0) { } float(75) [EMAIL PROTECTED]:/tmp$ Someone can help me? Thanks in advance Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] popup window from php page
On 6/8/06, William Stokes [EMAIL PROTECTED] wrote: How do I open a popup window from php code when a web page is loaded? Does it require javascript usage? Yes, this needs to be done with Javascript. Google will help you on this. Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restrict uploaded scripts
On 6/8/06, Mathias Bundgaard Svesson [EMAIL PROTECTED] wrote: Hi! I'm trying to create a CMS where it should be posible to upload script modules. Those modules should mostly be made by myself, but it is posible for others to create scripts too. My question is, is it posible to restrict the modules to their own directory so they don't overwrite some of the other modules or the CMS itself? Restrict them to do what exactly? -- 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] Running Scripts from the Command Line in Linux
How can I run a .php script from the command in Linux? -- OOzy Kubuntu-Dapper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: popup window from php page
Yeah, just echo JavaScript, which opens popup page. Remember php is server side language. On 6/8/06, William Stokes [EMAIL PROTECTED] wrote: Hello, How do I open a popup window from php code when a web page is loaded? Does it require javascript usage? Thanks -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mindaugas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] popup window from php page
What PHP does is it outputs HTML code as result. Any other functionality regarding browser commands (such as opening popups) are done using javascript. Andy William Stokes wrote: Hello, How do I open a popup window from php code when a web page is loaded? Does it require javascript usage? Thanks -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running Scripts from the Command Line in Linux
On 08/06/06, OOzy Pal [EMAIL PROTECTED] wrote: How can I run a .php script from the command in Linux? 1. run /usr/local/bin/php (or wherever the php binary is, run which php to find out) scriptname 2. add the hash bang to the start of the script and run it by typing the scriptname. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
Re: [PHP] Running Scripts from the Command Line in Linux
On 6/8/06, OOzy Pal [EMAIL PROTECTED] wrote: How can I run a .php script from the command in Linux? $ php yourscript.php Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running Scripts from the Command Line in Linux
$ php script.php OOzy Pal wrote: How can I run a .php script from the command in Linux? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file from database work local, but not on server
What happens when you print out the query to the page? Is the query correct? Jef -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 07, 2006 1:10 PM To: php-general@lists.php.net Subject: [PHP] file from database work local, but not on server Best group member, This code works fine on my local machine: $Query = sprintf(SELECT * FROM filestorage WHERE id=%s LIMIT 1, $_GET['fileid']); $Result = mysql_query($Query); if (mysql_num_rows ($Result)0) { $Row = @mysql_fetch_array ($Result); $file_type = $Row[filetype]; $file = $Row[filedata]; header (Content-type: $file_type); header(Content-Disposition: attachment; filename=fil.substr($Row['filename'], strrpos($Row['filename'], '.'))); '.')).' print $file; } But when I run it on my server it does not start the download, and the file name is the location of the script instead of what I state as file name. Is this a server issue? I run Linux server with Plesk. Is there anyone with the same problems? Best regards, Peter Lauri -- 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] php sessions and Google (Solved)
At 12:47 PM +1000 6/8/06, Chris wrote: tedd wrote: At 10:56 AM +1000 6/8/06, Chris wrote: tedd wrote: Hi gang: I've read that php sessions can create problems for Google bots. -snip- Chris: Thanks -- after your lead, I found that my site's session.use_trans_sid was turned off by default. So, it wasn't the problem I thought it might have been. So your page urls don't automatically append the session id to the end? I might have the wrong variable name so if you're still seeing them, I obviously have it wrong... No, you're right and my url's are clean of SID's -- they always have been, that was the default. The problem I was trying to figure out was how the use of SID's cause SE's to fail and how that works. I figured that once I understand how that worked, then I could keep from doing it. I just needed to see for myself what it was. You know, one of my wonder why this works studies. While the problem wasn't present for me, which at the start of this I wasn't sure about, I did learn how it works and why SE's have problems with indexing url's that have ? in them. For those interested in this thread, this is what I believe is happening. If you have a web page that uses SID's in it's url, then it appears to a SE as something like this (using one of my sites as an example): http://ancientstones.com?PHPSESSID=1234 and not like: http://ancientstones.com/ So the SE grabs the page with the SID. The next time it travels your site, it see's: http://ancientstones.com?PHPSESSID=5678 and grabs that page. After a while, Google has numerous duplicate pages and has to pick one to be representative of your site and store all the others into it's supplemental index. Now when Google determines PageRank for your site, it does so by calculating how many sites link to your site (simple version). If Google has picked: http://ancientstones.com?PHPSESSID=5678 to be THE representative for your site, then you're sunk because no one uses a SID in their link to your site. Your site will always have a PR of 0 -- as it is with the referenced site. While the site ranks very high (currently #1) in a Google search for Custom Tile Medallions, it has a PR of 0. I was trying to figure out what was happening and if there was something I was doing in using php caused the low PR. I found that PHP wasn't the problem -- and now I know that. At least, that's the way I understand what's going on -- if I'm mistaken, please correct me. 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
[PHP] Passing variables.
Hello, I've used like 3 hours to get this done but I can't figure this out. Hope someone here can help. I have a form that a user can use to edit www pages. Page content is stored in DB as a HTML code. First user has to select, from select menu, which page to edit. Then the selected page content html is retrieved to a textarea where it can be edited with tinyMCE editor. Then there's two buttons. Publish to save the edited content back to DB (no problems there) and Preview to open the full page layout in a popup window. The problem is that I can't pass the edited data from the textarea to the popup window. Here's last (desperate) attempt: table width=800 border=0 tr td colspan=2Edit/td /tr tr td colspan=2 textarea name=Edited cols=100 rows=40 id=? echo $tinymcestatus; ? ?php $result=mysql_query(SELECT ContentData FROM x_pages WHERE id = '$ID'); $ContentData = mysql_fetch_row($result); print $ContentData[0]; ? /textarea /td /tr tr td script language=JavaScript function Preview() { window.open('preview.php?page=?php echo $ContentData[0] ?', 'popup', 'width=900, height=900, top=0, left=0, menubar=0, scrollbars=1, location=1, toolbar=0, resizable=1, status=0'); } /script input type=submit name=Submit value=Publish input type=button onclick=Preview(''); return false; value=Preview / /td /tr /table When I echo $page at the preview.php window it prints some of the data to page and some to address line??? And this is not even the edited data. I should pass The variable $Edited but I can't get it to work Thanks a LOT -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XPath avg(), min(), max() functions not found
Hi Alex, Alex wrote: Hi all. I'm trying to use XPath avg(), min() and max() functions without success. Others functions like count() or sum() works correctly. Here is the code I'm using (PHP 5.1): ?php $xml_str = ' stats cards card name=My card type name=visits25/type type name=clicks7/type /card card name=My other card type name=visits50/type type name=clicks3/type /card /cards /stats '; $xml_doc = new DOMDocument(); $xml_doc-loadXML($xml_str); $xpath = new DOMXPath($xml_doc); $cards_avg = $xpath-evaluate(avg(//card/[EMAIL PROTECTED]'visits'])); var_dump($cards_avg); $cards_sum = $xpath-evaluate(sum(//card/[EMAIL PROTECTED]'visits'])); var_dump($cards_sum); ? min(), max() and avg() don't exist in XPath 1.0 which is the version implemented in libxml2. You need to calculate these yourself. For example: /* Find the average */ $cards_avg = $xpath-evaluate(sum(//card/[EMAIL PROTECTED]'visits']) div count(//card/[EMAIL PROTECTED]'visits'])); var_dump($cards_avg); $cards_sum = $xpath-evaluate(sum(//card/[EMAIL PROTECTED]'visits'])); var_dump($cards_sum); /* Find lowest visits */ $cards_min_nodes = $xpath-query(//card/[EMAIL PROTECTED]'visits']/text()); $min = NULL; foreach ($cards_min_nodes AS $node) { $val = (int)$node-nodeValue; if (is_null($min) || $min $val) { $min = $val; } } print 'Minimum Visits: '.$min.\n; /* Find maximum visits */ $cards_max_nodes = $xpath-query(//card/[EMAIL PROTECTED]'visits']/text()); $max = NULL; foreach ($cards_max_nodes AS $node) { $val = (int)$node-nodeValue; if (is_null($min) || $max $val) { $max = $val; } } print 'Maximum Visits: '.$max.\n; Rob -- [EMAIL PROTECTED] author of Pro PHP XML and Web Services from Apress -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File downloads
At 7:47 AM + 6/8/06, kartikay malhotra wrote: New problem: Is there a way for the server to notify the client that a new file has become available for download, provided the client was online in the past X minutes? This could be done... kartikay: First, it's probably best if you start a new thread for a new subject. Second, it might be better for you to state what you would like to do rather than set the specifics of how it is to be done, understand? Simply put, why are you trying to do? 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
[PHP] Re: pop-up window in php???
Am 2006-05-29 11:56:43, schrieb [EMAIL PROTECTED]: ok, maybe I didn't make my question too clear. I was mostly wondering if there is a way to do it in PHP rather than Javascript. I would prefer only using php. Maybe it can be done, like, 1) Client fill out a form 2) Client klick the Submit Button 3) The php script on the server get the data and store it temporary 4) The php script on the server send back a HTML page which open a new (popup) window with the question 5) Client must confirm 6) The php script on the server get the confirmation and do something wit the previously sored data Greetings Michelle Konzack -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSM LinuxMichi 0033/6/6192519367100 Strasbourg/France IRC #Debian (irc.icq.com) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing variables.
My Humble suggestion is possibly: upon preview, actually post the edited data to a temp table, and then pull the HTML from the temp table to display the preview page. Currently you are passing the original content to the preview page. And You might want to look to see if javascript has any functions for escaping html entities for your GET variable.. To get the edited content you will need to get the contents of the text area in the javascript, not pass the original PHP variable (as this will be the original content) -Brad William Stokes wrote: Hello, I've used like 3 hours to get this done but I can't figure this out. Hope someone here can help. I have a form that a user can use to edit www pages. Page content is stored in DB as a HTML code. First user has to select, from select menu, which page to edit. Then the selected page content html is retrieved to a textarea where it can be edited with tinyMCE editor. Then there's two buttons. Publish to save the edited content back to DB (no problems there) and Preview to open the full page layout in a popup window. The problem is that I can't pass the edited data from the textarea to the popup window. Here's last (desperate) attempt: table width=800 border=0 tr td colspan=2Edit/td /tr tr td colspan=2 textarea name=Edited cols=100 rows=40 id=? echo $tinymcestatus; ? ?php $result=mysql_query(SELECT ContentData FROM x_pages WHERE id = '$ID'); $ContentData = mysql_fetch_row($result); print $ContentData[0]; ? /textarea /td /tr tr td script language=JavaScript function Preview() { window.open('preview.php?page=?php echo $ContentData[0] ?', 'popup', 'width=900, height=900, top=0, left=0, menubar=0, scrollbars=1, location=1, toolbar=0, resizable=1, status=0'); } /script input type=submit name=Submit value=Publish input type=button onclick=Preview(''); return false; value=Preview / /td /tr /table When I echo $page at the preview.php window it prints some of the data to page and some to address line??? And this is not even the edited data. I should pass The variable $Edited but I can't get it to work Thanks a LOT -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] running php method in the background
Hi there I have a php web script which communicates with a server using sockets. There is a method in which the client listens for messages from the server, and this blocks the client. I need a way to 'fork' a process or to get this method to run in the background so that i can process user input while not interrupting the protocol. I have searched all over the web with no luck, can anyone point me in the right direction? thanks nic 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
[PHP] server sending notifications to clients
Hi All, Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Thanks KM
Re: [PHP] server sending notifications to clients
kartikay malhotra wrote: Hi All, Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Don't think it can But you can have the client (think AJAX) continuously 'poll' the server, and then the server can send updates back if necessary. -Brad Thanks KM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file from database work local, but not on server
At 9:03 AM +0700 6/8/06, Peter Lauri wrote: Is there anyone with reference of a small example of binary storage and retrieval from database? I have performed working solutions for images before, but this should support any file extensions (with exceptions of course). Peter: Storage and retrieval of an image in a dB is the same as any other data *. The problem I imagine you are having is how to prepare the data for insertion into the dB and how to display the data after you pull it back out. To prepare for insertion, try this: $image = addslashes(file_get_contents($_FILES['userfile']['tmp_name'])); (I have magic_quotes set to OFF -- if you have it ON, remove the addslashes().) To prepare the image file for display after retrieval, try this: ob_start(); ... your dB retrieval code $fileContent = mysql_result($result, 0, image); $image = imagecreatefromstring($fileContent); imagejpeg($image, null, 100); ob_end_flush(); --- hth's tedd *please gang -- no holy war about storing images in a dB -- 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] server sending notifications to clients
kartikay malhotra wrote: Hi All, Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Thanks KM what kind of event?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] server sending notifications to clients
[snip] Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? [/snip] You would need a connection with state to do that, web server connections are stateless. The client would have to have a 'listener' waiting for some event to be pushed to them and then the listener would take an action. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] server sending notifications to clients
Hi All, Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Short answer: It can't. Longer answer: There are probably 100 ways to get close to the result you are looking for. For instance, you could have each page on your site look for a flag in a DB, or a file in the filesystem, or some other clue. Then when the user loads a new page, the page discovers the event, and notifies him. PHP is server side. So everything it generates, it does so on page load. There are PHP/Javascript solutions (like AJAX) that may be able to get closer to what you want. We would need more detail for a more detailed answer. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] order of elements in $_POST super global
Hello All, I'm using a form (method=POST) to collect 30 boolean values from the end user using a series of checkboxes in the form. The form is arranged in a table so that the 30 check boxes are not a long list but rather three columns (with related items columnized). The problem is when I iterate through the $_POST results: The order in which I wish to present the checkboxes to the end user is different than the order I want to have in the $_POST super global and subsequently when I dump that information out to a text file. What would be the best way to solve this? 1) Is there a way to present the checkboxes in a certain order, yet have the data transmitted into the $_POST super global in a different order? 2) Does it make more sense to process the $_POST super global array and reorder the items within the array? 3) Some other method? Thanks for any advice. - Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] server sending notifications to clients
Angelo Zanetti schrieb: kartikay malhotra wrote: Hi All, Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Thanks KM what kind of event?? Server bored and fooling around with the neighbor servers hardware :P But Ajax would be the best method using. Anyway else isn't possible (well refreshing would be one way) But since you don't want php files to execute forever you will have to stick to AJAX. -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] order of elements in $_POST super global
On 08/06/06, Ben Liu [EMAIL PROTECTED] wrote: Hello All, I'm using a form (method=POST) to collect 30 boolean values from the end user using a series of checkboxes in the form. The form is arranged in a table so that the 30 check boxes are not a long list but rather three columns (with related items columnized). The problem is when I iterate through the $_POST results: The order in which I wish to present the checkboxes to the end user is different than the order I want to have in the $_POST super global and subsequently when I dump that information out to a text file. What would be the best way to solve this? 1) Is there a way to present the checkboxes in a certain order, yet have the data transmitted into the $_POST super global in a different order? 2) Does it make more sense to process the $_POST super global array and reorder the items within the array? 3) Some other method? Thanks for any advice. - Ben You can access the values in the $_POST array in any order, so if you know the checkbox names why not output them in the order you want? Or I am being dumb here? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
[PHP] Re: order of elements in $_POST super global
Ben Liu schrieb: Hello All, I'm using a form (method=POST) to collect 30 boolean values from the end user using a series of checkboxes in the form. The form is arranged in a table so that the 30 check boxes are not a long list but rather three columns (with related items columnized). The problem is when I iterate through the $_POST results: The order in which I wish to present the checkboxes to the end user is different than the order I want to have in the $_POST super global and subsequently when I dump that information out to a text file. What would be the best way to solve this? 1) Is there a way to present the checkboxes in a certain order, yet have the data transmitted into the $_POST super global in a different order? 2) Does it make more sense to process the $_POST super global array and reorder the items within the array? 3) Some other method? Thanks for any advice. - Ben 1. Use Keys in your form like a[1],a[2] 2. order the array by usort (alphabetically or whatever u prefer) that way = 2: yes it is. -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Passing variables.
William Stokes schrieb: Hello, I've used like 3 hours to get this done but I can't figure this out. Hope someone here can help. I have a form that a user can use to edit www pages. Page content is stored in DB as a HTML code. First user has to select, from select menu, which page to edit. Then the selected page content html is retrieved to a textarea where it can be edited with tinyMCE editor. Then there's two buttons. Publish to save the edited content back to DB (no problems there) and Preview to open the full page layout in a popup window. The problem is that I can't pass the edited data from the textarea to the popup window. Here's last (desperate) attempt: Hint: Fool around with the target property of HTML ;) -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] order of elements in $_POST super global
Hi Dave, No, that is definitely a possibility. Right now I am using a foreach loop to iterate over the $_POST array and determine if each checkbox is checked or not, if it is checked, than a related piece of data is written into the text file. This makes for pretty compact code. I could as you suggest, simply check each element in the array manually using the associative keys rather than using a loop, that way I could do it in any order I wished, but the code gets rather long with a line for each checkbox. I anticipate this set of checkboxes/boolean responses may increase in the future also, so having the loop allows for some future-proofing. - Ben On 6/8/06, Dave Goodchild [EMAIL PROTECTED] wrote: On 08/06/06, Ben Liu [EMAIL PROTECTED] wrote: You can access the values in the $_POST array in any order, so if you know the checkbox names why not output them in the order you want? Or I am being dumb here? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: order of elements in $_POST super global
I probably should add some more details to my question: The names of the form checkboxes could be changed from ie: bool_careers, bool_speaking, bool_internship, etc. to a single array bool_questions[], for instance. The problem with that is that I am using the form checkbox names later to process related data. Specifically, I am building a user-input based query. So if the form checkbox names are the same as the names of the variables in the database, it makes for easy creating of the query, since the names become associative keys in the $_POST array. I iterate through the $_POST array, checking each for true/false state. If the checkbox is checked, I add the associative key name to the query. Eliminating the checkbox names in favor of a numerical key only would make this more complicated. - Ben On 6/8/06, Barry [EMAIL PROTECTED] wrote: 1. Use Keys in your form like a[1],a[2] 2. order the array by usort (alphabetically or whatever u prefer) that way = 2: yes it is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: running php method in the background
On 6/8/06 10:10 AM, Nic Appleby wrote: I have a php web script which communicates with a server using sockets. There is a method in which the client listens for messages from the server, and this blocks the client. I need a way to 'fork' a process or to get this method to run in the background so that i can process user input while not interrupting the protocol. Have you looked at pcntl_fork()? http://www.php.net/pcntl-fork -- Ben Ramsey http://benramsey.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: order of elements in $_POST super global
Also, I need to re-order the elements in a custom manner, not simply alphabetical or reverse alphabetical or some logical way like that, more like how the original form is presented, by related fields. More specifically, the form is for a membership system, the system collects typical demographic information like home street address, home zip code, business street address, business zip code. So the form presents related fields together: business with business fields and home with home fields (in columns). The problem is the POST method writes these response into the $_POST array in a certain order: not top-to-bottom, then left-to-right as a person would read the form, but left-to right, then top-to-bottom. The simple solution would be to reorder the form checkboxes so that they matched the desired output order of the text file, but then the user is presented with a disorganized, illogical form. I could eliminate the table and just list all the checkboxes in one big list, but again that makes for an ugly, user-unfriendly form. I could perhaps use some divs to make columns and float them, I'm not sure how the $_POST method would order the responses in the $_POST array. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file( ) function
Mayank Maheshwary wrote: Hi, I am facing some trouble with the file( ) function. I understand that it returns the contents of the file in an array. Also, I am able to print the lines using the echo function. However, whenever I try to compare the contents of an array using strcmp, or ==, the page simply keeps 'loading', instead of printing results. The following is the code that I try: $name = $_POST[filename]; $lines = file($name); $i = 0; $len = sizeof($lines); //echo $i; while($i $len) { //echo $lines[$i]; $temp = $lines[$i]; $temp = trim($temp); //echo $temp; if($temp1 == '--') { echo $i; return $i; } else $i++; } I think that the way the lines of the file are stored in the array may be the problem, but I do not know what I am supposed to change. Any help would be appreciated. Thanks. MM. You might want to reexamine the need for your code. It appears that all your code does is searches through a file for a certain line. Do you need to do this manually? array_search() will replace your entire for loop with a single function call, and it'll almost certainly be faster to boot. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: running php method in the background
Nic Appleby wrote: Hi there I have a php web script which communicates with a server using sockets. There is a method in which the client listens for messages from the server, and this blocks the client. I need a way to 'fork' a process or to get this method to run in the background so that i can process user input while not interrupting the protocol. I have searched all over the web with no luck, can anyone point me in the right direction? thanks nic All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm You may be able to do this with asynchronous sockets without forking. With them, you can poll the sockets for new data in between processing user input requests. It might not be quite as fast, but it'll be a lot easier to work with. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] server sending notifications to clients
Barry wrote: Angelo Zanetti schrieb: kartikay malhotra wrote: Hi All, Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Thanks KM what kind of event?? Server bored and fooling around with the neighbor servers hardware :P But Ajax would be the best method using. Anyway else isn't possible (well refreshing would be one way) But since you don't want php files to execute forever you will have to stick to AJAX. You can do it without polling. I've seen web applications that open a neverending GET request in order to get updates to the browser instantaneously. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] order of elements in $_POST super global
Ben Liu wrote: Hi Dave, No, that is definitely a possibility. Right now I am using a foreach loop to iterate over the $_POST array and determine if each checkbox is checked or not, if it is checked, than a related piece of data is written into the text file. This makes for pretty compact code. I could as you suggest, simply check each element in the array manually using the associative keys rather than using a loop, that way I could do it in any order I wished, but the code gets rather long with a line for each checkbox. I anticipate this set of checkboxes/boolean responses may increase in the future also, so having the loop allows for some future-proofing. - Ben On 6/8/06, Dave Goodchild [EMAIL PROTECTED] wrote: On 08/06/06, Ben Liu [EMAIL PROTECTED] wrote: You can access the values in the $_POST array in any order, so if you know the checkbox names why not output them in the order you want? Or I am being dumb here? why not create an array with the keys in the order you want ( $array= array(value1,value2,). Then loop through the array and use the values as keys to the $_POST variable and perform your processing that way. foreach ($array as $value) { if (isset($_POST[$value]) { do something; } } -- Ron Clark System Administrator Armstrong Atlantic State University -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing variables.
At 4:44 PM +0300 6/8/06, William Stokes wrote: I have a form that a user can use to edit www pages. Page content is stored in DB as a HTML code. First user has to select, from select menu, which page to edit. Then the selected page content html is retrieved to a textarea where it can be edited with tinyMCE editor. Then there's two buttons. Publish to save the edited content back to DB (no problems there) and Preview to open the full page layout in a popup window. The problem is that I can't pass the edited data from the textarea to the popup window. Here's last (desperate) attempt: -snip- When I echo $page at the preview.php window it prints some of the data to page and some to address line??? And this is not even the edited data. I should pass The variable $Edited but I can't get it to work My opinion is that you're running into the classic problem of how to get javascript variables into php variables. As I see it, you have three ways to do this (anyone think I'm wrong, please correct me): 1. You place them into your dB with js and then pull them back out in php: http://www.devshed.com/c/a/MySQL/Loading-JavaScript-Arrays-with-MySQL-Data/ 2. You use ajax and plug the js variables values into like php variables. If you want to go this route, it's not complicated -- I can demonstrate. Please let me know. 3. You can try in your html using an id=Edited for js and a name=Edited for php -- it worked for a previous like-problem posted on this list. But I don't know if it's applicable in your case. hth's 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
[PHP] Re: order of elements in $_POST super global
Since i remember, when a for POST is sent and a checkbox is not checked, php not receive this $_POST variable. That is, i think you don´t need to use a foreach to know if checkbox was checked or not. Am i wrong? Ben Liu [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hello All, I'm using a form (method=POST) to collect 30 boolean values from the end user using a series of checkboxes in the form. The form is arranged in a table so that the 30 check boxes are not a long list but rather three columns (with related items columnized). The problem is when I iterate through the $_POST results: The order in which I wish to present the checkboxes to the end user is different than the order I want to have in the $_POST super global and subsequently when I dump that information out to a text file. What would be the best way to solve this? 1) Is there a way to present the checkboxes in a certain order, yet have the data transmitted into the $_POST super global in a different order? 2) Does it make more sense to process the $_POST super global array and reorder the items within the array? 3) Some other method? Thanks for any advice. - Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] server sending notifications to clients
Dear Adam, You can do it without polling. I've seen web applications that open a neverending GET request in order to get updates to the browser instantaneously. Regards, Adam. Kindly elaborate on neverending GET request. Shall I call the script from within itself? Regards KM On 6/8/06, Adam Zey [EMAIL PROTECTED] wrote: Barry wrote: Angelo Zanetti schrieb: kartikay malhotra wrote: Hi All, Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Thanks KM what kind of event?? Server bored and fooling around with the neighbor servers hardware :P But Ajax would be the best method using. Anyway else isn't possible (well refreshing would be one way) But since you don't want php files to execute forever you will have to stick to AJAX. You can do it without polling. I've seen web applications that open a neverending GET request in order to get updates to the browser instantaneously. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] order of elements in $_POST super global
Der...of course. Thanks Ron! I knew the answer was simple. :-) -Ben On 6/8/06, Ron Clark [EMAIL PROTECTED] wrote: why not create an array with the keys in the order you want ( $array= array(value1,value2,). Then loop through the array and use the values as keys to the $_POST variable and perform your processing that way. foreach ($array as $value) { if (isset($_POST[$value]) { do something; } } -- Ron Clark System Administrator Armstrong Atlantic State University -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] server sending notifications to clients
kartikay malhotra wrote: Dear Adam, You can do it without polling. I've seen web applications that open a neverending GET request in order to get updates to the browser instantaneously. Regards, Adam. Kindly elaborate on neverending GET request. Shall I call the script from within itself? Regards KM On 6/8/06, Adam Zey [EMAIL PROTECTED] wrote: Barry wrote: Angelo Zanetti schrieb: kartikay malhotra wrote: Hi All, Is there a way for the server to notify the client about an event, provided the client was online in the past X minutes? To elaborate: A client comes online. A script PHP executes (serves the client), and terminates. Now if a new event occurs, how can the server notify the client about that event? Thanks KM what kind of event?? Server bored and fooling around with the neighbor servers hardware :P But Ajax would be the best method using. Anyway else isn't possible (well refreshing would be one way) But since you don't want php files to execute forever you will have to stick to AJAX. You can do it without polling. I've seen web applications that open a neverending GET request in order to get updates to the browser instantaneously. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I refer to having the javascript code open a GET request that never ends and streaming data from the server back to the client. The server-side PHP process, which stays running, streams back data whenever it becomes available. This of course uses a lot of memory. I have never done this myself in a web application, so I suggest you google for examples of other people who have actually implemented it. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: order of elements in $_POST super global
Hello João, You are right that the $_POST variable does not receive anything for unchecked boxes. I didn't realize that. But I still need the foreach loop for other reasons: So it looks like this: foreach ($_POST as $key = $data) { $query.=$key, ; } Instead of this: foreach ($_POST as $key = $data) { if ($data) $query.=$key, ; } Thanks, Ben On 6/8/06, João Cândido de Souza Neto [EMAIL PROTECTED] wrote: Since i remember, when a for POST is sent and a checkbox is not checked, php not receive this $_POST variable. That is, i think you don´t need to use a foreach to know if checkbox was checked or not. Am i wrong? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] file from database work local, but not on server
Hi Tedd, Thank you for your answer. I have it working for images already, the problem comes to Excel, PDF's etc. I will do some more testing using your sample, thanks. /Peter -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Thursday, June 08, 2006 9:29 PM To: Peter Lauri; 'Chris' Cc: php-general@lists.php.net Subject: RE: [PHP] file from database work local, but not on server At 9:03 AM +0700 6/8/06, Peter Lauri wrote: Is there anyone with reference of a small example of binary storage and retrieval from database? I have performed working solutions for images before, but this should support any file extensions (with exceptions of course). Peter: Storage and retrieval of an image in a dB is the same as any other data *. The problem I imagine you are having is how to prepare the data for insertion into the dB and how to display the data after you pull it back out. To prepare for insertion, try this: $image = addslashes(file_get_contents($_FILES['userfile']['tmp_name'])); (I have magic_quotes set to OFF -- if you have it ON, remove the addslashes().) To prepare the image file for display after retrieval, try this: ob_start(); ... your dB retrieval code $fileContent = mysql_result($result, 0, image); $image = imagecreatefromstring($fileContent); imagejpeg($image, null, 100); ob_end_flush(); --- hth's tedd *please gang -- no holy war about storing images in a dB -- 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] file from database work local, but not on server
At 6:22 PM +0700 6/8/06, Peter Lauri wrote: Hi Tedd, Thank you for your answer. I have it working for images already, the problem comes to Excel, PDF's etc. I will do some more testing using your sample, thanks. /Peter Peter: Excel and PDF's are different critters. I'm sure there are people on this list that can help. Just change the subject line and ask. 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] Re: order of elements in $_POST super global
yes, as I said in an earlier post, I used to have 30 if ($key) statements, one for each checkbox, in the order I wanted to write them in. This is not optimal because: (a) it is a ton of code, (b) the checkboxes could in the future increase in number, change order, etc. and then I would have to recode this section to match. The solution I used to solve this was to remove the table, put all the checkboxes into div elements, float them into columns and now they appear in the same order as before when they were in a table, but they write to the $_POST variable in the order that I want. - Ben On 6/8/06, João Cândido de Souza Neto [EMAIL PROTECTED] wrote: I don´t test, but it can works fine: foreach ($_POST as $key = $data) { switch ($key) { case aaa $query.=$key, ; break; case bbb $query.=$key, ; break; case ccc $query.=$key, ; break; } } In switch you can order by ordening the cases. Hope help. - Original Message - From: Ben Liu [EMAIL PROTECTED] To: João Cândido de Souza Neto [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Thursday, June 08, 2006 1:14 PM Subject: Re: [PHP] Re: order of elements in $_POST super global Hello João, You are right that the $_POST variable does not receive anything for unchecked boxes. I didn't realize that. But I still need the foreach loop for other reasons: So it looks like this: foreach ($_POST as $key = $data) { $query.=$key, ; } Instead of this: foreach ($_POST as $key = $data) { if ($data) $query.=$key, ; } Thanks, Ben On 6/8/06, João Cândido de Souza Neto [EMAIL PROTECTED] wrote: Since i remember, when a for POST is sent and a checkbox is not checked, php not receive this $_POST variable. That is, i think you don´t need to use a foreach to know if checkbox was checked or not. Am i wrong? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running Scripts from the Command Line in Linux
Even better... if you want to use GET/POST, and access PHP scripts thru the web server, it is recommended to use wget very useful tool, supports http auth, etc. Regards Venky On 08/06/06, Brad Bonkoski [EMAIL PROTECTED] wrote: $ php script.php OOzy Pal wrote: How can I run a .php script from the command in Linux? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reset a resource?
After I've looped through a resource do I have to run the query again to load up 'mysql_fetch_assoc' or is there some kind of reset function I can't find? $q = SELECT * FROM table; $s = mysql_query($q, $pe) or die(mysql_error()); while ($row_s = mysql_fetch_assoc($s)) { echo $i++; } outputs 12345... for each row of table while ($row_s2 = mysql_fetch_assoc($q)) { ... } outputs Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reset a resource?
Perhaps this will help: http://www.php.net/manual/en/function.mysql-data-seek.php -brad sam wrote: After I've looped through a resource do I have to run the query again to load up 'mysql_fetch_assoc' or is there some kind of reset function I can't find? $q = SELECT * FROM table; $s = mysql_query($q, $pe) or die(mysql_error()); while ($row_s = mysql_fetch_assoc($s)) { echo $i++; } outputs 12345... for each row of table while ($row_s2 = mysql_fetch_assoc($q)) { ... } and $q is your query, I'm surprised this does not throw an error, unless you snipped some other code out of there... outputs Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reset a resource?
sorry, mysql_data_seek() On 6/8/06, sam [EMAIL PROTECTED] wrote: After I've looped through a resource do I have to run the query again to load up 'mysql_fetch_assoc' or is there some kind of reset function I can't find? $q = SELECT * FROM table; $s = mysql_query($q, $pe) or die(mysql_error()); while ($row_s = mysql_fetch_assoc($s)) { echo $i++; } outputs 12345... for each row of table while ($row_s2 = mysql_fetch_assoc($q)) { ... } outputs Thanks -- 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: pop-up window in php???
Michelle Konzack wrote: Am 2006-05-29 11:56:43, schrieb [EMAIL PROTECTED]: ok, maybe I didn't make my question too clear. I was mostly wondering if there is a way to do it in PHP rather than Javascript. I would prefer only using php. Maybe it can be done, like, 1) Client fill out a form 2) Client klick the Submit Button 3) The php script on the server get the data and store it temporary 4) The php script on the server send back a HTML page which open a new (popup) window with the question 5) Client must confirm 6) The php script on the server get the confirmation and do something wit the previously sored data Greetings Michelle Konzack You can not specify the window parameters (a popup) without using Javascript. You are correct, tough. You could load a new page asking them to confirm (I do this a lot with scripts that delete something - are you sure?), but not in a popup window. -- * Chuck Anderson • Boulder, CO http://www.CycleTourist.com Everyone's journey should be different, so that we all are enriched in new and endless ways * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restrict uploaded scripts
Restrict them not to overwrite other modules or overwrite the CMS itself. Each module should have it's own directory, and it shouldn't be allowed to change anything outside it. tor, 08 06 2006 kl. 21:49 +1000, skrev chris smith: On 6/8/06, Mathias Bundgaard Svesson [EMAIL PROTECTED] wrote: Hi! I'm trying to create a CMS where it should be posible to upload script modules. Those modules should mostly be made by myself, but it is posible for others to create scripts too. My question is, is it posible to restrict the modules to their own directory so they don't overwrite some of the other modules or the CMS itself? Restrict them to do what exactly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restrict uploaded scripts
At 10:37 PM +0200 6/8/06, Mathias Bundgaard Svesson wrote: Restrict them not to overwrite other modules or overwrite the CMS itself. Each module should have it's own directory, and it shouldn't be allowed to change anything outside it. tor, 08 06 2006 kl. 21:49 +1000, skrev chris smith: On 6/8/06, Mathias Bundgaard Svesson [EMAIL PROTECTED] wrote: Hi! I'm trying to create a CMS where it should be posible to upload script modules. Those modules should mostly be made by myself, but it is posible for others to create scripts too. My question is, is it posible to restrict the modules to their own directory so they don't overwrite some of the other modules or the CMS itself? Mathias: Well then, how about this? You can create a uniquely named id by using: $unique_id = md5(uniqid(microtime(), true)); and then use that name as a folder for each person submitting scripts OR use the unique id as a suffix for their cms file. Either way, it should stop persons from overwriting cms files. I would also suggest that you keep track of these id's in a dB. If you are still concerned about two people having the same unique, then you could search the dB to see if the recently created id exist. If it does, then generate another one. I use a similar method for making sure that the images I upload have unique names. hth's 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] Gzinflate on a string that has been base_64 encoded in Windows
Venky wrote: Greetings! I have a long piece of string that is apparently a PNG image which has been base_64 decoded in an XML file. I can retreive this string without problem. The string is in $mystra $pngdata = base64_decode($mystra); $pngdata = gzinflate($pngdata); When i try to gzinflate it , i get a warning that says data error and if i write pngdata to a binary file using fopen, there is 0 bytes (because of the warning). If i just write the base_64 decoded data to a binary file, then I can't open the file as a gziped file. (it is not a valid gzip'ed file) From the person who sent me the XML file, what I was told the base_64 decoded data will give me the deflated binary array for the image, which I would need to inflate using an InflaterInputStream, and as a result, I will get the PNG file that is represented in $mystra. I probably need to add some PNG headers to it and/or explode the base_64 decoded data and then add headers to it. I am getting quite lost here. Can anyone provide some hints please? Hmm, a couple of things. Do you get it base64_encoded or decoded? You're using decode as both terms so it's confusing for us. Does the xml feed give you it inflated or deflated? gzdeflate will only work if it is already inflated with gzinflate. Can you get the other person to show you the code of how he puts the image into the xml feed? That will tell you exactly what you need to undo. -- 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] binary zero evaluates as true!?
Seriously guys... am I completely missing something important here? An empty array evaluates as false. The null character evaluates as false. The STRING 0 even evaluates as false yet a binary zero does not? Even better yet bindec() doesn't appear to be binary safe so it will work for a string representation of binary data where the 0's and 1's are ascii characters but pass it an actual binary string and it always returns 0. (sigh) Someone help me understand this. Isn't this a bug or oversight? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] remove last comma in string
Hi all, I am using php 4.3.2 and mysql , linux. I have a sql statement below : UPDATE tbl_chassis_temp SET country = 'Singapore', city 'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40', I need to remove the last comma from sql text above. I have tried using substr and rtrim , without any success ? Anyone have any suggestion ? THanks - weetat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary zero evaluates as true!?
Jon wrote: Seriously guys... am I completely missing something important here? An empty array evaluates as false. The null character evaluates as false. The STRING 0 even evaluates as false yet a binary zero does not? Even better yet bindec() doesn't appear to be binary safe so it will work for a string representation of binary data where the 0's and 1's are ascii characters but pass it an actual binary string and it always returns 0. (sigh) Someone help me understand this. Isn't this a bug or oversight? The character '0' (zero) is not the same as a byte with all bits turned off. (char) '0' = (binary) '0011' = ord('0') = (int) 48 'bindec' returns the decimal equivalent of the binary number represented by the binary_string argument. Note the BINARY STRING key word. I'm guessing a Binary String is a string consisting of the characters '0' or '1' not bits. Each character is 8 bits, so a binary string is a sequence of the characters #48 and #49 from the ASCII table. The 'character' ZERO is written with bits 0011 in binary. This binary could be interpreted as either a character or an integer. If the binary is read as an integer, you'll get INT 48. INT 48 is NOT FALSE. Casting from string to int to 'binary string' is done even when you might not want it. Are you sure you are evaluating your binary '' properly as you claim? Send a sample code, otherwise, see the following example: -- pre ?php $zero = (string)'0'; $one = (string)'1'; var_dump($zero); var_dump($one); printf(char: %s, ord: %d, byte: %08b\n, $zero, ord($zero), $zero); printf(char: %s, ord: %d, byte: %08b\n, $one, ord($one), $one); // string(1) 0 // string(1) 1 // char: 0, ord: 48, byte: // char: 1, ord: 49, byte: 0001 $zero = (int)'0'; $one = (int)'1'; var_dump($zero); var_dump($one); printf(char: %s, ord: %d, byte: %08b\n, $zero, ord($zero), $zero); printf(char: %s, ord: %d, byte: %08b\n, $one, ord($one), $one); // int(0) // int(1) // char: 0, ord: 48, byte: // char: 1, ord: 49, byte: 0001 $zero = unpack('C', (string)'0'); $zero = array_pop($zero); $one = unpack('C', (string)'1'); $one = array_pop($one); var_dump($zero); var_dump($one); printf(char: %s, ord: %d, byte: %08b\n, $zero, ord($zero), $zero); printf(char: %s, ord: %d, byte: %08b\n, $one, ord($one), $one); // int(48) // int(49) // char: 48, ord: 52, byte: 0011 // char: 49, ord: 52, byte: 00110001 ? /pre -- Dante -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] remove last comma in string
weetat wrote: Hi all, I am using php 4.3.2 and mysql , linux. I have a sql statement below : UPDATE tbl_chassis_temp SET country = 'Singapore', city 'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40', I need to remove the last comma from sql text above. I have tried using substr and rtrim , without any success ? Anyone have any suggestion ? http://us2.php.net/manual/en/function.trim.php trim: 4.1.0 The optional charlist parameter was added. $str = UPDATE tbl_chassis_temp SET country = 'Singapore', city 'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40', ; $str = trim($str, ', '); print $str; Dante -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] remove last comma in string
weetat wrote: Hi all, I am using php 4.3.2 and mysql , linux. I have a sql statement below : UPDATE tbl_chassis_temp SET country = 'Singapore', city 'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40', I need to remove the last comma from sql text above. I have tried using substr and rtrim , without any success ? Anyone have any suggestion ? How about: $query = substr(trim($query), 0, -1); ? -- 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] binary zero evaluates as true!?
Are you sure you are evaluating your binary '' properly as you claim? Send a sample code alrightey then. the binary data itself is actually stored in a mysql table. (mysql 5.1.9) the relevant part is the following column: ++- | Field | Type ++- | bit_string | bit(8) ++- but of course there are others. assuming there weren't however, data would be inserted into this table with a queries similar to: INSERT INTO blah SET bit_string=b'0001'; INSERT INTO blah SET bit_string=b'0011'; INSERT INTO blah SET bit_string=b'0100'; this part appears to work great. i just discovered the bit type in mysql myself and have been having great fun with it. just in case you hadn't heard of it reference here: (*please* don't be insulted if this is old news to you) http://dev.mysql.com/doc/refman/5.1/en/bit-field-values.html anyway, when this data is selected from the table the characters are clearly being represented correctly, they show up unprintable in various wierd ways and return correct values for bitwise operations. the problem happens when you try to say: ?php // assume this code is part of a method of a greater class that has a member database handle already initialized... --- snip --- $bit_strings = array(); $rh = $this-_dbh-query('SELECT bit_string FROM blah'); if($rh !== false $rh-num_rows) { while($bit_string = $rh-fetch_assoc()) { $bit_strings[] = $bit_string; } $rh-free(); } return $bit_strings; --- snip --- // ok so lets say you call this method and just for simplicity sake (no its really not anywhere near this simple) *know* that the three values above are the only things that get returned. lets say we know that we will have an array of three values, which are the binary 1, binary 3, and binary 4, we inserted above, in that order. in that case the following check: if($bit_strings[0] $bit_strings[1]) { // blah } //evaluates to a binary 1 and is therefore true, as would be expected, but this check: if($bit_strings[0] $bit_strings[2]) { // blah } // evaluates to a binary zero but STILL counts as true! (go ahead, try it yourself) ? Now two things are worth stating here. First is that its comforting to see unpack('C',... in your sample code, because my fix for the problem last night eventually turned out to be: $bits = array_pop(unpack('C', ($bit_string_one $bit_string_two))); settype($bits, 'integer'); if($bits) { return true; } ... and though it seemed to work the way i wanted i was previously unfamiliar with unpack/pack and was worried i was approaching this entirely in the wrong way. Thank you for that. The second thing that needs to be said here is simply a re-statement of the original, this time more verbosely. The list of things in php that evaluate as false is as follows: * the boolean FALSE itself * the integer 0 (zero) * the float 0.0 (zero) * the empty string, and the string 0 * an array with zero elements * an object with zero member variables (PHP 4 only) * the special type NULL (including unset variables) * SimpleXML objects created from empty tags now, all i'm saying is that if, of all ungodly things, the literal string 0 and empty arrays evaluate to false, isn't it appropriate to expect a binary zero to evaluate to false as well? Maybe i still don't get it. :( thanks btw, for your time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary zero evaluates as true!?
Jon wrote: The second thing that needs to be said here is simply a re-statement of the original, this time more verbosely. The list of things in php that evaluate as false is as follows: * the boolean FALSE itself * the integer 0 (zero) * the float 0.0 (zero) * the empty string, and the string 0 * an array with zero elements * an object with zero member variables (PHP 4 only) * the special type NULL (including unset variables) * SimpleXML objects created from empty tags now, all i'm saying is that if, of all ungodly things, the literal string 0 and empty arrays evaluate to false, isn't it appropriate to expect a binary zero to evaluate to false as well? Maybe i still don't get it. :( Jon, You are correct about the behavior you are observing, sorry I doubted your ability/methods. Here is a much shorter example of what you are trying to do: ?php // start with int '0' $as_int = (int) 0x0; var_dump($as_int); // convert into to binary string $as_binstr = (string) pack('C', $as_int); var_dump($as_binstr); // cast binary string as boolean $as_bool = (boolean) $as_binstr; var_dump($as_bool); ? // int(0) // string(1) !~unprintable~! // bool(true) You want to know WHY a single byte of all 8 bits set to '0' does not evaluate as FALSE. I don't know the answer, but my theory is as follows: Perhaps binary strings are not a normal everyday kind of string. If you have a binary string, you probably got it from a binary place like a file or stream. If you read a file and that file contains one byte and that byte is all , then how is that FALSE when you got 1 byte not 0 bytes. I might believe that a binary string should always be TRUE if the length is greater than ZERO bytes in length. Since binary files are not meant to be looked at, perhaps length is all that determines their truth? Oddly, if you start with this in the example above: $as_int = (int) 48; Then, the is_bool will be false! Ok, now I'm with you about odd behavior and wanting a better answer ;-) You can't really use the bitwise operators on your binary string either. From the manual: Bitwise operators allow you to turn specific bits within an integer on or off. If both the left- and right-hand parameters are strings, the bitwise operator will operate on the characters' ASCII values. I think the best bet would be to unpack the binary string into a format that PHP will play nicely with. Most likely if you are looking at a single byte, unpacking as an int is the way to go. Dante -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] transfer file
can php do transfer file betwen 2 server without using ftp function socket that use ftp port Send instant messages to your online friends http://uk.messenger.yahoo.com
[PHP] Update table to get consecutive Primary keys
Hi All! I've a MySQL table: table (id INT NOT NULL AUTO_INCREMENT, flag TINYINT NOT NULL, msgID VARCHAR(30) NOT NULL, msgName VARCHAR(30), size INT NOT NULL, PRIMARY KEY(id)); If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10. I wish to keep entries consecutive, that is rearrange the table as 1 2 3 4 5 6 ... 9. How do I go about it? Thanks Regards, Antonio
Re: [PHP] Update table to get consecutive Primary keys
Antonio Bassinger wrote: Hi All! I've a MySQL table: table (id INT NOT NULL AUTO_INCREMENT, flag TINYINT NOT NULL, msgID VARCHAR(30) NOT NULL, msgName VARCHAR(30), size INT NOT NULL, PRIMARY KEY(id)); If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10. I wish to keep entries consecutive, that is rearrange the table as 1 2 3 4 5 6 ... 9. How do I go about it? Read this thread: http://marc.theaimsgroup.com/?l=php-generalm=114656385709968w=2 It will tell you this is a really bad idea. -- 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] Restrict uploaded scripts
Wouldn't they still be able to overwrite each other? I don't think I expressed myself clearly. The point of the protection is to keep the scripts from overwriting each other on purpose. It was a protection that would make it posible to upload scripts, even if you were not completly sure they were safe. tor, 08 06 2006 kl. 17:30 -0400, skrev tedd: At 10:37 PM +0200 6/8/06, Mathias Bundgaard Svesson wrote: Restrict them not to overwrite other modules or overwrite the CMS itself. Each module should have it's own directory, and it shouldn't be allowed to change anything outside it. tor, 08 06 2006 kl. 21:49 +1000, skrev chris smith: On 6/8/06, Mathias Bundgaard Svesson [EMAIL PROTECTED] wrote: Hi! I'm trying to create a CMS where it should be posible to upload script modules. Those modules should mostly be made by myself, but it is posible for others to create scripts too. My question is, is it posible to restrict the modules to their own directory so they don't overwrite some of the other modules or the CMS itself? Mathias: Well then, how about this? You can create a uniquely named id by using: $unique_id = md5(uniqid(microtime(), true)); and then use that name as a folder for each person submitting scripts OR use the unique id as a suffix for their cms file. Either way, it should stop persons from overwriting cms files. I would also suggest that you keep track of these id's in a dB. If you are still concerned about two people having the same unique, then you could search the dB to see if the recently created id exist. If it does, then generate another one. I use a similar method for making sure that the images I upload have unique names. hth's tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php