Re: [PHP] LIMIT?
On Mon, Feb 06, 2006 at 05:08:59PM +0200, Andrei wrote: You can use SELECT fields FROM table WHERE condition LIMIT 15, -1 and it will select all from 15... Andy William Stokes wrote: Hello I have a news page which is getting quite long now and I would like to split the news to two pages. Now I have one SQL query for all the rows and I think I could use LIMIT to limit the results but how to limit the results for example to 15 rows for page one and from 16 to the last on second page? Number of rows increase daily. One page one there's headline and short summary and the second page should be archive with only the headline so all remaining rows can be printed to one page. Something like: SELECT * FROM `x_news` LIMIT 0 , 15 but how to do the archive page SELECT * FROM `x_news` LIMIT 16 , xx? Thanks -Will Answers that show SQL commands that apply to specific databases annoy me. Not everyone uses MySQL. I've worked with several databases that don't support a LIMIT command. At least mention the database engine you are referencing. -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 --- A liberal is someone too poor to be a capitalist and too rich to be a communist. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] large files and readfile
On Mon, Feb 06, 2006 at 09:21:22AM -0800, Daniel Bondurant wrote: I am using php and readfile() to control the download of large files; These files can be up to 1GB.There is nothing really exciting or special about the script itself. The problem I am running into is php is loading the entire file into apache's memory as the file is being read - this seems quite unnecessary. I tired it with fpassthru() as well, with the same result. Why is php loading the entire file into memory? Is there another/ better way to download the files (other that resorting to mod_rewrite) that won't use up necessary memory? thanks - daniel Try 'fread' instead. You can control how many bytes are read. Something like: // get contents of a file into a string $filename = /usr/local/something.txt; $handle = fopen($filename, r); do { $contents = fread($handle, number of bytes to read); } while ($contents !== false); fclose($handle); What are you doing with the file? Do you want to output it as you read it? You will need to send the contents of $contents to the browser and flushing buffers. -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Window close.
On Mon, Feb 06, 2006 at 02:05:55PM -0500, tedd wrote: Hi: This might seem like a odd question, but in php I can leave a script by exit; But, how can I also close the html page that contains the script? I know that I can close the page many different ways via a user actions, but how can I close it from within a conditional php statement? Thanks. tedd -- http://sperling.com/ I've usually resorted to using Javascript: function close_window($msg='') { echo script language='Javascript'\n; if (!empty($msg)) { echo alert(\$msg\);\n; } echo self.close();\n; echo /script\n; exit; } -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Decision table/business rule parser?
On Tue, Nov 22, 2005 at 02:49:41PM +0100, Jochem Maas wrote: Geoff - Creative Living wrote: Hi Mike As an alternative, I worked briefly on a native PHP Petri-net workflow engine with a guy called Tony Marston before we parted ways. He has written it up here: http://www.tonymarston.net/php-mysql/workflow.html guess I didn't have to point you at that then ;-) Geoff Caplan Creative Living I wrote to Tony a couple of months ago and he said that his workflow code might be available someday, but wasn't available currently. His ideas are published on his website, but only code snippets. -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pre global configuration
On Tue, Sep 27, 2005 at 10:40:06AM -0400, Jake Gardner wrote: This is a stretch and I doubt you can do this very easily, but I was wondering if there is a way to define behaviors that happen throughout a script before execution for example if the OS is windows, all strings are terminated with \r\n, if Linux, then \n without adding addition ifs throughout the code. You could do something like: if (strtoupper(substr(php_uname('s'), 0, 3)) == 'WIN') { define('CRLF', \r\n); } else { define('CRLF', \n); } Then use the constant CRLF in your strings. You can put the above snippet in a file that is auto-prepended whenever php is invoked. -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Learning PHP - question about hidden form fields
On Wed, Sep 07, 2005 at 06:47:28PM -0400, Iggep wrote: Hey all! I sat down and started learning PHP today and ran into a bit of a spot. Hoped someone here could lead me in the right direction. I created a simple test form called form.php. I thought I had this strait in my mind when I created it, but obviously it didn't work. All I want to do is create a static value and pass it back to the page which then triggers a statement for the user to read. Problem I'm running into is that I can't seem to find a way to pass that variable correctly with all this being on a single file. I'd prefer to do this in a single file if possible. Any ideas? html head titleTest Form/title /head body ?php if ($_POST['form_submitted']=='y') { if (defined('form_submitted')){ echo pThank you for submitting your trouble ticket. We have received your trouble ticket and will be in touch with you about it as soon as possible./p; echo pIf you wish to submit another ticket, please use the form below./p; } echo form action='form.php' method='post'; echo input type='hidden' name='preform_submitted' value='y'; echo input type='hidden' name='form_submitted' value='$preform_submitted'; echo table; echo trtdLast Name:/tdtdinput name='lname' type='text'/td/tr; echo trtdFirst Name:/tdtdinput name='fname' type='text'/td/tr; echo trtdEmail Address:/tdtdinput name='email_add' type='text'/td/tr; echo trtd colspan=2Trouble:/td/tr; echo trtd colspan=2textarea name='explan'/textarea/td/tr; echo trtdinput type='submit'/td/tr; echo /table; echo /form; ? /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 --- Scientists inhabit quite an inhuman world, and so they tend to believe in a universe beyond people. And young people destined to become good scientists tend to be more curious about the universe around them than about other people. -- Jerry Ostriker (Astrophysicist) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best practices for deleting and restoring records - moving vs flagging
On Thu, Aug 11, 2005 at 10:47:09AM -0700, Saqib Ali wrote: Hello All, What are best practices for deleting records in a DB. We need the ability to restore the records. Two obvious choices are: 1) Flag them deleted or undeleted 2) Move the deleted records to seperate table for deleted records. We have a complex schema. However the the records that need to be deleted and restored reside in 2 different tables (Table1 and Table2). Table2 uses the primary key of the Table1 as the Foriegn key. The Primary key for Table1 is auto-generated. This make the restoring with the same primary key impossible, if we move deleted data to a different table. However if we just flag the record as deleted the restoring is quite easy. Any thoughts/ideas ? -- In Peace, Saqib Ali http://www.xml-dev.com/blog/ Consensus is good, but informed dictatorship is better. I like the approach of marking them as deleted. It's easy to modify the SELECT query to ignore deleted records, plus it's easy to restore them if you need them. -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 --- Kato, what is going on in that little yellow brain of yours? -- Chief Inspector Clouseau, in reference to a priceless white Steinway piano. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running a PHP script everyday
On Sat, Jul 30, 2005 at 09:17:20AM -0700, [EMAIL PROTECTED] wrote: I have a PHP script that I need to run once a day. I have it currently setup so that I just run it from my cell phone, but I would prefer something automated. I'd looked into a cron job, but that just looks like it's for doing linux command line stuff on my host. I also thought about writing a never ending while loop with an if statement that checks to see if it's time to run the script, then when it is time, it runs. Then checks to see if it's time again. But even assuming I could get it working, do I really want to have a PHP script that runs all the time. This could be bad if it ate up all the CPU on my server. I'm not even sure I have access rights to kill the process once I start it. Any suggestions? Andrew Darrow Kronos1 Productions www.pudlz.com You don't state what OS you are using, but you certainly can use cron under Linux to run a PHP script. What really matters is what does the PHP script do? For example, I have a PHP script that I run periodically that retrieves data from a database and updates a text file on the disk. What does your script do? -- Jim Kaufman Linux Evangelist public key 0x6D802619 CCNA, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating intelligent forms
On Wed, Apr 13, 2005 at 06:54:25PM -0700, dan wrote: Hello, all - I had some questions regarding the creation of intelligent forms - forms that take data, and then parse it for errors, real data, etc etc. The first idea I had was to make a function to display the form. When the form is submitted, the page would be called again (i.e. the form's ACTION=itself), and then the POST or GET or SESSION variables will be the arguments to the form. The idea is, when this happens, the form will be able to check the data that was sent, verify it, etc etc. If there are no problems with the data, then the user is directed to step 2 of the form, or the second page, to enter in additional data. But how should the redirection happen? ... What you are suggesting sounds a lot like what has been done with PEAR's QuickForm and QuickForm_Controller. Look at pear.php.net and see what's already been done. Why re-invent the wheel? -- Jim Kaufman Linux Evangelist public key 0x6D802619, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Illegal string offset error in array
On Mon, Mar 28, 2005 at 11:29:28AM +1200, Jasper Bryant-Greene wrote: Rasmus Lerdorf wrote: Jasper Bryant-Greene wrote: You can't access string offsets with square brackets [] in PHP5. You need to use curly braces {} instead. Not sure where you got that idea. This is not true. -Rasmus Actually, it is. See the following URL: http://www.php.net/manual/en/language.types.string.php#language.types.string.substr Yes, please read that link again. The syntax is deprecated. That doesn't mean it doesn't work as you indicated. If we broke this most of the scripts written for PHP4 would break. -Rasmus Yes, but he's talking about PHP5. He probably has E_STRICT on, which is why he's getting that error. I was telling him to use the correct syntax, which will cause him to not get that error. Best regards -- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 public key: Jasper Bryant-Greene [EMAIL PROTECTED] keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 You do realize you're arguing with Rasmus, right? -- Jim Kaufman Linux Evangelist public key 0x6D802619, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Script stuck on final ?
On Thu, Feb 03, 2005 at 08:25:43PM +0800, Alp wrote: Thanks to both of you. Unfortunately I have found out it was due to another reason: in one function I am trying to insert 3 sets of data into 3 seperate tables. In trying to accomplish that I am using a 'for' loop. The minute I write in the second 'for' loop I loose the page in browser and receive this parse error pointing to the last line of code. Any ideas to how I can overcome this? The loop I am using is given below. Thanks in advance. Alp Code: for ($c=0;$ccount($_POST['inctourid']);$c++) { if ($_POST['inctourid'][$c]!= $_POST['included'][$c]!=){ $sql = INSERT INTO tour_includes (tour_id, included) VALUES ('{$_POST['inctourid'][$c]}', '{$_POST['included'][$c]}')\n; } if (! mysql_query($sql, $link)) { $dberror = mysql_error(); return false; } // for ($i=0;$icount($_POST['extourid']);$i++) { // if ($_POST['extourid'][$c]!= $_POST['excluded'][$c]!=){ // $sql = INSERT INTO tour_excludes (tour_id, excluded) VALUES ('{$_POST['extourid'][$c]}', '{$_POST['excluded'][$c]}')\n; // } // if (! mysql_query($sql, $link)) // { // $dberror = mysql_error(); // return false; // } } // Add closing brace here -- Jim Kaufman Linux Evangelist public key 0x6D802619, CISSP# 65668 http://www.linuxforbusiness.net --- The most merciful thing in the world ... is the inability of the human mind to correlate all its contents. -- H. P. Lovecraft -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cal_days_in_month() missing, how can I tell if it exists
On Tue, Feb 01, 2005 at 08:47:29PM +, Ben Edwards wrote: I have been implementing a system on a different ISP than I normally use and have got:- Fatal error: Call to undefined function: cal_days_in_month() in /home/hosted/www.menublackboard.com/public_html/dev/classes/validator.class.php on line 134 I found a reference to this an the web and it seems PHP is not compiled with calender support. recompile php with the --enable-calendar option. Cant see being able to get the to re-compile PHP so I guess I am going to have to disable the feature. I seem to remember a while ago seeing a function to test weather a function exists in PHP. That way I can have the relevant validation skipped if the function is missing (I will tell the client if they get decent hosting it will start working). So something like function_exists( cal_days_in_month() ) Anyone know what the function is called. Ben I do this: if (!extension_loaded('calendar')) { /* * cal_days_in_month($month, $year) * Returns the number of days in a given month and year, * taking into account leap years. * * $month: numeric month (integers 1-12) * $year: numeric year (any integer) * * Prec: $month is an integer between 1 and 12, inclusive * $year is an integer. * Post: none */ function cal_days_in_month($month, $year) { return $month == 2 ? $year % 4 ? 28 : 29 : ($month % 7 % 2 ? 31 : 30); } } -- Jim Kaufman Linux Evangelist public key 0x6D802619, CISSP# 65668 http://www.linuxforbusiness.net --- The shortest distance between two points is through Hell. --Brian Clark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoiding NOTICEs with list()
On Mon, Jan 24, 2005 at 03:54:45PM -0500, [EMAIL PROTECTED] wrote: This construct: list($v1, $v2, $v3) = explode($sep, $string, 3); will generate NOTICE level errors if there are not enough parts of the string to fill all the variables in the list. What I really want is for list() to set the variables that have a corresponding array element, and then either don't change the others, or set them to NULL -- I could live with either approach. Anyone see a way to get rid of these errors short of this approach: $parts = explode($sep, $string, 3); switch(count($parts)) { case 3: $v3 = $parts[2]; case 2: $v2 = $parts[1]; case 1: $v1 = $parts[0]; } I did try @list(... and it made no difference. I just tried it with php 4.3.8 and it did not throw a NOTICE with @list. I suppose you could try @explode as well as @list. -- Jim Kaufman Linux Evangelist public key 0x6D802619, CISSP# 65668 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with foreatch()
On Sun, Jan 16, 2005 at 03:20:26PM +, Ben Edwards (lists) wrote: I have the following Code: foreatch( $_POST[mtype] as $akey = $avalue ) { echo $akey, $avaluebr; } When I run it I get: Parse error: parse error, unexpected T_AS in /var/www/mb/mb_estab_update.php on line 58 58 is the line with the foreatch on it. However if I replace it with: print_r( $_POST[mtype] ); I get: Array ( [1] = RESTAURANT [2] = BEVERAGEWINE [3] = MAIN ) so the array is populated, what am I doing Wrong? Regards, Ben You could try: foreach( $_POST[mtype] as $akey = $avalue ) { echo $akey, $avaluebr; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MD5 Hashing Comparison
On Sat, Nov 20, 2004 at 05:49:04PM -0500, Gregori Halsiber wrote: Hi, I'm trying to write a md5 hash to auth users... And before I get flamed about md5 not being a crypt system but a hashing system I know... Security is not a problem.. I'm trying to build a standalone Message Update Center intranet with PHP The problem I'm having is comparing a user inputed word or passphrase and comparing the code to the hash on a mysql database here's the code ?php // connect to database $connection = mysql_connect(localhost,root); mysql_select_db(forum); $result = mysql_query('Select username, password from users'); Right here, why not do: $username = $_POST['givenuser']; $result = mysql_query(Select password from users where username='$username'); That way you don't have to go through the loop for every user in the users table. while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // start while fetch loop // This is now guaranteed: if($_POST['givenuser'] == $row['username']) { // Begin user check if( md5($_POST['givenpassword']) == $row['password'] ) print(Welcome!); // The problem I'm having is the comaprisons are not accurate. // If I display --- print(md5($_POST['givenpassword']); // and $row['password'] to the browser all 32 char are identical // No longer needed } // end user check } // end while fetch loop ? Any Ideas at all? I was thinking that there could be somesort of WHITESPACE problem in the hashing of the passed var givenpassword How is 'password' defined in the 'users' table? Is it a char(32) or a varchar(32)? I would suspect a whitespace issue. Try rtrim on the password. if( md5($_POST['givenpassword']) == rtrim($row['password']) ) or possible a problem with a wierd floting point calculation at the comparision level? thanks in advance -- Jim Kaufman Linux Evangelist public key 0x6D802619 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error when I try to display 20 records per page
On Mon, Nov 15, 2004 at 06:56:45PM -0600, Scott McWhite wrote: Hi, I'm using an HTML search form that passes the searchterm to a php file. In my case the searchterm can have 1000s of records in my database, so I implemented a limit which displays 20 records per page. The pagination function works fine with one exception. Example of my problem: searchterm typed in the html search form equals ford, in the database there are 2000 fords, the first page displays 20 fords and then the next page forgets that we are searching fords and displays the equivalent to a wildcard % search and displays accordingly. Does anyone have sample code for using an HTML search form with pagination? Error. Notice: Undefined index: searchterm in C:\Inetpub\cars\search\my_php_file.php on line 2 Notice: Undefined index: searchterm1 in C:\Inetpub\cars\search\my_php_file.php on line 3 Notice: Undefined index: searchterm2 in C:\Inetpub\cars\search\my_php_file.php on line 4 My php file. ?php $searchterm=$_POST['searchterm']; $searchterm1=$_POST['searchterm1']; $searchterm2=$_POST['searchterm2']; $searchterm = addslashes($searchterm); $searchterm1 = addslashes($searchterm1); $searchterm2 = addslashes($searchterm2); // Previous Link if($page 1){ $prev = ($page - 1); echo a href=\.$_SERVER['PHP_SELF'].?page=$prev\Previous/anbsp;; } ...snip... Thank you, Scott Start with the first error message: Notice: Undefined index: searchterm in C:\Inetpub\cars\search\my_php_file.php on line 2 Then look at line 2: $searchterm=$_POST['searchterm']; This indicates that $_POST['searchterm'] is undefined. Why isn't it defined? In order to show up in the $_POST array, it would have to be POSTED, ie you could put it into a hidden field that could show up after the user pressed a Submit button. However, it doesn't appear that you are doing that. (Either that, or I snipped too much off your original post!) You have Previous and Next hyperlinks, each of which passes the page number in the query string. Perhaps you could also pass the searchterm(s) in the query string. Or, you could store them in the $_SESSION array. If you do this, be sure to start the session. -- Jim Kaufman Linux Evangelist public key 0x6D802619 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help: Database Search
Stuart, On Sat, Nov 13, 2004 at 05:31:06AM -0800, Stuart Felenstein wrote: It was not apparent whatsoever. Let me show the code again , but I'll include the print_r returns inline code. ?php $sql = 'SELECT PostStart, JobTitle, Industry, LocationState, VendorID FROM VendorJobs WHERE ' . implode( ' AND ', $where ); print_r($where); //Array ( [0] = VendorJobs.Industry IN(1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','35','','Array) ) Right here, print the contents of $sql. That is the most important thing to know right now. $result = mysql_query($sql) or die (Query failed: .mysql_error()); while($row = mysql_fetch_assoc($result)) ? Stuart -- Jim Kaufman Linux Evangelist public key 0x6D802619 --- A dog teaches a boy fidelity, perseverance, and to turn around three times before lying down. -- Robert Benchley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Big table dump stopping in between
On Sat, Nov 06, 2004 at 10:10:56AM -0500, Ritesh Nadhani wrote: I even tried an HTTP utility but it is also stopping half way thru. I think its a problem with ISPs server. Looks like some server option has to be configured. What database is this again? I had a similar problem with an 'Enterprise class' database. My solution was to update statistics. This gives clues to the database engine on how best to do the qury. Before the update, my large, though not as large as your result set, would just stop partly through. After updating statistics, it worked fine. -- Jim Kaufman Linux Evangelist public key 0x6D802619 --- Life is like an onion: you peel it off one layer at a time, and sometimes you weep. -- Carl Sandburg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 4.3.9 slower then 4.3.8 ... ?
On Wed, Nov 03, 2004 at 08:43:52PM -0400, Marc G. Fournier wrote: I'm not sure how to debug this further ... on the 27th, I upgraded our server(s) to 4.3.9, and since then, the sites just aren't performing very well ... I've tried adding mmcache, and it makes no improvement ... I've tried halving the # of processes running on the server, no improvement ... the only thing I haven't tried yet is downgrading back to 4.3.8, which I'm going to try next ... But, if anyone has any ideas ... ? Something that I can look at, or use to debug? Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664 How about going back to 4.3.8 and seeing if that truly makes a difference. -- Jim Kaufman Linux Evangelist public key 0x6D802619 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help With PEAR::DB Connection
On Sat, Sep 11, 2004 at 01:48:43AM -0500, [EMAIL PROTECTED] wrote: Hello everyone, I have a problem connecting to the Database. When I execute the code at the bottom, it gives me this message: DB Error: extension not found. It sees the DB file and the parameters are correct. I checked the include path and it was correct. Did I do something wrong? Any help would be greatly appreciated. Thank you. require_once 'DB.php'; $user = 'foo'; $pass = 'bar'; $host = 'localhost'; $db_name = 'clients_db'; $dsn = mysql://$user:[EMAIL PROTECTED]/$db_name; $db = DB::connect($dsn); if (DB::isError($db)) { die ($db-getMessage()); } -- Nilaab The message 'extension not found' means that PEAR couldn't find the mysql db extension. Hmm. In cases like this, create a phpinfo.php file as documented on this list and see what shows up. Or, you can type at the command prompt: php -i, then look for the MySQL extension in the output. Also, you neglected to tell us what OS you are running, etc. -- Jim Kaufman Linux Evangelist public key 0x6D802619 --- A dog teaches a boy fidelity, perseverance, and to turn around three times before lying down. -- Robert Benchley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() function problem
On Wed, Sep 01, 2004 at 06:09:04PM +0300, Dre wrote: Hi I was trying to use the mail() function, but it did not work, maybe because of some settings problem or something that I can't figure out I went online and tried to execute the following //=== ?php $from = $_POST['from']; $subject = $_POST['subject']; $content = $_POST['content']; $to = [EMAIL PROTECTED]; $headers = From:.$from; if(mail($to, $subject, $content, From: $from)) { echosent; } else{ echo not sent; } ? //=== the variable values sent from a Form in another and they are sent correctly but I keep having this error //=== Warning: mail(): Failed to connect to mailserver at localhost port 25, verify your SMTP and smtp_port setting in php.ini or use ini_set() in C:\Program Files\Apache Group\Apache2\htdocs\mysite/myfile.php on line 194 //=== my php.ini settings for the mail function are //= [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 sendmail_from = [EMAIL PROTECTED] //= thanks in advance Dre, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hmm. Your php.ini says that the smtp server is on localhost. The error message says that the system can't connect to an smtp server on localhost. Perhaps your smtp server is really at your ISP, say smtp.yourisp.com. -- Jim Kaufman Linux Evangelist public key 0x6D802619 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MSSQL, PHP and Linux
On Wed, Sep 01, 2004 at 04:39:51PM -0400, blackwater dev wrote: I have tried recompiling with --with-mssql and --with-mssql=/usr/include/freetds It all appears to compile correctly, except the info page does not reflect the config was done with mssql at all. below is a snippet of the config switches that were used. --enable-ftp \ --enable-magic-quotes \ --enable-safe-mode \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-discard-path \ --enable-track-vars \ --enable-trans-sid \ --enable-yp \ --enable-wddx \ --without-oci8 \ --with-pear=/usr/share/pear \ --with-imap=shared \ --with-imap-ssl \ --with-kerberos=/usr/kerberos \ --with-ldap=shared \ --with-mysql=shared,%{_prefix} \ --with-sybase=/usr/include/freetds \ --with-mssql=/usr/include/freetds \ Any help would be appreciated. thanks, It looks like you compiled it OK. Did you do a 'make install' afterwards? Did you restart the Apache server? I recently built PHP (4.3.8) with support for MS SQL and that was all I needed to do. -- Jim Kaufman Linux Evangelist public key 0x6D802619 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] row colours
On Sat, Jun 05, 2004 at 04:54:33PM +0200, Marek Kilimajer wrote: BigMark wrote: this piece of script makes alternate row colours, but i want the rows to be coloured in blocks of 8. So the first 8 rows are white then the next are mauve etc etc. Alternatively i could make the rows all the same colour , but i need a blank row after each 8 rows.? Any ideas -- How about: $bgcolor = ($i % 16 8) ? #ff : #ff; print tr bgcolor='$bgcolor'td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; // if ($i%8 == 0) { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; } else { print tr bgcolor=\#ff\td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen ter$item_5/center/td/tr\n; } --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net --- Duty then is the sublimest word in the English language. You should do your duty in all things. You can never do more, you should never wish to do less. -- General Robert E. Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sessions
On Fri, Jun 04, 2004 at 04:22:57PM -0800, BigMark wrote: why is this not working. I am using instead of a form ($name = $_POST[name];) and linking to it from a users logged in page. $FirstName = $_SESSION['first_name']; $LastName = $_SESSION['last_name']; $name = $FirstName , $LastName; Mark Have you started the session? Each page needs a session_start() call before accessing session variables. That is, session_start(); $FirstName = $_SESSION['first_name']; $LastName = $_SESSION['last_name']; $name = $FirstName , $LastName; -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lista en Espanol?
On Wed, May 19, 2004 at 02:02:37PM -0300, Lucas Passalacqua wrote: Hole, queria saber si alguien conoce alguna lista en espanol sobre PHP. Gracias! Start with http:///www.php.net/mailing-lists.php and look for Spanish PHP Mailing List. -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] elseif carry
Try this: echo META HTTP-EQUIV=\refresh\ content=\0; URL=./Conference_Calls.php?Date_and_Time=.$_POST['Date_and_Time'].; On Sat, May 15, 2004 at 07:47:28PM +0400, Ronald The Newbie Allen wrote: I did a cut asnd paste to your code and this is the error that I receive Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\inetpub\wwwroot\check.php on line 9 -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] get_browser() - browscap.ini for Linux
On Wed, Mar 10, 2004 at 02:21:19PM -0500, Shaunak Kashyap wrote: I am running Apache 1.3.29 on a Linux platform. I am trying to use PHP's get_browser function which needs a file called browscap.ini on the server. It *seems* that there is no such file available for Linux (I have checked the manual and the link that it mentions). Can anyone point me to a source for a working, up-to-date Linux version of browscap.ini Thanks in advance, Shaunak I pick up mine from http://www.GaryKeith.com and use it fine under Linux. -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pdflib alternatives
On Mon, Feb 16, 2004 at 09:35:10PM -0300, Fernando M. Maresca wrote: Hello everybody: Is there are any alternatives to the pdflib for on the fly generation of printable documents? May be a postcript lib? I need no fancy things, just speed and minimal formating facilities, even no graphics support is ok. Any sugestions? Thanks in advance to all of you -- Fernando M. Maresca http://www.fpdf.org/?lang=en -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using sessions with register globals off
On Thu, Feb 05, 2004 at 02:32:49PM -0500, Phillip Jackson wrote: it's this easy with register_globals off: $_SESSION['order'] = someValue; no need to name the session. ~Phillip John Nichel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Randall Perry wrote: Ok, with register globals on, this works ('order' being a php object): session_name('name'); session_register('order'); $order-print_something(); With with register globals off, this fails: session_name('name'); $order = $_SESSION['order']; $order-print_something(); Get the errors: PHP Notice: Undefined variable: _SESSION PHP Fatal error: Call to undefined function: print_something() Meaning the _SESSION arr is not recognized and the $order obj variable has not been passed. What am I missing? Where do you assign $_SESSION['order'] a value? Everyone in this thread has forgotten to mention the all important 'start_session();' command. Without that, you do not have access to your session variables. -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net --- Life is not one thing after another It's the same damn thing over and over! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: progress in PHP
On Tue, Dec 23, 2003 at 11:46:50AM -0500, Ed Curtis wrote: Join the 11,000 people who use megaupload progress bar (with a little help from perl) http://www.sourceforge.net/projects/megaupload/ I tried. It wasn't worth all the perl mods I would to have had to install to make it work. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Check out http://pear.laurent-laville.org/HTML_Progress/. It is a pure php approach to displaying a progress bar. I haven't used it, but the demos look good. -- Jim Kaufman Linux Evangelist public key 0x6D802619 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Recommendation for Unique URL
I have an application that does not require a user to log in. But, they do enter their email address and their dept. manager's email address. I want to send an email to the dept. manager that contains a personalized URL so they can click on that and see a page relevant to what the employee entered. What is the best approach to the unique page ID? I thought I would store the dept. mgrs. email address and the session ID in a db, and use the session ID in the URL. Do I even need the mgr's email address? Is another approach better? What have you used? -- Jim Kaufman mailto:[EMAIL PROTECTED] Linux Evangelistcell: 612-481-9778 public key 0x6D802619 fax: 952-937-9832 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION Not behaving II: permission denied(13)
On Sat, Oct 18, 2003 at 03:44:31PM +0300, Burhan Khalid wrote: [-^-!-%- wrote: Yep. It's me again. 96 hours into the battle, and SESSIONS are still winning. I've written my login script and is now getting the following error. Please advise. Warning: open(/tmp/sess_a690c089dead297c95034d9fe243f860, O_RDWR) failed: Permission denied (13) in Unknown on line 0 Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 First thing, make sure /tmp exists. If it does, make sure that the apache user has permissions to write to it. You can modify its permissions so that the apache user and/or group can write to /tmp; or you can chmod it to 777 (which could lead to other security issues). This should get rid of your warnings. -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com The standard permissions for /tmp are 1777. This allows any user to write to tmp, but only the user who created a specific file (eg, the session file as apache) can delete the file. Further, sesssions are created with a very restrictive permission set, so that ony the apache user and root will be able to read the data. Bottom line: make sure that /tmp exists and that its permissions are 1777. (as root, chmod 1777 /tmp) -- Jim Kaufman mailto:[EMAIL PROTECTED] Linux Evangelistcell: 612-481-9778 public key 0x6D802619 fax: 952-937-9832 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions Question
On Tue, Oct 14, 2003 at 05:23:54PM -0800, Chris Hubbard wrote: to use php sessions: you will need some place where you set up/create the sessions. typically this is the login page. let's assume you'll use the login page. The logic for the login page goes something like this: 1. present a form for logging in (usually username/password) 2. on post, clean the posted data (remove html, special characters, etc) 3. check the cleaned username/password against the data in the database 4. if the username/password is valid, create your session and assign variables to it like this: session_start(); //create the session $id = session_id(); // create a unique session id session_register(id); // register id as a session variable session_register(name); // register name as a session variable session_register(email); // register email as a session variable $_SESSION[id] = $id; // assign the unique session id to session array $_SESSION[name] = $data[name]; // assign the username to session array $_SESSION[email] = $data[email]; // assign additional values (after regisering them) to session array Hope this is helpful. Chris There is no need to register variables as a session variable if register_globals is foff. The manual states: If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled. So the three 'session_register' statements above should be removed. -- Jim Kaufman mailto:[EMAIL PROTECTED] Linux Evangelistcell: 612-481-9778 public key 0x6D802619 fax: 952-937-9832 http://www.linuxforbusiness.net --- Any smoothly functioning technology will have the appearance of magic. -- Arthur C. Clarke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unknown Syntax
On Fri, Jul 11, 2003 at 01:56:46PM +0100, Chris Morrow wrote: Does anybody recognize this: !== with 2 '=' Ive known != to mean not equal to but i'm just looking at someone elses script and they use this instead. Does anyone know if this works or any problems with it? Cheers The syntax means 'not true' You can use it after a strpos operation to distinguish 'string was not found' from 'string was found at position 0'. -- Jim Kaufman mailto:[EMAIL PROTECTED] Linux Evangelistcell: 612-481-9778 public key 0x6D802619 fax: 952-937-9832 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Checking if an array key exists
I have a multi-dimensional array. Looks like this: $work_order_hdr = array ('whdr_id'='record_no', 'whdr_order_no'='request_no', 'whdr_site_id'='site_id', 'whdr_user_id'='user_id', 'whdr_location'='location', 'whdr_date_submitted'='date_submitted', 'whdr_date_acknowledged'='date_acknowledged', 'whdr_date_approved'='date_approved', 'whdr_date_rejected'='date_rejected', 'whdr_date_cancelled'='date_cancelled', 'whdr_date_closed'='date_closed', 'whdr_status'='status'); $work_order_hdr['links']['whdr_site_id']='site_master[site_id]'; $work_order_hdr['links']['whdr_user_id']='user_master[user_id]'; I use the a part of the array to display the field names from the db in a more user-friendly manner. The 'links' part is new and is intended to link certain fields to fields in other tables. I have a variable called '$tbl' that contains a table name, in this case $tbl='work_order_hdr'. I can reference 'whdr_id' like this: echo $$tbl['whdr_id'] That gives the expected 'record_no' I can't seem to access the links correctly. I've tried various combinations of 'isset' and 'array_key_exists' but can't find the correct syntax. The system in question is running php 4.1.2. Suggestions? -- Jim Kaufman mailto:[EMAIL PROTECTED] Linux Evangelistcell: 612-481-9778 public key 0x6D802619 fax: 952-937-9832 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using SELECT and MULTIPLE in a form
I am displaying a form using values obtained from a database query. One of the elements contains about 20 different values. I want the use to be able to select multiple values before pressing submit. This seems to work, but when my php script is called, all I see is the last data value assigned to the variable. I could use a pointer. Here is a code snippet: echo TR\n; echo TDTask Description/TD\n; echo TDSELECT NAME='in_task_descr' MULTIPLE SIZE=4\n; for ($j = 0; $j $tskcount; $j++) { echo OPTION VALUE=\$taskdescr[$j]\$taskdescr[$j]/OPTION\n; } echo /SELECT\n; echo /TD\n; echo /TR\n\n; The above code adds a list to the form and the user can highlight more than one entry. How do I access the data after the user presses submit? -- Jim Kaufman mailto:[EMAIL PROTECTED] Linux Evangelistcell: 612-481-9778 public key 0x6D802619 fax: 952-937-9832 http://www.linuxforbusiness.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php