Re: [PHP] Ensuring all links go to index.php
On Oct 20, 2006, at 4:00 AM, Dave M G wrote: PHP List, This problem is a little hard to describe. Please forgive me in advance if it's not clear. I have set up my .htaccess file to work with my PHP script to create "friendly URLs". [snip] I thought it had something to do with setting headers. I want everything to operate through the index.php file in my root directory, so I thought I could do that by putting this at the top of the index.php page: header("Location: /"); Or: header("/local/server/www/directory/"); Bottom line is, how do I ensure that all links and user requests through the URL end up going to the index.php in my web site's root directory? If you want all requests to go through index.php, then the .htaccess file would be something like: RewriteEngine On RewriteRule ^whatever/.*$ - [L] RewriteRule !\.(gif|jpg|png|css|pdf)$ /server_path/index.php The second line exempts the directory "whatever" and the third line starts by exempting direct requests for files ending with "gif", "jpg", etc. Then, index.php would examine $_SERVER["REQUEST_URI"] to map the "friendly" URL to content by including files or redirecting with header(). Is that what you mean? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simultaneous post/get?
On Jun 12, 2006, at 8:02 AM, tedd wrote: [snip] Form... onsubmit="document.getElementById('waitimg').style.display = 'block'; return true;"> Bingo! That works slick ! While I *think* I know css, it would have taken me a long while before I would have turned to css to solve this. I recall trying this (exactly this I think) a couple months ago and finding that it works in most browsers, but not in Windows IE6 (of course). Is it working in Windows IE6 for you? I got a working upload progress bar by using Uber Uploader <http://sourceforge.net/projects/uber-uploader>. -- Lowell Allen Lowell: I don't do windows, I'm a mac guy. Me too, but Windows IE has so many problems I find it necessary to also have a Windows system to check things. However, I do have a BrowserCam account and on remote access under W2K, IE6 the page did show the animated gif, so it looks like it works. But, BrowserCam didn't have an image to upload so I couldn't test the complete operation. I suspect it works as wanted. Hey, all I'm saying is that my test of something very similar did not work in Windows IE6. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simultaneous post/get?
On Jun 11, 2006, at 2:02 PM, tedd wrote: At 5:46 PM +0100 6/11/06, Stut wrote: tedd wrote: At 4:35 PM +0100 6/11/06, Stut wrote: The form, with onsubmit="return sndReq()". sndReq does the AJAX image thing (although I don't know why you're using AJAX here, I'm using ajax because it's a method to inject an image in a DOM div without having to reload the current page. All I want to do is present an image during the "wait". Is there an easier way to do this? There is no need to hit the server for this. Simply include "display: none;" in the style for either the img tag or the div containing it so it's not shown when the page initially loads. In the onsubmit for the form change that display to 'block' to show the image. This also avoids the need to postpone posting the form since the image has already loaded. Image... Form... Bingo! That works slick ! While I *think* I know css, it would have taken me a long while before I would have turned to css to solve this. I recall trying this (exactly this I think) a couple months ago and finding that it works in most browsers, but not in Windows IE6 (of course). Is it working in Windows IE6 for you? I got a working upload progress bar by using Uber Uploader <http://sourceforge.net/projects/uber-uploader>. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OS Detection
On Nov 17, 2005, at 10:09 AM, Rahul S. Johari wrote: I'm working on a Guestbook for a site and I'm trying to identify Browser & Operating System of the user and eventually I'll display the Icon matching the Browser/OS in the entry. I'm able to identify and use an If Conditional statement for the Browser, but I can't seem to identify the OS. This is what I'm using to identify the Browser: function browser_detection( $which_test ) { // initialize the variables $browser = ''; $dom_browser = ''; // set to lower case to avoid errors, check to see if http_user_agent is set $navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; // run through the main browser possibilities, assign them to the main $browser variable if (stristr($navigator_user_agent, "opera")) { $browser = 'opera'; $dom_browser = true; } [snip] Any suggestions on getting the OS ? If you're using the above to match parts of the $_SERVER["HTTP_USER_AGENT"] string, why not also use stristr() to look for "windows", "mac", etc.? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending arrays from page to page
On Nov 15, 2005, at 12:07 PM, Ben Miller wrote: I am trying to learn how to work with arrays, and have the basic concept down for working within a single page, but I am having trouble sending an array from one page to another. For example, I can send a variable from page to page using either the URL, such as www.domain.com/?foo=bar, or using a form, but can I send an array from one page to another using a form so that all the values in the array will be sent? [snip] If you don't want to use session variables (as already suggested), you can serialize the array, then send as a hidden form value: <http://us2.php.net/manual/en/function.serialize.php> You may need to also encode the serialized value: <http://us2.php.net/manual/en/function.base64-encode.php> HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Scary nonsense form submissions
On Sep 4, 2005, at 12:06 PM, Brian Dunning wrote: Hi all - I have forms on a number of unrelated web sites that just send me an email for one purpose or another. There are 2 to 6 fields: name, email, comment, etc. No big deal. Recently I've been getting a lot of weird submissions. I'll receive half a dozen at a time, with all the fields filled with some kind of garbage contents. Here is one example from a form on my americansubstandard.com site: ---snip--- COMMENT: [EMAIL PROTECTED] NAME: [EMAIL PROTECTED] ---/snip--- Other times one of the fields will contain a complete multipart submission, like this: ---snip--- COMMENT: [EMAIL PROTECTED] NAME: [EMAIL PROTECTED] Content-Type: multipart/mixed; boundary=\"===1655480186==\" MIME-Version: 1.0 Subject: e8df6b7 To: [EMAIL PROTECTED] bcc: [EMAIL PROTECTED] From: [EMAIL PROTECTED] This is a multi-part message in MIME format. --===1655480186== Content-Type: text/plain; charset=\"us-ascii\" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit xqofli --===1655480186==-- ---/snip--- I wonder if this is some kind of automated attack attempt. Does anyone recognize this type of thing, and is it potentially dangerous? Should I do something about it? - Brian I've gotten the same kind of thing recently from a comment form. Something's definitely going around. I modified my script to check for various mail header elements within the comments and return an error message if any are found. I also added two returns following my own mail headers, which supposedly prevents an injection of additional headers -- see <http://us2.php.net/manual/en/ref.mail.php#55112>. And see the recent thread on this list -- "Be careful! Look at what this spammer did." -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SFTP problems
On Jun 20, 2005, at 11:19 AM, JB05UK wrote: Read the php man, it says to use the 'b' flag for binary files, infact it says to use it most the time anyway, if im not mistaken. Substituting "wb" for "wt" also fails. As I said in my OP below, I need to send both text files and binary files, and the remote server will be Windows (although I'm now testing on Linux), so that's why I have the "t" flag, but you're probably right to suggest just using "b" in all cases. Thanks for your reply. -- Lowell Allen Lowell Allen wrote: I need to use SFTP to send text files and binary files from one server to another, but I'm unable to use fopen on the remote server, and if I send with ssh2_scp_send the files are truncated. I'm assuming the libssh2-PECL/ssh2 installation isn't the problem because I'm able to connect using ssh2_auth_password, create a directory on the remote server with ssh2_sftp_mkdir, and copy files with ssh2_sftp_send and ssh2_sftp_recv (even though ssh2_sftp_send truncates files). When I try to use fopen, I get this error message: Warning: fopen(): Unable to open ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on remote host in /home/user/public_html/cms/sftp_test.php on line 79 Warning: fopen(ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt): failed to open stream: Resource temporarily unavailable in /home/user/public_html/cms/sftp_test.php on line 79 Here's line 79 of sftp_test.php: $stream = fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/ flamingo/".$filename, "wt") I've read "Secure Communications with PHP and SSH" in the February PHP Architect. That's what prompted me to try PECL/ssh2, but now I'm stuck. Anybody successfully using fopen with SFTP or anybody using ssh2_sftp_send without getting truncated files? -- Lowell Allen -- 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: SFTP problems
On Jun 19, 2005, at 12:37 PM, M. Sokolewicz wrote: Lowell Allen wrote: I need to use SFTP to send text files and binary files from one server to another, but I'm unable to use fopen on the remote server, and if I send with ssh2_scp_send the files are truncated. I'm assuming the libssh2-PECL/ssh2 installation isn't the problem because I'm able to connect using ssh2_auth_password, create a directory on the remote server with ssh2_sftp_mkdir, and copy files with ssh2_sftp_send and ssh2_sftp_recv (even though ssh2_sftp_send truncates files). When I try to use fopen, I get this error message: Warning: fopen(): Unable to open ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on remote host in /home/user/public_html/cms/sftp_test.php on line 79 Warning: fopen(ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt): failed to open stream: Resource temporarily unavailable in /home/user/public_html/cms/sftp_test.php on line 79 Here's line 79 of sftp_test.php: $stream = fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/ flamingo/".$filename, "wt") I've read "Secure Communications with PHP and SSH" in the February PHP Architect. That's what prompted me to try PECL/ssh2, but now I'm stuck. Anybody successfully using fopen with SFTP or anybody using ssh2_sftp_send without getting truncated files? First of all, posting this once is enough. Second of all, I think the problem here is actually a lot easier than it would look at first glance :) I noticed the following error: Warning: fopen(ssh2.sftp://Resource id #10/[...]): [...] Now, what you see here is that you suddenly have a "ssh2.sftp://Resource id #10". This is probably not the domain name you're trying to connect to, now is it? :) That string typically appears only when you cast a resource to a string (eg. a mysql-connection, a stream, or whatever). So, looking at line 79, I would guess that $sftp isn't a string which tells fopen where to find the file to open, but instead is a resource which should not be there at all. Thanks for your reply. I apologize for the duplication. I posted until I saw it show up, and I've only seen it once -- probably my gmail account marking as spam, which I don't see because I retrieve as a POP account with Thunderbird. I unsubscribed and subscribed with a different email address and posted again. Here's where $sftp is coming from: $connection = ssh2_connect("copy-design.com", 22); $sftp = ssh2_sftp($connection); And from the examples I've seen, the correct syntax for opening a handle is what I use on line 79: $stream = fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/ flamingo/".$filename, "wt") The info at <http://us4.php.net/manual/en/function.ssh2-sftp.php> says that ssh_sftp() "returns an SSH2 SFTP resource", which is what I figured "Resource id #10" is referring to. From the manual example for ssh_sftp: $connection = ssh2_connect('shell.example.com', 22); ssh2_auth_password($connection, 'username', 'password'); $sftp = ssh2_sftp($connection); $stream = fopen("ssh2.sftp://$sftp/path/to/file";, 'r'); Perhaps I'm being as inept with this code as I seem to be with my email, but if the domain is "whatever.com", and the file is located at "/home/whatever/public_html/flamingo/", and the file name is "test.txt", and I want to open the file (which doesn't exist yet) for writing, what should I use if not 'fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/ flamingo/test.txt", "wt")'? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SFTP problems
I need to use SFTP to send text files and binary files from one server to another, but I'm unable to use fopen on the remote server, and if I send with ssh2_scp_send the files are truncated. I'm assuming the libssh2-PECL/ssh2 installation isn't the problem because I'm able to connect using ssh2_auth_password, create a directory on the remote server with ssh2_sftp_mkdir, and copy files with ssh2_sftp_send and ssh2_sftp_recv (even though ssh2_sftp_send truncates files). When I try to use fopen, I get this error message: Warning: fopen(): Unable to open ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on remote host in /home/user/public_html/cms/sftp_test.php on line 79 Warning: fopen(ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt): failed to open stream: Resource temporarily unavailable in /home/user/public_html/cms/sftp_test.php on line 79 Here's line 79 of sftp_test.php: $stream = fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/ flamingo/".$filename, "wt") I've read "Secure Communications with PHP and SSH" in the February PHP Architect. That's what prompted me to try PECL/ssh2, but now I'm stuck. Anybody successfully using fopen with SFTP or anybody using ssh2_sftp_send without getting truncated files? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SFTP problem
I need to use SFTP to send text files and binary files from one server to another, but I'm unable to use fopen on the remote server, and if I send with ssh2_scp_send the files are truncated. I'm assuming the libssh2-PECL/ssh2 installation isn't the problem because I'm able to connect using ssh2_auth_password, create a directory on the remote server with ssh2_sftp_mkdir, and copy files with ssh2_sftp_send and ssh2_sftp_recv (even though ssh2_sftp_send truncates files). When I try to use fopen, I get this error message: Warning: fopen(): Unable to open ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on remote host in /home/user/public_html/cms/sftp_test.php on line 79 Warning: fopen(ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt): failed to open stream: Resource temporarily unavailable in /home/user/public_html/cms/sftp_test.php on line 79 Here's line 79 of sftp_test.php: $stream = fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/ flamingo/".$filename, "wt") I've read "Secure Communications with PHP and SSH" in the February PHP Architect. That's what prompted me to try PECL/ssh2, but now I'm stuck. Anybody successfully using fopen with SFTP or anybody using ssh2_sftp_send without getting truncated files? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SFTP problems
I need to use SFTP to send text files and binary files from one server to another, but I'm unable to use fopen on the remote server, and if I send with ssh2_scp_send the files are truncated. I'm assuming the libssh2-PECL/ssh2 installation isn't the problem because I'm able to connect using ssh2_auth_password, create a directory on the remote server with ssh2_sftp_mkdir, and copy files with ssh2_sftp_send and ssh2_sftp_recv (even though ssh2_sftp_send truncates files). When I try to use fopen, I get this error message: Warning: fopen(): Unable to open ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on remote host in /home/user/public_html/cms/sftp_test.php on line 79 Warning: fopen(ssh2.sftp://Resource id #10/whatever.com:22/home/whatever/public_html/flamingo/test.txt): failed to open stream: Resource temporarily unavailable in /home/user/public_html/cms/sftp_test.php on line 79 Here's line 79 of sftp_test.php: $stream = fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/ flamingo/".$filename, "wt") I've read "Secure Communications with PHP and SSH" in the February PHP Architect. That's what prompted me to try PECL/ssh2, but now I'm stuck. Anybody successfully using fopen with SFTP or anybody using ssh2_sftp_send without getting truncated files? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Installation
[EMAIL PROTECTED] wrote: Hi! I am running Apache on Windows XP and would like to install PHP. I'll be using PHP within my computer for development purposes. 1st issue. When I installed Apache, the installation program self-configures. Since I use a permanent, broadband connection, I think Apache detected it and assumed I was using Apache as a Web sever. How can I fix this? 2nd issue. I downloaded and extracted PHP 5.0.4-Win 32. Although I read the installation instructions, I have no clue how to install it. There are several files and I don't know which to execute to install PHP. Or which file (if any) to configure. Can someone please help me? Tony Suggest you try this product which installs Apache, PHP, MySQL (and more) at the same time: <http://www.reactorserver.com/>. It makes it very easy to set up a test server on a Windows box. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ftp_put() problem
I'm trying to FTP a string value as a file without writing it to the local server as a file, but I can't get ftp_put() to work. If I read a file from the server, ftp_fput() works: $fh = fopen("test.txt", "r"); $upload = ftp_fput($conn_id, $destination_file, $fh, FTP_ASCII); if(!$upload) { echo "FTP upload has failed!\n"; } else { echo "Uploaded to ".$ftp_server." as ".$destination_file."\n"; } But trying to avoid writing to the local server by using ftp_put() instead, this does not work: $source = "This is a test file. This is a test file.\nThis is a test file."; $upload = ftp_put($conn_id, $destination_file, $source, FTP_ASCII); I don't understand why ftp_put() isn't able to use $source as a string value, but substituting ftp_fput() into the script and using a file handle does work. I'm trying to avoid writing a file to the local server just to be able to use ftp_fput(). -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cURL FTP
On Dec 15, 2004, at 8:47 AM, Ian Firla wrote: On Wed, 2004-12-15 at 08:27 -0500, Lowell Allen wrote: I'm trying to FTP a text file from a commercial hosting server, but the file isn't being transferred and I'm not getting any feedback from the script. Here's the code: [snip] $c = curl_init("ftp:// $username:[EMAIL PROTECTED]"); $fh = fopen("test.txt", "r") or die($php_errormsg); curl_setopt($c, CURL_UPLOAD, TRUE); curl_setopt($c, CURL_TRANSFERTEXT, TRUE); curl_setopt($c, CURL_INFILE, $fh); curl_setopt($c, CURL_RETURNTRANSFER, TRUE); $result = curl_exec($c); curl_close($c); echo("".$result."\n"); [snip] Try opening the file "rw". At the moment, you're opening it read only. Thanks for the reply, but I'm opening test.txt as the local file for uploading. I don't need to write to it. (I tried it anyway, same result -- no result.) I've switched to ftp_put() and ftp_fput() and will start a new thread with a different subject line. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cURL FTP
I'm trying to FTP a text file from a commercial hosting server, but the file isn't being transferred and I'm not getting any feedback from the script. Here's the code: $username = "whatever"; $password = "somepassword"; $remote_domain = "somedomain.com"; $remote_file_location = "/upload/testtransfer.txt"; $c = curl_init("ftp:// $username:[EMAIL PROTECTED]"); $fh = fopen("test.txt", "r") or die($php_errormsg); curl_setopt($c, CURL_UPLOAD, TRUE); curl_setopt($c, CURL_TRANSFERTEXT, TRUE); curl_setopt($c, CURL_INFILE, $fh); curl_setopt($c, CURL_RETURNTRANSFER, TRUE); $result = curl_exec($c); curl_close($c); echo("".$result."\n"); Running this produces nothing -- $result has no value and no file is transferred. cURL is available on the server I'm sending from because I use it successfully for a couple scripts. The "upload" directory has permissions set to 777. The server I'm attempting to upload to runs in a shared hosting environment. I've read what I think are the relevant sections of the manual. I'd appreciate info or links to info on setting up cURL to do an FTP transfer and return the success or failure of the operation. Thanks. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] antique PHP problem
I'm doing a project on a server with an old version of PHP -- 4.0.6 on Apache 1.3.22 on FreeBSD and I'm having a problem with session variables. From code in a script that receives a post: - session_start(); $HTTP_SESSION_VARS["m_name"] = get_magic_quotes_gpc() ? stripslashes($HTTP_POST_VARS["m_name"]) : $HTTP_POST_VARS["m_name"]; - Then later I can successfully echo the posted value with: - htmlentities($HTTP_SESSION_VARS["m_name"]) - The posted value is shown as expected, which means the session variable is set, right? At the end of the receiving script page I have a link back to the form where the values were posted from, and in the original form I check for session variables in order to re-populate the form with them if they're present: - session_start(); $m_name = isset($HTTP_SESSION_VARS["m_name"]) ? $HTTP_SESSION_VARS["m_name"] : ""; - Then in the original HTML form field: - - But $m_name == "" and the field is blank. The same code works as expected on a different server running PHP 4.3.8 on Apache 1.3.31 on Linux. I think I'm stuck with 4.0.6 for this project. I'd appreciate any suggestions on what I should check/advice on using $HTTP_SESSION_VARS. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] upload changes accented character
I've built a system which uploads a tab-delimited text file saved from Excel, then uses the text file to update a MySQL database. But when the text file contains an "é" character (confirmed by viewing in a text editor before uploading), the character is converted to some other weird character -- a capital Z with what looks like an inverted circumflex accent above it. This replacement character is stored in the database and output to HTML pages. It doesn't matter if I use htmlentites() on the data before storing in MySQL, the weird Z character is still what's written to the database. And I'm not able to do a string replacement to make it "é" again (or "é"), because when I paste the weird accented Z character into a PHP file and save, the character is converted into " }" (a space and closing bracket). Perhaps this isn't a PHP problem, but can anyone point me towards a solution? Setup is PHP 4.3.2 on FreeBSD 4.10, Apache 1.3.27. TIA -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping php content output for valid html
On Apr 16, 2004, at 3:40 AM, Merlin wrote: Hi there, I am just validating html generated by a php page. There is an error which comes up if ther is a dash in the content text. Those characters come out of a database. Is there a command in php which is escaping those characters for valid html output? Something like urlencode, but for text escaping all such signs? Here is the error msg: non SGML character number 150 This is the text: normal – text If the text is coming from a database, how did the invalid character get into the text in the first place? It sounds like the problem is with the original HTML editor, not with PHP. For example, the current version of Adobe GoLive still uses the invalid code – for an en dash (the valid code is –). A good reference chart for correct character entities is here -- <http://www.roselli.org/adrian/articles/character_charts.asp>. You could set up str_replace() translations to correct invalid character entity codes before displaying. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
On Apr 15, 2004, at 11:47 PM, Anthony Ritter wrote: John W. Holmes <[EMAIL PROTECTED]> wrote in message: Remember... we're laughing with you, not at you. You forgot to call mysql_query() in your code. :) . Hmmm... I wish it was as simple as that. I inserted the mysql_query() below but it still doesn't upload the file nor does it throw an error. If you get a chance please take a look and advise. Again, my thanks for your help, TR // connect to the database // (you may have to adjust the hostname,username or password) MYSQL_CONNECT("localhost","root","mypass"); mysql_select_db("mydb"); $uploadfile = $_FILES['form_data']['tmp_name']; $uploadname = $_FILES['form_data']['name']; $uploadtype = $_FILES['form_data']['type']; $uploaddesc = $_POST['desc']; [snip] You might try using "$HTTP_POST_FILES" rather than "$_FILES" -- was necessary in my code recently. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP editor
What I am looking for is something to work pretty fast, have code autocompletion (even for functions defined in the included files like zend does) and also code ident in a similar manner with zend studio I just installed Zend Studio because I was able to buy it through Adobe at a discount when upgrading GoLive. I've been comfortable working in the source editor of GoLive, and the new version has improved support for PHP, but I assumed moving to Zend Studio would improve my efficiency. This thread makes me wonder if I should switch or stay with the simple workflow I'm used to. Opinions? Zend Studio endorsements? Is it worth the time to learn to use? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Upload file field not working as a form element
>> The uploaded file name will be $HTTP_POST_FILES["filename"]["name"] -- use >> that rather than $_POST["filename"]. > > I'm sorry I don't understand. What is the extra ["name"] for? When I use > this in the insert into the value that is inserted into the database is > Array, as opposed to the actual filename. The $HTTP_POST_FILES array works for me. Maybe you need to try the $_FILES array instead. Take a look at the info in the manual: <http://www.php.net/manual/en/features.file-upload.php#features.file-upload. post-method>. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Upload file field not working as a form element
> All I am trying to do is insert the file name, not the file. The file is > being uploaded to the server in a specific location. All I need is the > filename inserted into the database. I've gotten the upload part to work and > everything I just can't get the file name inserted for God knows what > reason. I removed the upload code and am simply trying to insert the > filename and userid into the database. The userid goes in but I cannot get > the file name inserted. > > Here is the form: > enctype="multipart/form-data" name="form1"> > >value=""> >disabled> > > The uploaded file name will be $HTTP_POST_FILES["filename"]["name"] -- use that rather than $_POST["filename"]. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's your favorite PHP weather code?
> I'm looking for some code to get the latest weather and put it on my > webpage, and have it very customizable. What are your favorites? > I've only tried this one -- found it easy to work with: <http://www.cruelacid.com/?page=weather> -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP REDIRECT
> --- Lowell Allen <[EMAIL PROTECTED]> wrote: [snip] >> Am I overlooking a better solution? > > I'm not sure. To be clear, you're saying that the following two things do > not behave the same for you: > > header('Refresh: ...'); > > > > Is this right? I suspect that you might be comparing these instead: > > header('Location: ...'); > > Your suspicion is correct, as pointed out earlier by Stuart. Thanks to both of you for the explanation, and sorry for the confusion. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP REDIRECT
> --- Chris <[EMAIL PROTECTED]> wrote: >> You can't view the page and have PHP redirect it. You would need to >> use a refresh tag or JavaScript. > > I assume by meta refresh tag, you mean this: > > http://example.org/";> > > What most people seem to not realize, is that the http-equiv attribute is > just a way to specify HTTP headers in a meta tag. This is handy when you > want to do so in static pages, but PHP has a more proper way to specify > headers: > > http://www.php.net/header > > This creates a real HTTP header, and there is no reason for any PHP > developer to use a meta tag for this purpose. Well, how about this situation as a reason: You must do authorization, then force a file download, and you want to also display a link to the file with the typical "click the link below if the download does not start automatically". I couldn't figure out how to display a page (after authorization), then use the PHP header redirect to force the download while keeping the same page display. However, using a meta refresh to a script that forced the download (without producing any display) was an easy solution. Am I overlooking a better solution? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can PHP redirects be detected?
> On Mon, Feb 09, 2004 at 02:31:16PM -0500, Lowell Allen wrote: >> A recent thread on the WebDesign-L raised the question of whether search >> engines can detect (and penalize sites for) PHP redirects of the form: >> >> header("Location: http://www.whatever.com/";); >> >> I don't see how that could be the case, since the redirect occurs on the >> server before any HTML is output to the browser. Someone else says: >> >>> No, the header() redirect immediately tells the /client/ to make a second >>> GET request at a different location and the client (search bot) must >>> actively make that 2nd request to the "Location:" URL (what happens if you >>> request amazon.com) Note this is different from simply sniffing the UA >>> string from a single request and serving altered content. > > This is accurate (the explanation from webdesign-l). Try it yourself: > [snip] > >> What say you, PHP list? Would it be better (in terms of search engine >> detection) to use include() to serve different or altered content? > > Do neither. Create excellent content, structured well, and the search > engines will reward you for this. Try to trick them, and they will > likely figure it out and penalize you. I'm not interested in tricking search bots. However, for the sake of user-friendly URLs, I use mod_rewrite to send most requests to index.php, then based on the request string I include() different content. I wanted to verify that wasn't creating a problem with search engines. > However, if you're asking whether or not Google can determine if you're > using include() to serve up different content based on the UserAgent or > perhaps the IP address, then no, bots can't figure that out. Unless > they switch useragents/IPs and compare the results that they get. Or > unless a human complains that the listing is innacurate. etc... Thanks Joel and thanks John for confirming the WebDesign-L explanation. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can PHP redirects be detected?
A recent thread on the WebDesign-L raised the question of whether search engines can detect (and penalize sites for) PHP redirects of the form: header("Location: http://www.whatever.com/";); I don't see how that could be the case, since the redirect occurs on the server before any HTML is output to the browser. Someone else says: > No, the header() redirect immediately tells the /client/ to make a second > GET request at a different location and the client (search bot) must > actively make that 2nd request to the "Location:" URL (what happens if you > request amazon.com) Note this is different from simply sniffing the UA > string from a single request and serving altered content. What say you, PHP list? Would it be better (in terms of search engine detection) to use include() to serve different or altered content? TIA -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a way to automate user logout
> I used cron to do this as well; but i devised a much simpler, elegant > solution that is cross-browser and event-based and not schedule-based. > > I basically have a javascript include file that instantiates a function that > counts down in T-minus 10 minutes fashion. at 9:30 the browser pops a > window and says "you appear to be inactive; would you like to continue > working?" clicking on yes closes the popup and resets the timer; not > clicking expires the popout which redirects the parent page to the logout. > clicking on "log me out" basically circumvents the 30-second countdown > straight to the logout. > > to handle the alt+F4-happy crowd i devised a way to pop a special logout > window when the browser is closed. this child window destroys sessions and > makes database logs; this window closes itself. > > this happened to work for me, YMMV. > > ~phillip jackson I've recently faced a similar issue. I lock CMS database records during editing so multiple users can't edit simultaneously. It's easy to unlock the records via PHP if the user goes to any other area of the CMS or if she logs out. The problem is that users often don't log out, and sometimes leave directly from an edit screen. I tried using the Javascript onunload event to open a new window which runs a PHP script to unlock the record then close itself, but that doesn't work if pop-up blocking software is being used. Does your method do something similar? Does it work with pop-up blocking? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] transactions
> Is there anyway to do something similar to Transactions in mysql? > Yes -- <http://www.mysql.com/doc/en/ANSI_diff_Transactions.html> -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spelling without aspell/pspell?
> Hi, > > I just found a really nice set of javascripts for spell-checking a > textarea before submitting, which is really nice, BUT is shell_exec()'s > to aspell, which neither my host or my staging server has installed. > It works with both PHP and Perl too. > > There's a demo here: > http://www.netjs.com/speller/ > > What I'd like to know is if there's any other PHP-oriented solutions to > spell checking that I might be able to integrate (with a fair amount of > hacking) into this solution -- or perhaps a complete solution that > doesn't require any compiling or libraries exists Just FYI -- if you've searched for information on a spell checker, I'm sure you saw Jspell -- <http://www.jspell.com/jspell.html>. It's Java and Javascript, but I found it fairly easy to add to a PHP CMS. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Locking and unlocking records
I need to implement database record locking and unlocking. I want to prevent multiple users of a content management system from editing the same record simultaneously, which can result in one user's edits being overwritten. I can use PHP to lock a record when it's opened, and unlock it when it's updated or if the user goes anywhere else within the content management system (or logs out), but I need to account for a user leaving the CMS directly from the edit screen. I'm not aware of any way to do that other than using a Javascript onunload event to open a new window, run a PHP script, and close the new window onload -- very nasty and unreliable with pop-up blocking so popular. Can anyone suggest an all-PHP way? TIA -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Calendar.
> Hi, > Is there any PHP function or set of PHP files that allows me to print the > current month in calendar format ? > You should write one. Here's mine, which I'm sure could be improved: HTH -- Lowell Allen function display_calendar($mon, $year) { // find current date and day of the month for comparison $today = getdate(); $current_mon = $today['mon']; $current_mday = $today['mday']; $current_year = $today['year']; // if no arguments provided with function call if ((!isset($mon)) || ($mon == "")) { $mon = $today['mon']; } if ((!isset($year)) || ($year == "")) { $year = $today['year']; } // establish timestamp values from arguments provided $cal_date = getdate(mktime(0, 0, 0, $mon, 1, $year)); $month = $cal_date['month']; $weekday = $cal_date['weekday']; // find position of first day of month, 0 thru 6 for Sun. thru Sat. $firstdayposition = $cal_date['wday']; // find day of year of first day of month $firstday_yearday = $cal_date['yday']; $lastday = getdate(mktime(0, 0, 0, $mon + 1, 0, $year)); // find position of last day of month $lastdayposition = $lastday['wday']; // find day of year of last day of month $lastday_yearday = $lastday['yday']; // find number of days in current month $numdays = $lastday_yearday - $firstday_yearday + 1; // find last day date of previous month $prevmonlastday = getdate(mktime(0, 0, 0, $mon, 0)); $prevmonlastdaydate = $prevmonlastday['mday']; // html layout for month if ($firstdayposition != 0) { $caldate = $prevmonlastdaydate - $firstdayposition + 1; $color = "#666"; } else { $caldate = 1; $color = "#333"; } ?> S M T W T F S " . $caldate . "\n\n\n"); } else { echo("" . $caldate . "\n\n\n"); } } else { if (($caldate == $current_mday) && ($mon == $current_mon) && ($year == $current_year) && ($color == "#333")) { echo("" . $caldate . "\n"); } else { echo("" . $caldate . "\n"); } } $i = $i + 1; if ($i - 1 == $firstdayposition) { $caldate = 1; $color = "#333"; } elseif (($i - 1) == ($numdays + $firstdayposition)) { $caldate = 1; $color = "#666"; } else { $caldate = $caldate + 1; } } ?> http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regexp with mysql
> i hope someone can help it should be easy but i still don't get it. > > i have a field which has numbers seperated via a comma > for example 1,2,3,12,14,23,51 > > now if i was to do a search for a the rows that has '2' in it i do > SELECT * FROM table WHERE ids REGEXP "2" > > will it show fields that has 12 22 23 etc...?? or just 2 Yes. I think you need something like: $sql = "SELECT * FROM table WHERE ". "ids REGEXP '2' AND ids NOT REGEXP '([1-9]2)|(2[0-9])'"; But I don't profess to much knowledge of regular expressions. Check the MySQL documentation. I saw something about REGEXP there recently. Also, there's a MySQL discussion list at <http://lists.mysql.com/>. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL rewriting...anybody done this?
[snip] > > I took out the .php part...and even tried it with [L] tacked to the end of > the second linenot working > Heres how my .htaccess looks now: > > RewriteEngine On > RewriteRule ^show/(.*)/(.*)/(.*) /show.php?category=poetry&sid=$2&id=$3 > > I even took out the space which was in category. > > Any ideas? > [snip] Make sure you upload the .htaccess file as ASCII mode, not binary. (That wasted lots of my time recently.) -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL rewriting...anybody done this?
> On Thursday 15 January 2004 02:44, Ryan A wrote: > >> It seems to be partly working. >> >> /* >> How isn't it working? What happens? I would try one variable first, get >> that working, then add the others. Also, I am not sure how it will >> handle the space in "Beginners Corner". Try passing simple values first. >> */ >> Its a bit hard to explain what happens so see for yourself: >> Heres the index page: >> http://www.rizkhan.net/articles/articles.php >> Heres the actual page: >> http://www.rizkhan.net/articles/show.php?category=Beginners%20Corner&sid=1&; >> id=1 and then if you modify it to: >> http://www.rizkhan.net/articles/show/Beginners%20Corner/1/1 >> >> it just shows me the index...which even links wrong. >> >> Ok, will try to pass a value without the space in between. > >>>> RewriteRule ^show/(.*)/(.*)/(.*).php >>>> /show.php?category=Beginners%20Corner&sid=$2&id=$3 > > It doesn't look like your rule would match. Try: > RewriteRule ^show/(.*)/(.*)/(.*) > > Another way to achieve a similar result without using Rewrite is to parse > $_SERVER['REQUEST_URI'], and possibly $_SERVER['PATH_INFO'] > > Eg if your link is: > > http://www.rizkhan.net/articles/show.php/Beginners%20Corner/1/1 > > Then $_SERVER['REQUEST_URI'] would contain > > /articles/show.php/Beginners%20Corner/1/1 > > and $_SERVER['PATH_INFO'] would contain > > /Beginners%20Corner/1/1 Ryan, I'm doing what I believe Jason is indicating above. I'm sure in your research you read the articles about URL rewriting on A List Apart, specifically this one: <http://www.alistapart.com/articles/succeed/>. Using a similar approach, I'm saving page content in a database with the unique identifier set to the desired value of $REQUEST_URI. After redirecting all requests to index.php as described in the article, I use code in index.php similar to what's in the article, plus this for the database content: - // check for database content $conn = db_connect(); if (!$conn) { $db_error = mysql_error(); include("error_page.php"); exit(); } // get the page details from db $request = substr($REQUEST_URI, 1); $results = mysql_query("SELECT DisplayStatus FROM Pages WHERE MenuPath='$request' AND DisplayStatus='Y'"); if (!$results) { $db_error = mysql_error(); include("error_page.php"); exit(); } if (mysql_num_rows($results) > 0) { include("page.php"); exit(); } // if request has not been matched, include custom error page include("notfound.php"); exit(); - That pulls page content based on $REQUEST_URI. I build site menus from the database, using values from the MenuPath field as URLs. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql selecting question
> I have a question > I have to select a group of person i.e > $query = "SELECT * FROM table WHERE id = <10"; > > my question is that can we order order in random mode?? or do we have to > program it in php > > any help is appreciated Not a PHP question, but if you're using MySQL version 3.23.2 or later, and you only want to return one random result you can use: $query = "SELECT * FROM table WHERE id<10 ORDER BY RAND() LIMIT 1"; I don't know if that works without the LIMIT clause; give it a try. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload and PullPicture???
> Hello... I'm trying to upload a picture along with other information. > > I have several fields to input, such as name, address, etc. (and I get those > to go to the MySQL database with no problem). But on the same page I want > the user to be able to pick a picture of themself from their harddrive and > upload it. The script must either enter the address of the uploaded picture > to MySQL so it will show up with the user's info., or rename it something > like $id.ext. > > I know something like this needs to go in the html: > > > > Send this file: > > I'd like to just use one "submit" button that uploads everything (the > data to the database and the picture to my server). > > I've read the PHP manual but it's greek to this newbie... any help GREATLY > appreciated You say you read the manual, did you read the material at: <http://us2.php.net/manual/en/features.file-upload.php> ? Note in your example you're specifying a max upload size of only 30K. Following are snippets from a couple of my scripts. HTH. -- >From the uploading script: [snip] Upload image: Caption: Sequence: -- And from the script that's posted to (upload_process.php): $userfile = $HTTP_POST_FILES["userfile"]["tmp_name"]; $userfile_type = $HTTP_POST_FILES["userfile"]["type"]; $userfile_name = $HTTP_POST_FILES["userfile"]["name"]; // same file name that was uploaded if ($userfile_type == "image/gif") { echo("Problem with upload " . ($i + 1) . ": Image is GIF format. Only JPEG or PNG formats are supported.\n\n"); exit(); } if ($userfile_type != "image/jpeg" && $userfile_type != "image/png") { echo("Problem with upload " . ($i + 1) . ": Image file type is: " . $userfile_type . ". Only JPEG or PNG formats are supported.\n\n"); exit(); } $userfile_error = $HTTP_POST_FILES["userfile"]["error"]; if ($userfile_error > 0) { echo("Problem with upload: "); switch ($userfile_error) { case 1: echo("File exceeded upload_max_filesize"); break; case 2: echo("File exceeded max_file_size"); break; case 3: echo("File only partially uploaded"); break; case 4: echo ("No file uploaded"); break; } echo("\n\n"); exit(); } // keep same name as uploaded, specify where it's moved to $upfile = $DOCUMENT_ROOT . "/i/" . $userfile_name; if (is_uploaded_file($userfile)) { if (!move_uploaded_file($userfile, $upfile)) { echo("Problem: Could not move file to destination directory.\n\n"); exit(); } } else { echo("Problem: Possible file upload attack. Filename: " . $userfile_name . "\n\n"); exit(); } // save file information to database $conn = db_connect(); if (!$conn) { echo("Error connecting to database: " . mysql_error() . "\n/n"); exit(); } $PagePath = get_magic_quotes_gpc() ? htmlentities($_POST["menu_path"]) : htmlentities(addslashes($_POST["menu_path"])); $Caption = get_magic_quotes_gpc() ? htmlentities($_POST[$cp]) : htmlentities(addslashes($_POST[$cp])); $insert_sql = "INSERT INTO Images SET PagePath='$PagePath', FileID='$userfile_name', " . "Caption='$Caption', Sequence='$_POST[$sq]', LastMod=NOW(), UploadedBy='$valid_user'"; if (@!mysql_query($insert_sql)) { echo("Error adding image information to database: " . mysql_error() . "\n\n"); exit(); } echo("" . $userfile_name . " uploaded sucessfully and image information saved.\n"); -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Rename generates level 2 warning but works
> Lowell Allen wrote: > >> >> Try using $HTTP_POST_FILES['uploadedFile']['name'] instead. I wasted a bunch >> of time yesterday with an upload script that did not recognize files when >> using "$_FILES", but worked fine with "$HTTP_POST_FILES" -- PHP 4.3.4 on >> Linux. >> > Thank you for the suggestion. Unfortunately, it didn't resolve the > issue. Still getting the warning AND the rename function works. Odd > indeed... > > Thanks, > Roger > OK, well how about this -- you said your code is: $rename = time(); $old_name = $_FILES['uploadedFile']['name']; $read_extension = explode(".", $old_name); $ext = $read_extension[1]; $new_name = $rename.".".$ext; rename($old_name, $new_name); And your error message is "rename() failed (No such file or directory)", but isn't $_FILES['uploadedFile']['name'] the original file name before uploading, whereas $_FILES['uploadedFile']['tmp_name'] is where the file was uploaded to on the server. So the first is just a name, and the second is the file location. Also, you're defining what $new_name is before you even use rename(), so even if rename() fails, you've set the desired value for $new_name. But what you have not done is actually move the uploaded file. If it's being uploaded to /tmp, it will be deleted when your script ends. So, I think you need to pass rename parameters that are file locations. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Rename generates level 2 warning but works
> I have this magical script which uses rename. A visitor to the site > uploads a file and I want to rename it to a timestamp. Oddly enough, > the rename() function actually works, it renames the file AND then > generates a level 2 warning: > > Error code: 2 > Error message: rename() failed (No such file or directory) > > Why does it work AND create a warning? > > Here's the snippet of code: > $rename = time(); > $old_name = $_FILES['uploadedFile']['name']; > $read_extension = explode(".", $old_name); > $ext = $read_extension[1]; > $new_name = $rename.".".$ext; > rename($old_name, $new_name); > > I know I can suppress the the warning with @, but I'm more interested in > WHY this warning gets generated. I'm using PHP 4.2.2 on a Linux box. > Any hints or suggestions are greatly appreciated... Try using $HTTP_POST_FILES['uploadedFile']['name'] instead. I wasted a bunch of time yesterday with an upload script that did not recognize files when using "$_FILES", but worked fine with "$HTTP_POST_FILES" -- PHP 4.3.4 on Linux. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Selecting between using letters
> How would I create a select statement in MySQL that would return a range of > records from the LastName field where the value starts with a designated > letter - for example, returning the range where the first letter of LastName > is between A and E... > > Any help would be greatly appreciated. $sql = "SELECT * FROM table WHERE LastName REGEXP '^[A-E]'"; HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Structuring keyword searches
> I'd better apologize at the outset as I'm not sure this is strictly a PHP > problem - though I'm using PHP as the means of building the application. > Anyway, here goes: > > I'm creating a website that will function as a directory of services within a > specific area of the UK charity sector. A variety of groups will input the > content via a custom built CMS and this content will then be available to the > general public. One of the requirements is that a keyword search facility is > built into the application allowing end users to search for services based on > a variety of words they might associate with them. > > What I propose to do is have a separate table of keywords/phrases that have > been previously entered by contributors. There will then be a separate table > linking the id field of the associated keywords with the id field of the > service in question. Herein lies the problem. > > The contributors will be presented with a multi-part form. When it comes to > the stage at which they will need to enter the relevant keywords for a service > there seem to me to two ways of dealing with this: > > 1.Allow the contributors to enter whatever keywords and phrases they wish. > > 2.Only allow contributors to have access to a restricted set of > keywords/phrases. > > The first of these options would run the risk of creating an unmanageably > large and devalued set of keywords/phrases. The second option would seem to > result in a set of keywords that are too generalized to be of much benefit to > the ultimate end users. > > Are there any accepted approaches to tackling such a problem which anyone > could point me towards? I'm sure it must have been encountered before though > I've been unable to find much on this after extensive googling and searching > through mailing list archives. I like the Luke Welling, Laura Thomson approach for keyword searching described in "PHP and MySQL Web Development" -- <http://www.lukelaura.com>. The system described is your option (1) above, and allows the keywords to be weighted by the contributors. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dynamic menu building
> Dear list, >I have been facing problems while building dynamic menu. I am using > database to store the Menu items. I am having two fields in the database > table called ParentID, ChildID. > ParentChild > 10 > 20 > 30 > 41 > 51 > 61 > 73 > 83 > 94 > 108 > I want to build menu from this. Please suggest me the way to do so. > > Thanks in Advance The following will build a two-level menu as an unordered list, with the second level appearing if its parent is selected. The variable "$gpid" is grandparent id for a third level, which is not displayed in this menu. Some checks are done in order to display a menu item differently if it is the current page or an ancestor of the current page. (In the design I took this example from, third level menus are shown in a different place.) // build menu array $menu_sql = "SELECT id, parentid, menuname, FROM pages"; $menu_result = mysql_query($menu_sql); if (mysql_num_rows($menu_result) > 0) { while ($menu_row = mysql_fetch_array($menu_result)) { $menu_array[] = array($menu_row["id"], $menu_row["parentid"], $menu_row["menuname"]); } } // home id is 10 $id = isset($_GET["id"]) ? $_GET["id"] : 10; $pid = isset($_GET["pid"]) ? $_GET["pid"] : 0; $gpid = isset($_GET["gpid"]) ? $_GET["gpid"] : ""; // display menu echo(""); foreach ($menu_array as $menu) { // if the parent id is 0, menu item is main level if ($menu[1] == "0") { if ($menu[0] == $id || $menu[0] == $pid || $menu[0] == $gpid) { echo("" . $menu[2] . ""); foreach ($menu_array as $menu2) { if ($menu2[1] == $menu[0]) { $subcount[] = $menu2[1]; } } if (count($subcount) > 0) { echo(""); foreach ($menu_array as $menu3) { if ($menu3[1] == $menu[0]) { if ($menu3[0] == $id || $menu3[0] == $pid) { echo("" . $menu3[2] . ""); } else { echo("" . $menu3[2] . ""); } } } echo(""); } echo(""); } else { echo("" . $menu[2] . ""); } } } echo("\n"); HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Expiration Problem....
> Our hosting company sets session vars to expire every 15 minutes. > > I've setup an Admin Center for users to enter various types of information, > some of which, for example entering a basketball team roster, can take > slower users upwards of 25 minutes or more. > > The result? Admin user spends 25 minutes entering data; clicks the submit > button; then is redirected to the login page because their session > expired! -- all form data is lost -- not good > > Is there a way to extend the php session timeout for particular pages? > Alternatively, is there a way, other than using cookies, to store user data > from page-to-page? > > Thanks for any leads, Yeah, I get occasional complaints about this problem -- although I don't have to contend with sessions expiring every 15 minutes! I've found that it's usually possible to use the browser back button to return to the form with all values still in place (Windows 98-IE6 being an exception), then open a new window to log in again, then return to the form window to submit. Those instructions can accompany your "not logged in" message. Admittedly an inelegant solution, but it's better than losing the form data. In my situation, I've considered rewriting the PHP script that's receiving the form post so that if the session has expired it will re-display a simplified version of the form (without showing protected content) with the posted data, and provide a link to open a login form in a new (small) window. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions, ending and starting new with just a click
> Hey guys and gals, > > I am working on a shopping cart and using some code to write it from 2 > temp databases to a full end databases (which will then be used via PERL > to send to an archaic order system) but right now I need to come up with > a way to clear their current session ID after finalizing the order and > then dropping them into the new session variable so they can start a new > order. Why do you need to start a new session? Why not record the order to the database with a unique identifier, and then just empty the shopping cart? If they do a new order, you can give it a different id when saving to the db. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick ereg_replace question
> I need a regular expression which will eliminate all characters except > numbers, period, and +, -, *, or / > > I am currently using: > $new_value = ereg_replace('[^0-9\.-/+*]', "", $value); > > However, this seems to eliminate - as well. Any help would be appreciated. Try listing the - as the first character (or last) so it's not seen as showing a range. > Also, any good references for regular expressions? O'Reilly's "Mastering Regular Expressions", by Jeffrey Friedl. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Having fits with input to array
> I have a series of commands like so (with different programs on each line): > > display_pgm("bash"); > > Here is the bare bones of the function 'display_pgm': > > function display_pgm ($pgm) { > $cmd = " -C $pgm --no-headers -o > pid,fname,state,vsz,start_time,flag,user,cputime,args --cols 200"; > $ps = `ps $cmd`; > $ps2 = ereg_replace("\n", ",", $ps); > > eval("\$psArray = array(\$ps2);"); > print_r($psArray); > } > > If I can't get this part to work the rest of the function is a no-go. When I > do this I get only one element in my array instead of the 3-4 I should be > getting. I'm using bash for testing since I know that will always give a > return. > > I've also tried: > eval("\$psArray = array(\"$ps2\");"); > and > eval("\$psArray = array($ps2);"); - This one gives me a parse error > (Parse error: parse error, unexpected T_STRING, expecting ')' in > /var/www/html/ps.php(25) : eval()'d code on line 1) > > When I have used the same eval in another page I get each part separated by > the comma as a separate element in the array. What in the world am I doing > wrong? For $psArray to be an array, shouldn't it be: eval("\$psArray[] = array(\$ps2);"); -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help create community newbie guide to security
> Lawrence Kennon wrote: >> For a BBS I would like to let users post links to >> various resources. They 'post' a message to the BBS >> via a form and that is stored in a MySQL db, then the >> content of their 'post' is available to other users on >> the BBS. Currently I strip out all PHP/HTML with the >> strip_tags() function. What I would really like to do >> is allow a limited set of HTML tags (like the anchor >> tag) but at the same time implement reasonable protection. > > Get yourself a bbcode parser from phpclasses.org so you can use things > like [b] [/b], and [url=] [/url], etc. This is safer than trying to deal > with actual HTML, imo. Then use htmlentities() on the data instead of > strip_tags(), so the users can actually write something like and > not have it stripped. [snip] I have a "best practice" question related to this thread. I usually store data in MySQL without any translation, then use htmlspecialchars() before displaying as HTML. This works well for a content management system where administrators are entering data in forms and storing, but perhaps it's not appropriate for storing information from website visitors. If that information should be translated before storing, then I'd have some stuff that needs htmlspecialchars() applied before displaying, and some stuff that does not. My question is, are there any disadvantages to always following the procedure described below? - Use htmlentities() on everything before storing in the database - Retrieve and display in cms forms without any translation - Retrieve and translate mnemonic codes (like [b] [eb] to ) before displaying as HTML - Retrieve and use html_entity_decode() if needed for non-HTML use (like for plain text email), or if I actually *WANT* to use stored HTML code (like for HTML-formatted email) TIA -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help With Recursion && Multi-Dimensional Arrays
t;); foreach ($sublevel2 as $sublink2) { $menu_count++; if ($menu_count < count($sublevel2)) { echo("" . $sublink2[2] . " | \n"); } else { echo("" . $sublink2[2] . "\n\n"); } } } } elseif ($gpid != "" && $gpid != "0") { // display children of grandparent page, then children of parent page // build submenu of children of grandparent page foreach ($menu_array as $subcheck) { if ($subcheck[1] == $gpid) { $sublevel[] = array($subcheck[0], $subcheck[1], $subcheck[2]); } } if (count($sublevel) > 0) { $menu_count = 0; echo("\n"); foreach ($sublevel as $sublink) { $menu_count++; if ($menu_count < count($sublevel)) { if ($sublink[0] == $pid) { echo("" . $sublink[2] . " | \n"); } else { echo("" . $sublink[2] . " | \n"); } } else { if ($sublink[0] == $pid) { echo("" . $sublink[2] . "\n\n"); } else { echo("" . $sublink[2] . "\n\n"); } } } } // build submenu of child pages of parent page foreach ($menu_array as $subcheck2) { if ($subcheck2[1] == $pid) { $sublevel2[] = array($subcheck2[0], $subcheck2[1], $subcheck2[2]); } } if (count($sublevel2) > 0) { $menu_count = 0; echo("\n"); foreach ($sublevel2 as $sublink2) { $menu_count++; if ($menu_count < count($sublevel2)) { if ($sublink2[0] == $id) { echo("" . $sublink2[2] . " | \n"); } else { echo("" . $sublink2[2] . " | \n"); } } else { if ($sublink2[0] == $id) { echo("" . $sublink2[2] . "\n\n"); } else { echo("" . $sublink2[2] . "\n\n"); } } } } } elseif ($pid == "0") { // only display children of current page // build submenu of child pages of current page foreach ($menu_array as $subcheck2) { if ($subcheck2[1] == $id) { $sublevel2[] = array($subcheck2[0], $subcheck2[1], $subcheck2[2]); } } if (count($sublevel2) > 0) { $menu_count = 0; echo("\n"); foreach ($sublevel2 as $sublink2) { $menu_count++; if ($menu_count < count($sublevel2)) { echo("" . $sublink2[2] . " | \n"); } else { echo("" . $sublink2[2] . "\n\n"); } } } } Sorry for all the code, and sorry I can't offer an example URL (don't think the client would like me to at this stage), but HTH. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cell Colour Change!!! HELP
> I have a cell in my view.php which shows up in all my pages of my site. This > is wha tI need to do: > > If the user is on the home page(index.php) then the cell colour should be > blue. > If the user is on the compose page(compose.php) then the cell colour should > be green > If the user in on the registration page then the colour should red > and if the user is on the contac us then the color of thecell should be > yellow! > > Can some one point me to an example or provide me with a basic php code > structure to work with. You could check the name of the current page and set a variable for the cell color accordingly. Something like: if (eregi("index", $PHP_SELF)) { $color = "blue"; } elseif (eregi("compose", $PHP_SELF)) { $color = "green"; } elseif (eregi("register", $PHP_SELF)) { $color = "red"; } elseif (eregi("contact", $PHP_SELF)) { $color = "yellow"; } else { $color = ""; } HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dictionary
> Got a bit of a peculiar problem. > > I'm recovering a hard disk which has got corrupted (work for a data > recovery business). > > I've got a whole stack of text files which I need to clean up to try and > get back some of the text information > here's an example snippet > [snip] > > What I want is a dictinary of some sort to try and eliminate the lines > where and english word does not exist !! > > Anyone got any ideas ... greatly appreciated The GNU Aspell project includes dictionaries: <http://ftp.gnu.org/gnu/aspell/dict/> -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mailing List
> I would like to setup a mailing list for my company. > I have a database containing email address of my clients along with other > details. > How can I send them mails ? > If i write a script containing the mail function and loop the address, I > think that might generate a script timeout error. I feel increasing the > script timeout is not a good solution. I would like to know how you manage > such situations. I feel this is a common problem but i didnt find any > solution on the net. Do I need to use any sw or are there any already > available scripts. I built a queuing system to email to a large list. The general approach is to add a database table that stores the email message and tracks progress through the list. A PHP script called by a crontab checks the database to see if a mailing is in progress. If so, it selects a certain number of addresses and sends the message. By controlling the number of addresses selected and how often the crontab calls the script, the email rate is controlled. And using a crontab makes it a background process. The email message is created and list progress monitored through a content management system. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] more proplems with passing arrays
> I'm trying to pass an array variable from a search page to the results page > via GET. The $NAMES variable contains an array which is obtained from the > URL. Per a previous suggestion I've been trying SERIALIZE/UNSERIALIZE but > can't get the variable to pass correctly. To take a look at my test files > follow this URL... I have success using base64_encode before serializing an array to be passed. Like so: $serial_array = base64_encode(serialize($original_array)); Then in the code that gets the serialized array: $original_array = unserialize(base64_decode($_GET["whatever"])); HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
> I checked the session settings with phpinfo(); I get the following values: > session_save_path = /tmp > session.use_cookies = On > session.use_trans_sid = 1 > > I've created a folder on the same level as all the pages called > "ccb_sessions" and have CHMOD it to 777. > I have added the following snippet above session_start: session_save_path("/ccb_sessions");?> > When navigating to my test page I get the following error: > > Warning: open(/ccb_sessions/sess_bbbfa69631155d4097e0b0012c857c4a, O_RDWR) > failed: No such file or directory (2) in > /home/.paco/campuscb/campuscorkboard.com/MemberAccountDetails.php on line 2 > > Checking with my FTP client that file is there and has CHMOD values of 777. > I've done a Google search for "No such file or directory", found a bunch of > stuff for Python, nothing for PHP. [snip] > Other ideas? I think you need to provide a full directory path. I looked at my code and here's exactly what I do. First, I include some functions with a require_once() statement. One of the functions is prepath(): function prepath($url) { $prepath = ""; if (substr_count($url, "/")) { for ($i = 1; $i < substr_count($url, "/"); $i++) { $prepath .= "../"; } } return $prepath; } That lets me use the same statement in different directories. Then the page actually starts like this: require_once($req_fns); session_save_path(prepath($PHP_SELF) . "../ccb_sessions"); session_start(); Note that when I said my session data directory is on the same level as my publicly viewable files (public_html), I mean that the session directory is not contained within public_html, but is outside it at the same directory level on the server. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
> I'm trying to track down some issues with my site, and am trying to decide > if it's a session variable issue. On a random basis, it appears that session > vars are being dumped, deleted, or unset, as the site will break. Queries > based on session vars don't work, session vars not being displayed, etc. > This seems to happen most often after a page has been idle for a couple of > minutes and a refresh is done on the page. > > This is on a hosted site. I have checked the configuration settings with > phpinfo(); and session support is enabled. > > On all pages where I use $_SESSION[], I have session_start();?>. This has been double checked. > > 1) Do session vars timeout, or can they be set to timeout after a certain > length of time? > 2) Is there anything other than session_start(); that needs to be done when > using session vars? > 3) What other things can I check for? Most things are explained well by the online manual, and you should read and re-read the session documentation. That said, I'll also say that the documentation on sessions is not as informative as I'd like it to be, and I still get reports of sessions expiring before they should. Look at the output from echo phpinfo() and check these session configuration options: session.cookie_lifetime -- should be 0, lasts until quitting the browser session.use_cookies -- should be on session.use_trans_sid -- should be on Some things aren't explained very well, like what does "session.gc_maxlifetime" mean? The maximum time before garbage collection to remove session data that hasn't been used? But to minimize the chance of garbage collection on a shared server wrecking your sessions, you can specify a directory for saving session data. Create a directory (on the same level as your directory of publicly-viewable files if you can) and before the 'session_start();' line, do 'session_save_path("../my_sessions_dir");'. Also be aware that circumstances on the client side can mess with session cookies and cause the session to be lost, like using Internet Explorer with Entourage in Mac OS X. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session info stored on server
>> What's actually stored on the server when using sessions? >> >> I've built a content management system on a commercial host, PHP 4.3.2, >> Apache 1.3.28, and use session_save_path() to specify a directory. When >> someone logs in, I check the username and password against the database, and >> save username as a session variable -- $valid_user = $username; >> session_register("valid_user"); If I examine the directory specified by >> session_save_path(), I see something like "sess_4f5d...0367". Where's the >> session variable "valid_user"? Is it an array element of "sess_whatever", or >> are session variables stored in memory with only the ID stored on the >> server? > Open sess_4f5d...0367 in any text editor and you will see your variable > there. I can't. I'm unable to open or download or change the permissions. Is it an array? >> A related question -- I thought that by specifying a directory with >> session_save_path(), the session data would not be subject to garbage >> collection. However, when I examine the directory specified, I don't see any >> creation dates more than 24 hours old, and I know there have been instances >> where the Mac OS X Entourage/Internet Explorer bug have caused sessions to >> fail, so the user never logged out, and session_unregister() and >> session_destroy() were never called for those sessions. Why aren't those >> sessions still listed in the sessions directory? > session_start() runs garbage collector in current session save path > directory. The plus is you are not affected by other virtual hosts on > the same server. So if I want to create sessions that last indefinitely (as least as far as the server is concerned), do I need to write my own session functions that use a database to store the session ID? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session info stored on server
What's actually stored on the server when using sessions? I've built a content management system on a commercial host, PHP 4.3.2, Apache 1.3.28, and use session_save_path() to specify a directory. When someone logs in, I check the username and password against the database, and save username as a session variable -- $valid_user = $username; session_register("valid_user"); If I examine the directory specified by session_save_path(), I see something like "sess_4f5d...0367". Where's the session variable "valid_user"? Is it an array element of "sess_whatever", or are session variables stored in memory with only the ID stored on the server? A related question -- I thought that by specifying a directory with session_save_path(), the session data would not be subject to garbage collection. However, when I examine the directory specified, I don't see any creation dates more than 24 hours old, and I know there have been instances where the Mac OS X Entourage/Internet Explorer bug have caused sessions to fail, so the user never logged out, and session_unregister() and session_destroy() were never called for those sessions. Why aren't those sessions still listed in the sessions directory? Thanks for any insights. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Passed Multidimension Array
> I am trying to find out how to pass a multidimensional array within a hidden > input of a form. > Would it be something like this? > > > > Any advice would be forever appreciated... Here's a recycled reply from a similar question last month. To pass an array in a form, you should serialize it and encode it, then after receiving it you decode it and unserialize it. The example assumes register_globals is on: $portable_array = base64_encode(serialize($array)); You can then pass $portable_array as a form hidden input value. To turn it back into an array: $array = unserialize(base64_decode($portable_array)); -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XHTML / CSS
> First, excuse-me for this out of topic message. > > I am searching a good mailling-list for people trying to write standard > XHTML and CSS. css-discuss <http://www.css-discuss.org/mailman/listinfo/css-d> -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web server file perms || More than I can chew.....
> On my local machine (win2k pro, apache), no problems -- everything works > just as designed. > > Today I began testing on the live server; i.e. my client's hosting company > (linux, apache 1.3.27, php 4.3.1) -- that's when the trouble started. > > The site builder app builds static pages based on changes made by users in > our online administration center. When I test out creating a new site > section; i.e. triggering my make_file function(writes page content to new > file) I receive the following error: > > Warning: fopen(/local_server_path/file_to_create.php) [function.fopen]: > failed to create stream: Permission denied > > I've attempted to chmod(777) my testing directory via ftp client, which > appears to work; however, when I fileperms($file_in_test_dir), I get > chmod(644), so clearly I'm not the owner. > > Pardon my ignorance here, but I as yet know little about dir/file perms. > Should I contact the host and have them give me sufficient permissions? If you create a subdirectory of the root level public HTML directory, then PHP can create files there, but not in the root level directory. If you change permissions to 777, PHP can create files there, but it's not a good idea to have the permissions that wide-open. You might be able to get your commercial host to change who PHP is running as from "nobody" to your login identity, then PHP could write to the root level directory, but you might not be able to -- my main host says they're changing policy for security reasons to not allow that. You could put the static files in a subdirectory where PHP will have permission to create files. But this might require lots of reworking links depending on your site design, and thus not be a viable option. You could set up a PHP script to be executed by a crontab as a CGI. Done this way, PHP can write to the root level directory. This is what I did recently for a similar problem. The content management system provides a link for updating static HTML pages. That link (script) writes info to the database, flagging an update request. Every 5 minutes, a crontab calls the PHP CGI script that actually does the update. The script checks the database flag and does the updates if they've been requested (flagged). Bottom line -- discuss the problem with your commercial host and see what they suggest. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is there an issue using sessions with IE/Mac?
> I've built a log in system which sets the user's id as a session if > succesfully logged in. However, a user on IE5/Mac tells me that the site > logs her out even though she has entered the correct login details. I > have tried using her details on Firebird/Windows and have had no problems. > > Are there any known issues using php sesisons with IE5/Mac? For what it's worth (which may not be much), I've heard reports of problems with IE5.2 in OSX when used with Entourage. A colleague's session was failing after checking email with Entourage, and he said Microsoft confirmed the problem. However -- I've since gone to OSX and can't duplicate the problem on my system. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password systems
> Anyone have any sources of noun/verb/adjective lists for password > generation? Google search for Aspell and Pspell. Here's a link to Aspell info, which has a link to dictionaries: <http://aspell.net/> -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating files in public_html
My commercial host is changing policy so that PHP can't create files in public_html. This screws up my content management system, which generates static HTML pages which are hit a lot. Is this policy common? Is it a security risk for PHP to be able to create files in the main directory? (I have no problem creating files in subdirectories.) I've spent a couple days rewriting to use a PHP script called as a CGI to do the updates, and now they're telling me that that won't work when called from the CMS -- I've got to call it from a crontab, which I don't think will be acceptable. This is my third post concerning this (rephrased and refocused each time). Does anyone else need to create and update files in their main directories? Is this a security problem? Do I need to completely rewrite the CMS to use a subdirectory? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to exec PHP as CGI
My PHP script for updating some static HTML pages no longer works on a commercial host that changed their setup so PHP can't write files to the public_html directory. The host's tech support says that a PHP script executed as a CGI can still write to public_html. The site has PHP 4.3.2 on Apache 1.3.28, with passthru, shell_exec, and system disabled. I'm not sure how to approach converting my script to work as a CGI -- if I need to execute the update from a content management system link, do I use exec()? Does exec() take a Unix command? If so, would that command just reference my PHP script headed with "#!/usr/bin/php -q"? And how do I return something to tell me if execution was successful? I'm searching through the manual, but links to good examples (or outright explanations) would be greatly appreciated. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem passing variable between forms.
> I have a form in which I have a table with dynamic checkboxes, they are in a > checkbox array ( name = chk[]...), I pass this variable to the next page > using POST I receive the variable and use it, no problem, but then when I > try to pass it to the next form in the URL (using an A HREF: > > ) > > then it doesnt get passed. I have also tried sending it with POST and a > submit button Isn't $chk an array? To pass an array in a form, you should serialize it and encode it, then after receiving it you decode it and unserialize it: $portable_array = base64_encode(serialize($array)); You can then pass $portable_array as a form hidden input value. To turn it back into an array: $array = unserialize(base64_decode($portable_array)); -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP permissions problem
> * Thus wrote Lowell Allen ([EMAIL PROTECTED]): >> My commercial host is set up with the public root directory, "public_html", >> owned by user: userid, group: nobody. Directories I create within >> public_html are owned by user: userid, group: userid. As a result, PHP does >> not have permission to create files or write to files in public_html, but it >> does within its subdirectories. >> >> Is this a common setup? Are there security problems with changing the >> ownership of public_html to user: userid, group: userid so PHP can create >> files within the root directory? Advice, opinions, and links to relevant >> information are requested. > > I usually keep my writable directories outside the public_html > directory. > > homedir/public_html/* All read only by webserver. > homedir/private_data/* Make these files read/write > > > Curt I should have explained that the setup is a problem because the site uses a content management system that updates a few static HTML pages -- the pages that get hit most often. The commercial host seems to have changed their standard setup so that my CMS can no longer update these pages since PHP no longer has permission to write to public_html. (I'll eventually get an explanation from the host. I find I have to email one simple question at a time.) I could change the permissions of public_html to 777, but that doesn't seem like a good idea. I could write the static files to a subdirectory, but that would require rewriting several output functions. Or I could ask the commercial host to change ownership of public_html to userid.userid. But is there a security problem with that? -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP permissions problem
My commercial host is set up with the public root directory, "public_html", owned by user: userid, group: nobody. Directories I create within public_html are owned by user: userid, group: userid. As a result, PHP does not have permission to create files or write to files in public_html, but it does within its subdirectories. Is this a common setup? Are there security problems with changing the ownership of public_html to user: userid, group: userid so PHP can create files within the root directory? Advice, opinions, and links to relevant information are requested. PHP 4.3.2/Linux/Apache 1.3.28 -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and directory permissions
I developed a script which updates some static HTML pages. The script creates temporary files and opens them for writing. It then reads the HTML content of PHP-generated pages and writes that to the temp files. If that's successful, it copies the temp files to the static files, thus updating them. This worked without problem for several months, but recently started throwing a permissions error: > Warning: fopen(temp_list_auctions.html): failed to open stream: > Permission denied in > /home/williams/public_html/generate_auction_lists.php on line 55 > Unable to open temporary file (temp_list_auctions.html) for writing. The same script still works fine in public_html/dev, which is a directory I use for testing. I asked the commercial host why this has become a problem and why it works in public_html/dev but not in public_html. Here's the reply (which does not explain why it once worked): > The reason the problem occurs in the public_html directory is because > the directory is owned by user: williams group: nobody. Your account is > setup like this so no one can write into your root directory, except a perl > script or a PHP script on your site executed as a CGI. By chmoding the > public_html directory to 777 you make the ownership settings useless. The > directory named dev is owned by user: williams group: williams so your PHP > script has no trouble writing to it with 757 permissions. > > So you could either chmod the public_html directory to 777 or we could chown > the directory to user: williams group: williams. I don't want the public_html directory set to 777, but I certainly want PHP to be able to update files. Is there a security problem with having public_html owned by user: williams, group: williams? Would it be better to rewrite my script so that it doesn't need to create files? Comments on the best approach for security and reliability would be appreciated. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems send MIME multipart/alternative mail with php
> I have had no success sending multipart/alternative emails with php. I have > tried everyone's various code snippets with no luck. I test the results with > Outlook and Outlook Express. Everytime my boundary tag ends up showing as > part of my message and thus the plain text and html portions show up as one > long blob of unformatted text. Below is the code I am currently using. Any > suggestions would be greatly appreciated. > > Thanks, > > Dan > > The code: > > error_reporting(E_ALL); > //FUNCTION future > multipartmailer($to,$from,$subject,$plaintextsource,$htmlsource); > //$boundry="**=-=-=D-=-=-=-MIME-A-Boundry-=-=-N=-=-=-**"; > $boundry= "---=".uniqid("MAILDIVIDERS"); > //set mime type > > $headers="From: Person <[EMAIL PROTECTED]>\n"; > $headers.= "MIME-Version: 1.0\n"; > $headers.="Content-Type: multipart/alternative; > boundary=\"$boundry\"\n"; > //these files have the raw message content > $plaintext = file("plaintextcontent.txt"); > $html = file("htmlcontent.txt"); > //warning for non-MIME lovin' clients > > $headers .= "This message is in MIME format. Since your mail reader does not > understand this format, some or all of this message may not be > legible.\n\r\n\r"; > > // CHOP > $message .= $boundry."\n"; > $message .= "Content-Type: text/plain; charset=ISO-8859-1\n"; > $message .= "Content-Transfer-Encoding: 8bit\n\r"; > foreach($plaintext as $line) { > $message .=$line; > } > $message .="\n".$boundry."\n"; > $message .= "Content-Type: text/html; charset=ISO-8859-1\n"; > $message .= "Content-Transfer-Encoding: 8bit\n"; > foreach($html as $line) { > $message .=$line; > } > $message .="\n".$boundry."\n"; > mail("[EMAIL PROTECTED]","Welcome to the Website",$message,$headers); > print $headers."".$message.""; > > ?> > > \n"; if ($reply_to_email != "") { $multiheaders .= "Reply-To: " . $reply_to_name . "<" . $reply_to_email . ">\n"; } $multiheaders .= "Return-Path: <$from_email>\n"; $multiheaders .= "X-Mailer: PHP4\n"; $multiheaders .= "MIME-Version: 1.0\n"; $multiheaders .= "Content-Type: multipart/alternative;\n\tboundary=\"" . $OB . "\"\n\n"; $multiheaders .= "--" . $OB . "\n"; $multiheaders .= "Content-Type: text/plain; charset=us-ascii\n"; $multiheaders .= "Content-Transfer-Encoding: 7bit\n"; $multiheaders .= "Content-Disposition: inline\n\n"; My code samples are all chopped up because they're part of a queuing system. I create a plain text message and an HTML-formatted message and write everything to a MySQL database. A separate script that's called by a crontab actually sends the email. (That let's me control frequency and volume.) After pulling from the database, I build the multipart message from the plain text message, the boundary, some more specific headers, the HTML-formatted message. // build multipart/alternative $multipart_message = $message . "\n\n--" . $boundary . "\n" . "Content-Type: text/html; charset=us-ascii" . "\n" . "Content-Disposition: inline" . "\n\n" . html_entity_decode($html_message) . "\n\n--" . $boundary . "--\n\n--End--\n\n\n"; if ([EMAIL PROTECTED]("$fullname<$email>", $subject, $multipart_message, $multiheaders)) { // some stuff for error checking } Hopefully you can decipher my example. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File ordering
> I am doing a 'readdir' on a subdirectory. I did my file naming counting on > it ordering based on numbering... But when I do the readdir it isn't doing > it. My naming convention 002_2003_66.jpg would indicate the 66th picture for > the month of Feb in 2003. This gave me automatic sorting. So I thought. But > it doesn't seem to be doing it. The server is a linux server > ((IStop/Doncaster consulting) and I don't see why the ordering is screwing > up. I checked the create dates and that isn't the ordering choosen (I have > pictures from July showing up between pictures from March). > > Thoughts, suggestions? > > Katherine > > This is the clip of code(srcdir being passed in): > > $imgdir = "$srcdir/images"; > $txtdir = "$srcdir/txt"; > $imgdh = opendir($imgdir); > $txtdh = opendir($txtdir); > > while($file = readdir($imgdh)) { > if(substr($file,-3)=="jpg") { > $imgFiles[] = $file; > $textFileName = substr($file,0,-3)."txt"; > $textFiles[] = $textFileName; > } > } Just sort the $imgFiles array. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail From option in PHP.ini
> From the php website, it appears that the [EMAIL PROTECTED] can be > put in the fifth parameter of the mail() function: > > Example 3. Sending mail with extra headers and setting an additional > command line parameter. > > mail("[EMAIL PROTECTED]", "the subject", $message, >"From: [EMAIL PROTECTED]", "[EMAIL PROTECTED]"); > > > Note: This fifth parameter was added in PHP 4.0.5. Since PHP 4.2.3 > this parameter is disabled in safe_mode and the mail() function will > expose a warning message and return FALSE if you're trying to use it. I followed this recent thread with some interest, because I'd like to be able to set the return-path header for a script that emails to a large list, which would in turn allow me to identify bounced emails. I'm using a shared host server, with PHP running as the master account user name, so the return-path for emails is something like "Return-Path: <[EMAIL PROTECTED]>". I had accepted that I could not change the return-path value with PHP, but reading about this fifth parameter renewed my hope that I could. I tried adding a fifth parameter to mail() in order to do this, like so: // fifth mail() parameter to set envelope sender $cmd_line_param = "[EMAIL PROTECTED]"; mail("$fullname<$email>", $subject, $message, $headers, $cmd_line_param); This didn't change the return-path header. Perhaps the problem is that I have no idea what the syntax of the command line parameter is (what the "-f" does). Can anyone advise? Is it possible to use this fifth parameter to set the return-path header, and if so, what's the syntax? TIA, -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multi file multi colomn
> I have 40 text files.. each files have 1 colomn of a data. I want to write a > script to merge them like > > datafrom1;datafrom2;datafrom3;datafrom40 > > how can I do that? Assuming that by "1 column" you mean each file has data, then a new line character, then data, then a new line character, etc., you could read each file into a variable: $data1 = ""; $file = "(path to the file)"; $fp = fopen($file, "r"); if ($fp) { while (!feof($fp)) { $data1 .= fread($fp, 1024); } } fclose($fp); Then make each file an array by exploding on the new line character: $records1 = explode("\n", trim($data1)); Find the size of each array as you make them (if they have different sizes, track the largest size value somehow): $num_records = count($records1); Then concatenate: for ($x = 0; $x < $num_records; $x++) { $merged_files = $records1[$x] . $records2[$x] . (etc) . $records40[$x]; } If you need the data separated with semicolons, add them when concatenating. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A php-mysql checkbox question
> From: "John T. Beresford" <[EMAIL PROTECTED]> > > I have a problem trying to show a checkbox list and have some of the > boxes checked and not others. Here are the details: > > table: features > rec_id | fName > - > 1 | Window > - > 2 | pool > - > 3 | fence > - > 4 | Drive > > > table: com_features > > rec_id | com_features_id | feature_id > -- > 1 | 2| 1 > -- > 2 | 1| 4 > -- > 3 | 1| 3 > -- > 4 | 2| 3 > -- > 5 | 4| 4 > -- > 6 | 7| 4 > -- > 7 | 8| 4 > -- > 8 | 2| 4 > > > > what I want is to display a checkbox list that would show all the > values from 'features' and have the appropriate boxes checked when > 'com_features.com_features.id = 2' > > ie > > X Window > pool > X fence > X drive > > The query I am using now is: > > $sql ="SELECT > features.rec_id AS rec_id, > features.fName AS fName, > com_features.feature_id AS feature_id, > com_features.com_rec_id AS com_rec_id > FROM features, com_features > WHERE com_features.com_rec_id = \"2\" AND features.TheTest=\"1\""; > > What I get in the return is: > > X Window > pool > fence > drive > > Window > pool > X fence > drive > > Window > pool > fence > X drive I'm not sure how you're formatting (HTML?), what "TheTest" is, or what this has to do with PHP, but how about this select statement: $sql = "SELECT features.fName, features.rec_id FROM features, com_features WHERE features.rec_id = com_features.feature_id AND com_features.com_features_id = '2'"; HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem receiving notification emails to mails sentwith php
> From: "czamora" <[EMAIL PROTECTED]> > > I'm sending emails to the subscribers of my site using mail() with a fourth > parameter to specify the From: and Reply-To: headers. They seem to be sent > correctly and the users may reply to them and I get the replies in the > mailbox identified by these headers. > The problem is some email addresses I'm sending email to are incorrect, and > I should be receiving the email notification saying that the email could not > be delivered. But I'm not receiving these messages in my mailbox. > Any ideas why this could be so? > > Thanks a lot for any hints. > > I'm sending mails with: > > mail($to, $subject, $body, $from); > > where $from = "<[EMAIL PROTECTED]>\nReply-To: > [EMAIL PROTECTED]: PHP/" . phpversion(); > > I've also tried using \r\n instead of \n Send yourself an email using PHP and examine the Return-Path listed in the source code. (The Return-Path is not the same as the From you're setting.) If you're using a commercial host (shared hosting), then the Return-Path is probably something like [EMAIL PROTECTED] My host provides Horde for web-based email, and bounces go to the master user account. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spellchecking using PHP on WinXP?
> From: "Murray Wells" <[EMAIL PROTECTED]> > > As I understand it Aspell / Pspell don't work under PHP on the WinXP > platform. Just wondering if anyone knows of an alternative that does > (for use with Apache server, if that's important)? Not a PHP solution, but I can recommend the Java-based JSpell spell checker if you've got Tomcat on Apache and you're OK with *absolutely no support* installing. <http://www.jspell.com/> -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSS help
> From: "Angelo Zanetti" <[EMAIL PROTECTED]> > > Hi guys sorry for the off topic post. > > i am not getting any success with Css @ the moment. > > What I need is basically a class in my CSS file that defines everything about > A links. > > I have this class but it aint working (i know its wrong): > > ..sideMenu { > > hover{color:white}; > visited {color: black}; > visited:hover {color:white}; > a:text-decoration : none; > > } > > should this be: > > ..sideMenu{ > > a-hover color:white; > > } > > ??? > > please help me. Yes, this is very off-topic. You should post to the css-d list -- <http://www.css-discuss.org/mailman/listinfo/css-d>. Meanwhile, try something like this: a { font-weight: bold; text-decoration: none } a:link{ color: #339; text-decoration: none } a:visited { color: #036; text-decoration: none } a:hover{ color: #fff; text-decoration: none; background-color: #339 } a:active{ color: #fff; text-decoration: none } -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Formatting issue.
> From: "Tom Ray [Lists]" <[EMAIL PROTECTED]> > > I'm having a bit of a formatting issue, and I was wondering if someone > might have an idea on how to solve it. Basically what I have right now > is a script that opens and reads the content of an image directory, each > time the script is accessed it writes the contents out to a text file > for me. I then open that text file and read it's contents, I want to be > able to display thumbnail versions of the pictures, 3 per row and as > many rows as needed. Unfortunetly, all I can do right now is 1 per row, > this is where I need the help. Here's the code that displays images: > > $dat="$_GET[gallery].dat"; > $file=fopen($dat, 'r'); > $contents = fread ($file, filesize ($dat)); > fclose($file); > $img=explode("|",$contents); > > print ""; > > foreach($img as $image) { > if($image) print " width=150 height=100>"; > } > print ""; > > So how do I make this work so I can have three cells per table row and > it actaully show the proper picture? You need to set up a counter so you can start a new table row at the appropriate time. Beginning from the line where you use explode(), and for brevity not writing out the HTML for linking the image: $img = explode("|", $contents); $img_count = count($img); $i = 0; foreach ($img as $image) { if ($i%3 == 0) { echo("$image"); if ($i+1 == $img_count) { echo("\n"); } } elseif ($i%3 == 1) { echo("$image"); if ($i+1 == $img_count) { echo("\n"); } } elseif ($i%3 == 2) { echo("$image\n"); } $i++; } Hope this helps. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirect
> From: "shaun" <[EMAIL PROTECTED]> > > How would one redirect a user to a different page if a certain condition was > met? > > i.e. > > if($condition == true){ > goTo newPage.php > } Redirects are done using the header() function. See the documentation at <http://www.php.net/manual/en/function.header.php>. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MSSQL using Sybase FreeTDS
> From: "Craig" <[EMAIL PROTECTED]> > > Im running PHP 4.31 on RH Advanced Server 2.1 > > I am connecting, to M$SQL Server 2000 using FreeTDS -- with Sybase support, > and Im stumped on 1 thing: > [snip] > > The above code works fine, except when one of the fields e.g client_name - > Has a quoted string or an apostrophe in it, it just spews the following > error: > > Warning: Sybase error: Line 1: Incorrect syntax near 's'. (severity 15) in > /var/www/html/clients/pages/add_client.php on line 17 > > Has anyone experienced this, and if so know of a possible solution?? I have > used addslashes() etc but still no joy. MSSQL doesn't use slashes for escaping. You probably need to use a single quote character instead of a slash. See user notes in the PHP manual, <http://www.php.net/manual/en/function.addslashes.php>, which will direct you to other info on changing the escape character used. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mailing forms and input into MySQL
> From: "Scott Miller" <[EMAIL PROTECTED]> > > I have a current php script that allows me to add/remove customer information > from a particular MySQL Database. What I would like to do, is when an > employee adds a customer, have some (if not all) of that information e-mailed > to a particular e-mail address. > > I've created scripts that e-mail info, and ones that just enter info into a > database, but have not attempted combining them. > > Anyone have any ideas, or is anyone doing this? If so, could you give me a > quick how-to or point me in the direction of some online documentation? > There's nothing tricky about it. Just do the database insert and then send the email. I suggest returning a simple success/failure from the database insert so that if it fails you can note that in the email (probably going to a site administrator). I build strings for $subject, $headers and $message (from the values that were used in the insert) like so: $message = "SUBMITTED:\n\n"; $message .= "First name: $first\n"; $message .= "Last name: $last\n\n"; $message .= "Address: $address1\n"; if ($address2 != "") { $message .= "Address: $address2\n"; } etc. Then send it and report failure or success to the user like so: if ([EMAIL PROTECTED]("$send_to_name<$sendto>", $subject, $message, $headers)) { // report failure to send confirming email } else { // thanks for submitting } HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cookies with internet explorer on macs
> From: Jimmy Brake <[EMAIL PROTECTED]> > > The cookies i set for people using Internet Explorer on mac (OS X or mac > os 8-9) are not staying alive as long as I would like(12hours) they only > last for a few hours or sometimes even a few minutes, the time on the > end users computers are set correctly. IE on windows is fine and Mozilla > and other browsers on linux are fine. > > This is what I use to set the cookie. > > $rand = md5(uniqid(rand())); > setcookie("sessid", $rand, time()+43200, "/"); > > Any ideas? A designer I work with was having problems with his sessions sometimes expiring after a few minutes. He uses OS X/Internet Explorer/Entourage. He determined that whenever he checks his email with Entourage, his session cookie is no longer recognized. He got Microsoft support to duplicate and acknowledge the problem. I use Mac OS 9/Internet Explorer/Outlook Express -- no problem. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Addslashes problem (MSSQL)
Read the user-contributed notes following the online manual info on addslashes: <http://www.php.net/manual/en/function.addslashes.php> -- Lowell Allen > From: "Poon, Kelvin (Infomart)" <[EMAIL PROTECTED]> > Date: Thu, 20 Mar 2003 11:20:51 -0500 > To: 'Lowell Allen' <[EMAIL PROTECTED]> > Cc: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> > Subject: RE: [PHP] Addslashes problem (MSSQL) > > > What do you mean by "It escapes single quotes with single quotes."? > > so let's say my $content is > > lalal 'lalalal' "lalala" > > > then what do I have to do to $content in order to insert to my MSSQL table? > -Original Message- > From: Lowell Allen [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 20, 2003 11:20 AM > To: PHP > Subject: Re: [PHP] Addslashes problem (MSSQL) > > > MS-SQL doesn't escape with slashes. It escapes single quotes with single > quotes. > > -- > Lowell Allen > >> From: "Poon, Kelvin (Infomart)" <[EMAIL PROTECTED]> >> Date: Thu, 20 Mar 2003 10:58:02 -0500 >> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> >> Subject: [PHP] Addslashes problem (MSSQL) >> >> Hi, >> >> I have a problem that lets you add a record to a database. THere is a >> problem with it, and the following is the area of the program where it has >> problem. >> >> >> >> $created_date = date('m, d, Y'); >> >> $title = strip_tags($title); >> $keywords = strip_tags($keywords); >> $content = strip_tags($content); >> $product = strip_tags($product); >> >> >> if (!get_magic_quotes_gpc()) { >> $title = addslashes($title); >> $keywords = addslashes($keywords); >> $product = addslashes($product); >> $content = addslashes($content); >> } >> >> $query = "SELECT * FROM knowledgeBase"; >> $result = mssql_query($query); >> >> $ID = mssql_num_rows($result); >> $ID += 1; >> >> $query2 = "INSERT INTO knowledgeBase( >> ID, >> Title, >> Keywords, >> Content, >> [Created Date], >> [Updated Date], >> Product) >> VALUES( >> '".$ID."', >> '".$title."', >> '".$keywords."', >> '".$content."', >> '".$created_date."', >> 'Never', >> '".$product."')"; >> $result2 = mssql_query($query2); >> >> >> >> where my $content value is osmethign like this. >> >> "Step 1: Access the homepage >> Step 2: type in your username under the field 'username' " >> >> and after the addslashes funciton there would be \ around the 'username' >> like this.. >> \'username\'and now after running this program I got an error message: >> >> Warning: MS SQL message: Line 14: Incorrect syntax near 'username'. >> (severity 15) in > d:\apache_docroots\internal.infomart.ca\infodesk\kb_add.php >> on line 119 >> >> Warning: MS SQL: Query failed in >> d:\apache_docroots\internal.infomart.ca\infodesk\kb_add.php on line 119 >> >> >> >> does any body have any idea? I did the same thing with another problem > but >> it worked fine. I have no idea what the problem is. I know I need to >> addslashes to the string since I am putting it in the valuable >> $query2..please advise.. >> >> 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 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] Addslashes problem (MSSQL)
MS-SQL doesn't escape with slashes. It escapes single quotes with single quotes. -- Lowell Allen > From: "Poon, Kelvin (Infomart)" <[EMAIL PROTECTED]> > Date: Thu, 20 Mar 2003 10:58:02 -0500 > To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> > Subject: [PHP] Addslashes problem (MSSQL) > > Hi, > > I have a problem that lets you add a record to a database. THere is a > problem with it, and the following is the area of the program where it has > problem. > > > > $created_date = date('m, d, Y'); > > $title = strip_tags($title); > $keywords = strip_tags($keywords); > $content = strip_tags($content); > $product = strip_tags($product); > > > if (!get_magic_quotes_gpc()) { > $title = addslashes($title); > $keywords = addslashes($keywords); > $product = addslashes($product); > $content = addslashes($content); > } > > $query = "SELECT * FROM knowledgeBase"; > $result = mssql_query($query); > > $ID = mssql_num_rows($result); > $ID += 1; > > $query2 = "INSERT INTO knowledgeBase( > ID, > Title, > Keywords, > Content, > [Created Date], > [Updated Date], > Product) > VALUES( > '".$ID."', > '".$title."', > '".$keywords."', > '".$content."', > '".$created_date."', > 'Never', > '".$product."')"; > $result2 = mssql_query($query2); > > > > where my $content value is osmethign like this. > > "Step 1: Access the homepage > Step 2: type in your username under the field 'username' " > > and after the addslashes funciton there would be \ around the 'username' > like this.. > \'username\'and now after running this program I got an error message: > > Warning: MS SQL message: Line 14: Incorrect syntax near 'username'. > (severity 15) in d:\apache_docroots\internal.infomart.ca\infodesk\kb_add.php > on line 119 > > Warning: MS SQL: Query failed in > d:\apache_docroots\internal.infomart.ca\infodesk\kb_add.php on line 119 > > > > does any body have any idea? I did the same thing with another problem but > it worked fine. I have no idea what the problem is. I know I need to > addslashes to the string since I am putting it in the valuable > $query2..please advise.. > > 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
Re: [PHP] PHP and IIS 5.0
The error reporting level setting is set higher on the Windows box than on your Linux box. See info in the manual about changing, or define all those variables. HTH -- Lowell Allen > From: "Beauford.2002" <[EMAIL PROTECTED]> > Date: Wed, 19 Mar 2003 11:11:42 -0500 > To: "PHP General" <[EMAIL PROTECTED]> > Subject: [PHP] PHP and IIS 5.0 > > Hi, > > I am putting together a website for a customer who insists on using IIS > running on Windows XP and I'm running into some problems. It appears that no > matter what PHP script I run, I'm getting tons of errors saying this > variable or that variable is undefined. I have global variables turned on in > the php.ini file - so I'm not sure what would be causing the problem (other > than it is a Microsoft product). The same scripts work perfectly on my Linux > box running Apache. > > Any help is appreciated. > > BTW - thanks to those that answered previous questions regarding > authentication. > > B. > > > > -- > 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] sessions terminating randomly please help
> From: "freaky deaky" <[EMAIL PROTECTED]> > > i am experiencing a major problem with sessions expiring randomly in some of > my > apps. i will log in and start clicking around and then i will eventually > arrive at a page that tells me that i'm not logged in anymore. this happens > apparently randomly. i have seen it on ie6, ie for mac, netscape 4.7 for pc, > and mozilla > > the apps are hosted on > > freebsd 4.7-release p2 > apache 1.3.27 > php version 4.2.3 > compiled with --enable-trans-sid > > i can't go into production if there's the possibility that users will be > randomly logged off. i went through all of my code over the weekend, and i > don't think i can attribute this to a miscoding: > > when a user logs in, i create a session with > > session_start(); > $valid_user=$_POST['username']; > session_register("valid_user"); > > i have the following code at the top of each page to check to see if the > session > is valid: > > session_start(); > $valid_user=$_SESSION['valid_user']; > global $valid_user; > if (session_is_registered("valid_user") > {...function to spit out an error message if the session is not valid...;} > > i have a logout page that destroys the session > > session_start(); > session_destroy(); > > i also have a javascript timer in the header of every page that redirects to > the > logout page if the user has been inactive for 20 minutes. > > i have played around with session.gc_probability, setting it to 100, but that > doesn't seem to have fixed the problem. > > this is a huge problem. > if anyone can give some advice, i'd really appreciate it. Is your session.save_path set to /tmp? It's my understanding that you should specify a directory for saving session data -- or use a database -- that /tmp is subject to garbage collection, and specifying a directory prevents that. I made this change to a site recently. In tests prior to the change the session would last up to about 2.5 hours with no activity. After specifying a directory with session_save_path() right before session_start(), the session was still OK after almost 4 hours of inactivity. (Not much of a controlled test, I admit.) That said, here's a disturbing fact that turned up last week -- a designer working on the same site was continually being logged off unexpectedly. After many tests he identified that the problem was Microsoft IE/Entourage. Every time he checks email he's no longer recognized as logged in (Mac OSX IE). He got Microsoft tech support to duplicate the behavior and confirm it's a problem with IE -- doesn't happen with Mozilla. So, it's important to verify the problem with more than one system, but it sounds like you have since you mention both IE6 and IE Mac! -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Checking for empty values sent from a form
You can write a function and when using it in a script insert $HTTP_POST_VARS as the argument: function filled_out($form_vars) { foreach ($form_vars as $key => $value) { if (!isset($key) || ($value == "")) { return false; } } return true; } (I think this is from the Welling and Thomson book -- PHP and MySQL Web Development.) -- Lowell Allen > From: "shaun" <[EMAIL PROTECTED]> > Date: Thu, 6 Mar 2003 13:45:52 - > To: [EMAIL PROTECTED] > Subject: [PHP] Re: Checking for empty values sent from a form > > thanks for your reply but I was wondering if there was a way to check > through all of the form entries with an easier way that > > if ($_POST['your_input_name'] == '' || $_POST['your_input_name'] == '' || > $_POST['your_input_name'] == '' || $_POST['your_input_name'] == '' ) //etc > // field is empty > > this would be particularly useful for forms with lots of fields... > > > "Niels Andersen" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Since input from a form are strings, you can check like this: >> >> if ($_POST['your_input_name'] == '') >> // field is empty >> >> "Shaun" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> Is there an easy way to scan through an array of values sent from a form >> to >>> see if any of them are empty? >>> >>> >> >> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general@lists.php.net
In my case the client's list is about 1500 addresses and they send every 2-3 weeks. The client wanted a way to recover if sending failed mid-list -- a way to know where to pick up again. A post to the list described a queuing system similar to the one I built, so check the archives if you end up building one yourself. In my preliminary tests it took much longer to send emails than 250 in 15 seconds! Sending test batches of 100, I got ranges from 27 seconds to 202 seconds, with the average time about 73 seconds for 100 emails. During these tests I was writing a counter to a flat file each time through the loop, which probably slows the process down a little, but I don't think that would account for the dramatic differences in speeds between your tests and mine. About bounce backs -- on the commercial host I'm using, each domain comes with web mail accounts. The default user for the account corresponds to the account username for FTP access. Other usernames/passwords can be added and can receive email at "[EMAIL PROTECTED]". By setting up the crontab to execute as a specific user, that user email address is listed in the email header as the return-path and bounced/undeliverable email goes to that user email account. Someone at the client company monitors that address, verifies the bounce, and manually removes the address from the list. Good luck with your project! -- Lowell Allen > From: J J <[EMAIL PROTECTED]> > Date: Wed, 5 Mar 2003 16:34:44 -0800 (PST) > To: PHP <[EMAIL PROTECTED]> > Subject: Re: [PHP] What solution to use for mass newsletter mailing & > reporting? > > Interesting way of tracking everything... and I like > the idea of the pop-up being able to query the > database for current status. > > For now, I'm firing off a process with no timeout and > it can run even after browser abort... but no real way > to check on it other than I send a "mailing complete" > type email with some of the mailing details. > > I was able to send 250 emails within 15 seconds, so > roughly 1000 a minute. Not sure if this is because > the server load is light, or the server is just that > powerful. Does this seem right??? > > > I'd like to find out more how you handle the bounce > backs. > > Again, thanks for the great information. > > > > --- Lowell Allen <[EMAIL PROTECTED]> wrote: >> - It takes several minutes to send hundreds of >> emails, so it's best done in >> the background. You'll need PHP available to run as >> a CGI/CLI called from a >> cron tab. >> >> - My solution is part of a content management >> system. Site administrators >> create the body of the email from database info. >> When a user hits the send >> button, the email is saved to a MySQL table which >> has fields for Time (time >> created), ListSize (number of addresses), Invalids >> (bad address formats), >> Attempts, and InProgress (an enum field used as a >> flag). There are lots more >> fields for storing parts of the message, etc., but >> that's not important to >> the approach. There's also a database table for >> storing the email address >> list, with fields for Time (same as the message >> table), Valid (valid >> format), Failed, Attempted, and TimeAttempted. >> > > __ > Do you Yahoo!? > Yahoo! Tax Center - forms, calculators, tips, more > http://taxes.yahoo.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general@lists.php.net
> From: J J <[EMAIL PROTECTED]> > > What do you use for mass newsletter mailing say for > 5000+ members every month? At the same time, I'd like > to be able to track who opened the message, any links > they clicked inside the message, bounced messages, > etc. > > I keep seeing reports that PHP/mail have trouble > sending more than a few hundred messages depending on > the machine. But for mass mailings you get into > majordomo, etc, which seems to bulky for my needs. > > Any thoughts or suggestions on possible solutions? > Thank you in advance! This general question is asked often, and I found lots of good information by searching the list archives. So check the archives, read the manual, read whatever articles you can find. (Check zend.com and sitepoint.com.) This will give you all the info you need to successfully send to a small list -- verify you can do that. Assuming you've got that down, here's a quick description of the system I built on a commercial Linux host using a MySQL database: - It takes several minutes to send hundreds of emails, so it's best done in the background. You'll need PHP available to run as a CGI/CLI called from a cron tab. - My solution is part of a content management system. Site administrators create the body of the email from database info. When a user hits the send button, the email is saved to a MySQL table which has fields for Time (time created), ListSize (number of addresses), Invalids (bad address formats), Attempts, and InProgress (an enum field used as a flag). There are lots more fields for storing parts of the message, etc., but that's not important to the approach. There's also a database table for storing the email address list, with fields for Time (same as the message table), Valid (valid format), Failed, Attempted, and TimeAttempted. - The cron tab calls a PHP script every five minutes which queries the database message table for fields where ListSize-Invalids > Attempts and InProgress = "N". If the result set is less than 1, the script exits. Otherwise, it sets the InProgress flay to "Y" and selects 50 email addresses from the addresses table where Attempted = "N" and Valid = "Y" and Time matches Time from the message table. - The sending PHP script then loops through the 50 addresses, and each time through the loop updates the address table for the address being processed, setting Attempted to "Y", Failed to "Y" or "N", and TimeAttempted to a timestamp value. After finishing the 50-address loop, the script updates the message table to set Attempts to a greater value and InProgress to "N". - Finally, the sending script selects all "completed" messages (where ListSize-Invalids = Attempts and InProgress = "N"), orders the selection by Time descending, and deletes all but the most recent, and also deletes the Time-matching email addresses from the address table. This means that only active info and the last-completed mailing info is kept in the database. - Another nice thing about running the sending script as a CLI is that when a PHP script running as a module sends email, the return-path in the email header is listed as something like "[EMAIL PROTECTED]" and bounced email isn't accessible. (This is true on the commercial host I'm using, anyway.) But when the PHP script runs as a CGI, the return-path can be set to the user and the bounces are accessible. - Using the info stored in the message table and address table, I can produce a report on a mailing attempt. I also built a pop up window that refreshes every few minutes so I can monitor the progress of sending to a large list. There are lots of other details, of course, but it took too long to describe the general approach -- whew! Anyway, for anyone struggling with this sort of thing, building a queuing system like this seems to work well, and I'm sure it would be safe to greatly increase the speed above 50/5 minutes. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mortgage calculator
> From: "Karen E. Lubrecht" <[EMAIL PROTECTED]> > > I'd like to add a mortgage calculator to a client's site. I've been unable > to find the formula. In searching php.net, I found a discussion from back in > 2000 related to some buggy code. My web search hasn't produced anything > other than realtor and mortgage companies and a perl script site. I'm not > familiar with perl and would prefer avoiding it until my knowledge improves. > There were corrections for a java script somewhere, but I'm beginning to > think it is down. Some things seem so obvious that you just don't think you > need to bookmark! So why can't I remember... > > I would just prefer not reinventing the wheel. Suggestions would be greatly > appreciated. There's a free PHP mortgage calculator at <http://www.dreamcost.com/>, which I easily adapted for use on <http://www.williamsauction.com/>. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date problem
> From: "Alexander Tsonev" <[EMAIL PROTECTED]> > > Hello, > I would ask you a question about date type > if I have a variable from date type ($newdate) such as 2003-02-17 > how can I separate $newdate into 3 different variables? I want to create > such variables: > $day=17 > $month=2 > $year=2003 > I searched a lot, but I didn't find how to do this. > I'll be very happy if someone helps! > list($year, $month, $day) = explode("-", $newdate); -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about replacing \r\n with
> From: Al <[EMAIL PROTECTED]> > > I can't find a way to replace \r\n codes with in a text file. > > I'm reading a text file that was prepared with windows notepad > The hex code shows OD OA for CR/LF as I expect. > > I'd like to replace the OD/LF with s. > > I spent hours trying every User Notes in the PHP Manual for this simple > operation. e.g., > > $txt= preg_replace("\r\n", "", $words); > > and this version > $txt = preg_replace("/(\015\012)|(\015)|(\012)/","", $txt); > > I can substitute other characters and dec equivalents and the > substations just won't work for \r\n [or just \r or just \n] or "\015" > or "\15". > > And, I've tried using "10" and "010" and "13" and "013". > > And nl2br doesn't work either. > > Can anyone help? Here's what I use to make two returns a paragraph return and one return a baseline return: $text = ereg_replace("\r", "", $text); $text = ereg_replace("\n\n", "", $text); $text = ereg_replace("\n", "\n", $text); $text = ereg_replace("", "\n", $text); HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session expiration
> From: "1LT John W. Holmes" <[EMAIL PROTECTED]> > >> I'm using sessions for authentication in a content management system and >> experiencing rare but occasional problems with the session apparently >> expiring unexpectedly. I've checked the manual and I've reviewed the > session >> configuration on the commericial host I'm using. I don't see anything > wrong, >> but there are some settings that I don't understand: >> >> session.gc_maxlifetime 1440 -- Garbage collection after 24 minutes? Does >> this mean that the session id and session variables will be cleared after > 24 >> minutes of inactivity? (Surely not; that doesn't make sense.) And cleared >> from where, the directory specified in session.save_path? > > Yes and Yes. After 1440 seconds of not being accessed, they are deleted the > next time the garbage collection routine is ran. So how did my tests of going up to 2 hours without activity succeed? >> session.save_path /tmp -- The session id and session variables are stored > in >> this directory, and it's more secure to specify a different directory. Is > it >> more stable to specify a different directory? Is it more stable to use a >> database? > > Depends on what else your server is doing and how much traffic you get. If > you get a lot of traffic, there are going to be a lot of session files > sitting in this directory. Keeping it separate from /tmp will just reduce > the number of files in the directory. > > A database adds to much overhead and is only needed in special cases, IMO. > >> session.cache_expire 180 -- The cache expires after 3 hours? If >> session.cache_limiter is set to nocache, is session.cache_expire relevant? > > Not sure on that one, but it seems logical. > >> Basically, I want users to be able to stay logged in to the content >> management system indefinitely, but my tests show that after about 2 hours >> of inactivity, the session expires. (Going to a different page causes the >> session variable that identifies the user to be checked with >> session_is_registered(), and access is denied if the variable isn't >> registered.) Some users have reported this happening after about 30 > minutes. > > Garbage collection isn't exact. It's triggered (by default) on 1% of the > hits to your site. So if two are triggered close together, then someone can > be logged out rather quickly at 30 minutes. If there is a long pause where > the probability just doesn't trigger the garbage collection, then it may > take longer. > >> I'm on LInux, PHP 4.1.2, session.cookie_lifetime setting is 0, >> session.use_cookies setting is On, session.use_trans_sid setting is 1, and >> other configurations as mentioned above. Why are sessions expiring? > Comments >> and directions to more information are appreciated. > > Sessions are lost when the file is cleaned up by garbage collection or when > the user closes the browser (by default). So, if you wanted to use the > existing session handling routines, you could set the cookie lifetime to a > large value so the cookie isn't deleted and set the gc_maxlifetime to a > large value, also. You could possibly turn the gc_probability to zero, go > garbage collection is never triggered. > > Another option would be to use session_save_path() within your application > to save the session files to a separate directory that's writable by the web > server. Since this directory is different from session.save_path specified > in php.ini, garbage collection will never occur, so the files will not be > deleted. This seems like the answer I was looking for. So the setting session.gc_maxlifetime only relates to garbage collection from the /tmp directory? If I use session_save_path() to define a different directory for saving session data, then garbage collection will never occur for that directory? > You can also define your own session handler to do what you want. > > Why not just use a cookie to "remember me" though, instead of keeping the > sessions persistant? You're going to end up with a file on your computer for > _every_ person that visits the site and the file will not go away. Seems > like it'd be better to just use a cookie and load their data if it's not > already present, like on their first visit. This is for a content management system, with less than 10 people authorized to access it, so I don't see the number of session files as a problem. Thanks for the info. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: session expiration
> From: "Hans Prins" <[EMAIL PROTECTED]> > > can you show us the PHP code that you use to manage your session? Sure. You say in a following post: > I am asking because if you are using: session_set_cookie_params(), the > effect of this function only lasts for the duration of the script. I'm not using session_set_cookie_params(). The session.cookie_lifetime setting is 0; I don't specify anything about cookies. I have a login function that checks username/password against database values, then on the content management system index page I do: if (login($username, $password) { $user = $username; session_register("user"); } All pages within the cms have session_start(); following a require_once() statement, output some HTML, then call check_valid_user(), shown below: function check_valid_user() { global $user; if (session_is_registered("user")) { echo("Logged in as $user."); } else { ?> Problem: You are not logged in. Login "Lowell Allen" <[EMAIL PROTECTED]> schreef in bericht > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... >> I'm using sessions for authentication in a content management system and >> experiencing rare but occasional problems with the session apparently >> expiring unexpectedly. I've checked the manual and I've reviewed the > session >> configuration on the commericial host I'm using. I don't see anything > wrong, >> but there are some settings that I don't understand: >> >> session.gc_maxlifetime 1440 -- Garbage collection after 24 minutes? Does >> this mean that the session id and session variables will be cleared after > 24 >> minutes of inactivity? (Surely not; that doesn't make sense.) And cleared >> from where, the directory specified in session.save_path? >> >> session.save_path /tmp -- The session id and session variables are stored > in >> this directory, and it's more secure to specify a different directory. Is > it >> more stable to specify a different directory? Is it more stable to use a >> database? >> >> session.cache_expire 180 -- The cache expires after 3 hours? If >> session.cache_limiter is set to nocache, is session.cache_expire relevant? >> >> Basically, I want users to be able to stay logged in to the content >> management system indefinitely, but my tests show that after about 2 hours >> of inactivity, the session expires. (Going to a different page causes the >> session variable that identifies the user to be checked with >> session_is_registered(), and access is denied if the variable isn't >> registered.) Some users have reported this happening after about 30 > minutes. >> >> I'm on LInux, PHP 4.1.2, session.cookie_lifetime setting is 0, >> session.use_cookies setting is On, session.use_trans_sid setting is 1, and >> other configurations as mentioned above. Why are sessions expiring? > Comments >> and directions to more information are appreciated. >> >> -- >> Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session expiration
I'm using sessions for authentication in a content management system and experiencing rare but occasional problems with the session apparently expiring unexpectedly. I've checked the manual and I've reviewed the session configuration on the commericial host I'm using. I don't see anything wrong, but there are some settings that I don't understand: session.gc_maxlifetime 1440 -- Garbage collection after 24 minutes? Does this mean that the session id and session variables will be cleared after 24 minutes of inactivity? (Surely not; that doesn't make sense.) And cleared from where, the directory specified in session.save_path? session.save_path /tmp -- The session id and session variables are stored in this directory, and it's more secure to specify a different directory. Is it more stable to specify a different directory? Is it more stable to use a database? session.cache_expire 180 -- The cache expires after 3 hours? If session.cache_limiter is set to nocache, is session.cache_expire relevant? Basically, I want users to be able to stay logged in to the content management system indefinitely, but my tests show that after about 2 hours of inactivity, the session expires. (Going to a different page causes the session variable that identifies the user to be checked with session_is_registered(), and access is denied if the variable isn't registered.) Some users have reported this happening after about 30 minutes. I'm on LInux, PHP 4.1.2, session.cookie_lifetime setting is 0, session.use_cookies setting is On, session.use_trans_sid setting is 1, and other configurations as mentioned above. Why are sessions expiring? Comments and directions to more information are appreciated. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mac os 9 - file upload problems
> From: Jimmy Brake <[EMAIL PROTECTED]> > > I have a file upload page that accepts file uploads from pretty much > every browser and os EXCEPT any browser on mac os 9. I have no idea > why, any of you ever have problems with file uploads on mac os 9? How > did you solve the issue. I have no problems with file uploads using IE 5.1, Mac OS 9.2. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delimited file values behaving strangely...
> From: Geoff Caplan <[EMAIL PROTECTED]> > > Hi folks, > > A strange one - unless I am having a brainstorm... > > I am reading in tab delimited files created in Excel on Windows and > uploaded to Linux. > > Cell A1 contains a numeric id - I extract this into a variable, $id, > by exploding on \n and \t. > > But for some files, the values of $id do not behave as expected. Say > the value should be "23". > > If I echo, it prints as "23". But comparisons fail to match: > > if( $id == 23 ) ... > Try using trim() on the value to get rid of blank spaces, returns, and other weirdness. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] returning results of cURL POST
> From: Lowell Allen <[EMAIL PROTECTED]> > [snip] > > // check cURL results > if ((trim($curl_results) != 1) || (trim($curl_results) != 0)) { > // maybe nothing returned, bail out > echo("Can't confirm results of attempt to add to database!\n"); > exit; > } I knew I'd find a stupid mistake as soon as I posted the question. I was using a condition that could never be true, instead, I needed: if ((trim($curl_results) != 1) && (trim($curl_results) != 0)) Sorry. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] returning results of cURL POST
I'm using cURL to POST form fields to a PHP script on a different server that does a database insertion. I know the POST is working, because the values are being inserted into the database. But I want to return results from the remote server so I can tell if the insert was *not* done. Here's the relevant part of the sending script: $ch = curl_init(); $remote_url = "http://www.whatever.com/scriptname.php";; curl_setopt ($ch, CURLOPT_URL, $remote_url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $field_values); ob_start(); curl_exec ($ch); curl_close ($ch); $curl_results = ob_get_contents(); ob_end_clean(); // check cURL results if ((trim($curl_results) != 1) || (trim($curl_results) != 0)) { // maybe nothing returned, bail out echo("Can't confirm results of attempt to add to database!\n"); exit; } Here are the relevant parts of the receiving script: // return notice if connection fails if (!$db_connection) { echo 0; exit; } ... // return notice if database insert fails if (!$db_connection->execute($insert_sql)) { echo 0; exit; } else { echo 1; } The receiving script doesn't display anything and should only echo as shown above. I don't get how to return success or failure from the receiving script. The information I've been able to find on cURL doesn't clarify this. Can anyone shed some light? Thanks. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] tracking bulk email
> From: "Matt Schroebel" <[EMAIL PROTECTED]> > >> -Original Message- >> From: Lowell Allen [mailto:[EMAIL PROTECTED]] >> Sent: Monday, February 03, 2003 12:38 PM >> To: PHP >> Subject: [PHP] tracking bulk email >> (1) My client is nervous about the script failing mid-list >> and not being >> able to determine which contacts were sent mail. I need a way >> to build this >> check into the content management system. I could write a flag to the >> database every time mail() returns true, but that would mean >> 1400 database >> updates! If I instead append to a variable each time through >> the mail() >> loop, I'll lose the record if the script times out. Can >> anyone suggest a way >> to record the position in a loop if a time out or failure occurs? > > What's wrong with 1,400 database updates? Seems to me that's the most > straight forward solution, easiest to recover from, easier for someone > following your footsteps to work on later, and is what db's are for.. > Have you timed it, and felt pain? You could email yourself 1,400 times > to test, and see if it hurts. I haven't tried it from a database, no, and I don't know if the time requirement would be prohibitive. As it is, the best test time has been 0.186 seconds per email, and the worst has been 0.847 seconds per email (from about 4-1/2 minutes to about 19-3/4 minutes for 1400 addresses). I just *assumed* it would take longer to write to a db; I should compare. I certainly agree it would be easier to manage recovery from mid-list failure with everything stored in a database. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] tracking bulk email
> From: "Leonard Burton" <[EMAIL PROTECTED]> > > What about making the log a .txt file and not a database? Wouldnt that be > quicker? [snip] >> Thanks, Kevin. I've put a counter in place within my mail loop. It seems to >> slow the process, but perhaps not too much. And thanks to Mark McCulligh for >> describing a system for sending about 1500 messages that's called with a >> cron tab and writes to a db after each mail. And thanks to Chris Hayes for >> pointing to relevant list archives. My system seems to be working, but it's >> so slow that I'm going to look at using a cron tab and saving everything to >> a database for easier reference in case of failure mid-list. I'm not sure how the speed of flat file access compares to MySQL access; I assume for simple stuff flat file reading/writing is faster. Currently my system does use .txt files to store/record standard message intro text, standard exit text, reply-to name, reply-to address, list of addresses that failed, the actual contact list (which is pulled from a remote MSSQL server each time email is sent), and a counter of mail attempts generated while looping through the email list (thanks, Kevin). But if I do a version with a cron tab I'll store in MySQL instead, since speed really wouldn't be much of a factor for a process without user involvement, and for me it would be easier to manage. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] tracking bulk email
> From: "Kevin Stone" <[EMAIL PROTECTED]> > > - Original Message ----- > From: "Lowell Allen" <[EMAIL PROTECTED]> > >> I've added an email feature to a content management system that will send >> plain text email to about 1400 contact addresses. Each contact is sent a >> separate email with the contact name and address in the "To:" header. It >> works fine to small test lists, but hasn't been tested with a large list. >> >> Although I think list posts should only pose one question, I have two: >> >> (1) My client is nervous about the script failing mid-list and not being >> able to determine which contacts were sent mail. I need to build this >> check into the content management system. I could write a flag to the >> database every time mail() returns true, but that would mean 1400 database >> updates! If I instead append to a variable each time through the mail() >> loop, I'll lose the record if the script times out. Can anyone suggest how >> to record the position in a loop if a time out or failure occurs? > >> (2) In order to avoid the script timing out, I'm counting the number of >> mail() attempts and calling set_time_limit(30) every 50 attempts to >> provide another 30 seconds of script execution time. [snip] > In response to your first question. File stores are something a computer > does very very fast (might want to add some error catching to this).. > > $i=0 > while() { > count_index($i) > $i++; > } > > function count_index ($i) { > $fp = fopen('count.txt', 'w'); > fwrite($fp, $i); > fclose($fp); > } Thanks, Kevin. I've put a counter in place within my mail loop. It seems to slow the process, but perhaps not too much. And thanks to Mark McCulligh for describing a system for sending about 1500 messages that's called with a cron tab and writes to a db after each mail. And thanks to Chris Hayes for pointing to relevant list archives. My system seems to be working, but it's so slow that I'm going to look at using a cron tab and saving everything to a database for easier reference in case of failure mid-list. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php