RE: [PHP] Yikes! Strange Occurrence of ! in mail
This would be of some use to you http://bugs.php.net/bug.php?id=13342&edit=1 -Naintara -Original Message- From: Nicole [mailto:[EMAIL PROTECTED] Sent: Monday, September 15, 2003 2:32 PM To: [EMAIL PROTECTED] Subject: [PHP] Yikes! Strange Occurrence of ! in mail Has anyone experienced exclamation points ! in their emails from no where? This is a really strange thing I have been noticing lately in emails I send to myself via PHP. When I send an email from 2 different machines using 2 different smtp servers, I still get the exclamations in the email. Any ideas what on earth is causing that? Example: the!ir is an ex!clamation in my e!mail that I did not pu!t there. Why?? Thanks! -- Nicole -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.518 / Virus Database: 316 - Release Date: 9/11/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Fatal error: Call to undefined function: mysql_connect()
I get this error "Fatal error: Call to undefined function: mysql_connect() " in one script. whereas phpMyAdmin is installed in another directory and it works fine. Any ideas why? -Naintara -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] twodimensional array / word-frequencylist
Very simple, there's a function designed just for this. check out the manual for array_count_values() array_count_values() returns an array using the values of the input array as keys and their frequency in input as values. EXAMPLE: $array = array (1, "hello", 1, "world", "hello"); print_r(array_count_values ($array)); The printout of the above program will be: Array ( [1] => 2 [hello] => 2 [world] => 1 ) -Cheers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Dore van Hoorn Sent: Thursday, June 26, 2003 4:56 PM To: [EMAIL PROTECTED] Subject: [PHP] twodimensional array / word-frequencylist Hi, I asked the same question two days ago, but i have not received an answer that could really help me on my way... So i'll try again, this time with the help of a little PHP code, and soms explanations while($myrow = mysql_fetch_row($result)) # as long as there are texts in the database { $text = $myrow[0]; # variabele text contains the text $array = array(); # variabele array is an empty array $modText = strtolower($text); #modify text: string to lower case $array = split(" ",$modText); #split text after empty space to create array of words # i would like a similar function that removes interpuntuation like "." etc. # all i want remaining in the array are the separate words, all in lower case sort($array); # sort array elements in alphabetical order $num = count($array); # count the number of elements in the array for ($c=0; $c<=$num; $c++) #as long as function has nog reached past last element in array { $wordInText = $array[$c]; #array element is word in text echo "$wordInText"; #print word in text } # i would like a function that pushes this word into a second array. # before pushing, it has to check whether or not the same word is already in the array. # if it is: do not push word into array, but add "1" to the number of occurrences of that word # if it is not: push this new word into array # all of this has to result into a word - frequency array (content analysis of free text) # question 1: how do i produce such an array? # question 2: how do i get the two elements (word and number of occurrences) # together out of the array and print them to the screen? # f.e.: the word "computer" occurred two times in this text. } I do hope there is someone out there who can help me with this problem, and help me fast Thnx in advance!! Dore. +++ NDore van Hoorn Ss1000454 AlfaInformatica-RuG E[EMAIL PROTECTED] Whttp://www.let.rug.nl/~s1000454 +++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] need help breaking out of loop.
Are you incrementing number_of_days anywhere within the loop? It looks like you have an infinite loop running. If you want to be able to move to the next date, increment you date variable. -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of anders thoresson Sent: Thursday, June 26, 2003 4:31 PM To: [EMAIL PROTECTED] Subject: [PHP] need help breaking out of loop. Hi, I'm working of a PHP-MySQL-planning system for a newspaper. I want to add dates and number for each issue. I have to following code, where $current_date is a unix timestamp. If $current_date is a Saturday or Sunday, I want to quit the current execution of the loop and contiune with the next date. But when the if- clause that checks if $issue_day_of_week is Sunday or Saturday is included in my while-loop, everything stalls. Without it, everything goes smooth. What am I missing? while ($i <= $number_of_days) { $issue_date = strftime("%Y-%m-%d", $current_date); $issue_month = date("m", $current_date); $issue_day = date("d", $current_date); $issue_day_of_week = date("l", $current_date); // Check that $issue_date isn't Saturday or Sunday if ($issue_day_of_week == "Sunday" | $issue_day_of_week == "Saturday") { continue; } if ($issue_month == 1 & $issue_day == 1) { $issue_number = 1; $current_date = $current_date + 86400; $i++; $issue_number++; continue; } $current_date = $current_date + 86400; $i++; $issue_number++; } -- anders thoresson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Weird mktime problem
You might want to consider removing the leading zeroes, this post is there in the php manual and has been useful to me. -xxx- jchen3625 AT yahoo DOT com (25-Aug-2002 03:33) beware, arguments with leading zeros are treated as zeros. that is, "mktime(0,0,0,10,09,2002)" == 09/30/2002, whereas "mktime(0,0,0,10,9,2002)" == 10/09/2002. -xxx- Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Ford, Mike [LSS] Sent: Thursday, June 26, 2003 3:23 PM To: 'Glenn'; [EMAIL PROTECTED] Subject: RE: [PHP] Weird mktime problem > -Original Message- > From: Glenn [mailto:[EMAIL PROTECTED] > Sent: 25 June 2003 14:58 [] > Here is what's weired. > > I use these lines to get the specifics: > $StartHour = substr("$StartTime", 0, 2); > $StartMinute = substr("$StartTime", 3, 2); > $EndHour = substr("$EndTime", 0, 2); > $EndMinute = substr("$EndTime", 3, 2); > list($SMonth, $SDay, $SYear) = split('/', $StartDate); > list($EMonth, $EDay, $EYear) = split('/', $EndDate); > > I then do this: > $SUnixTime = mktime($StartHour, $StartMinute, 00, $SMonth, > $SDay, $SYear); > > This is what's being sent to the mktime: > (17,00,00,06,23,2003) > > This is what it ouputs: > 1056405600 > > Which is not technically correct. That is the unix time stamp for the > starting our in Zulu time (greenwich mean time) which is > currently 5 hours > ahead of my timezone. > > Can anyone tell me why mktime is automatically converting to > zulu time? UNIX timestamps are *always* GMT -- it's the routines that process them that do timezone (and DST) conversion. To prove this, run the following on your server: \n"; echo "local = ", date("Y-m-d H:i:s"), "\n"; ?> Also see the manual page for gmdate() at http://www.php.net/gmdate which shows a very similar script as its first example. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Fw: Help
You possibly have a select list box named 'title[]' remove the brackets [] and rename the list box 'title'. That should work. -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Tirnovanu Aurel Sent: Saturday, June 21, 2003 12:28 PM To: [EMAIL PROTECTED] Subject: [PHP] Fw: Help Can anyone tell why this script: $query = "INSERT INTO mos_articles (catid, title, content, date, author, approved, published) VALUES ('5','$title','$content','$data','$author','1','1')"; $result = mysql_query($query); add in title field "array" and not the input. -- 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] in a logic loop!
sweet solution. :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Marek Kilimajer Sent: Tuesday, September 24, 2002 1:44 PM To: PHP Subject: Re: [PHP] in a logic loop! Do it after the loop finishes while( ){ if( something ) { print out; reinicialize } } print out Naintara Jain wrote: >I have a logic problem: > >I have a complicated query. The main thing is that I have an ID, and for a >particular ID, I may have between 1 to 3 rows returned. The rows returned >are variable, that is for 1 particular ID there might just be 1 row and at a >later time it may have 3 rows. > >But what I need to do is print only one row for a particular ID. Please do >not suggest I do it through SQL itself, because it's after using various >aggregate functions that I have arrived at the min. result set. I need the >logic clarified, because it has me stumped. It will be simple for a >clear-thinking individual. > >What I am doing is: >I maintain a set of details in say $prev_row (previous row) and another in >cur_row (current row). >The minute my cur_row detail (one unique id) doesn't match the prev_row >detail, I print out all the previous row details, and reinitialize the >various variables (all in a loop). > >This works fine for all cases but fails for the last ID, because of the >logic used. Do I need to create a special case for the last one, or can >anyone suggest a better way? > >-Thanks >Naintara > > > > > -- 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] in a logic loop!
Thank you Chris. I agree with you wholeheartedly that the SQL should be optimized. Now, I don't want to freeload on your time, but I have a very complex query, which I have been pondering over for the last many days. If anyone can tell me what query will return just one row for the problem I have, s/he will be SQL Guru to me. My problem is: I have 3 tables (given below). A member of the staff takes courses and for each course he has requirement id, these details get stored in the staff_courses table. Each course taken will have a requirement specification which could be any of 4 values given below (after the reqs table). I need to get totals for each requirement for each member of the staff. I am using MySQL (and cannot use sub-queries). I have been able to get the requirement totals for each member using Group By reqid, but I get a separate row for each requirement against the member of staff. So if a member has taken 3 courses, and one course has a reqid of 0 and the other two courses have a reqid of 1, I get 2 rows in the result set for that staffid, one will contain the reqid 0 and total as 1, while the second row will contain the reqid as 1 and the total as 2. Can I get the totals for each requirement in one row and can I do this in one query? 1)"staff" table staffid branchid 2)"staff_courses" table courseid staffid reqid 3)"reqs" table reqid requirement contains the reqid requirement 0 No action 1 Primary requirement 2 Further requirement 3 Completed -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Chris Hewitt Sent: Tuesday, September 24, 2002 1:49 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] in a logic loop! Naintara Jain wrote: >What I am doing is: >I maintain a set of details in say $prev_row (previous row) and another in >cur_row (current row). >The minute my cur_row detail (one unique id) doesn't match the prev_row >detail, I print out all the previous row details, and reinitialize the >various variables (all in a loop). > >This works fine for all cases but fails for the last ID, because of the >logic used. Do I need to create a special case for the last one, or can >anyone suggest a better way? > When you come out of your loop, either there will be one row left to print, or there were no matching rows. Suggestion one is to test for this and if there were matching rows, do a special case for the last row. Alternatively, you are printing a row when the ID changes, that is, the last row of the 1 to 3 matching rows. Why not print the first one, not last one? You change the logic to print the first row then ignore others with the same ID. It could be that (because of an Order By clause) the last row is the correct one and the data may differ between rows with the same ID. You say you do not want to do it in the SQL statement itself, but this really is the right place. If MySQL use a LIMIT clause to only get one row, if you cannot refine the SQL statement to only retrieve one row. HTH Chris -- 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] in a logic loop!
I have a logic problem: I have a complicated query. The main thing is that I have an ID, and for a particular ID, I may have between 1 to 3 rows returned. The rows returned are variable, that is for 1 particular ID there might just be 1 row and at a later time it may have 3 rows. But what I need to do is print only one row for a particular ID. Please do not suggest I do it through SQL itself, because it's after using various aggregate functions that I have arrived at the min. result set. I need the logic clarified, because it has me stumped. It will be simple for a clear-thinking individual. What I am doing is: I maintain a set of details in say $prev_row (previous row) and another in cur_row (current row). The minute my cur_row detail (one unique id) doesn't match the prev_row detail, I print out all the previous row details, and reinitialize the various variables (all in a loop). This works fine for all cases but fails for the last ID, because of the logic used. Do I need to create a special case for the last one, or can anyone suggest a better way? -Thanks Naintara -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] gmdate()
lets say, ServerOne has TimeZone GMT+2 ServerTwo has TimeZone GMT+3 the gmdate() will return diff values for the same timestamp. essentially there will be a diff of 1 hour in the return values from these two servers. -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of lallous Sent: Friday, September 06, 2002 8:55 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] gmdate() I don't own the server, and the server is probably set up correctly as it is a web hosting server. anyway, how should that RedHat 6 server be set up ? Elias "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > The server needs to be set up correctly - it needs to know what time > zone it is in and if the BIOS time is GMT or local. > > lallous wrote: > > >Isn't the gmdate() supposed to return the same value when run from two > >different timezones? > > > > > >I run it on GMT+2 system and EDT system, and I get 1 hour difference, > > > >please advise. > > > >Elias > > > > > > > > > > > -- 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] cant find the wrong?
are u using the exact code (below, as given by u) if yes, the 1st page has the problem (missing = ), replace with this name="id" not name "id" -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Meltem Demirkus Sent: Friday, September 06, 2002 2:16 PM To: [EMAIL PROTECTED] Subject: Fw: [PHP] cant find the wrong? I am correcting I used echo $id; but did not work thanks. meltem - Original Message - From: "Meltem Demirkus" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, September 06, 2002 11:42 AM Subject: [PHP] cant find the wrong? > > > > Hi, > > I am using this on a page to move 'new_id' to another page: > > > > > > > > and onthe other page I qm tring to get the data like this: > > > > $id= $_POST['id'] ; > > > > even I tried > > echo $new_id; (directly use the data) > > but it is not working..WHY? > > > > > > thanks > > meltem demirkus > > > > > -- > 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] question about Location
see, if you output anything for the user, then you cannot use a header if your include files have echo/print statements or errors that are displayed then it is considered output. use JavaScript to redirect the page look up window.location= in JavaScript reference embed that script in php. or else turn output buffering on. look up * http://www.zend.com/zend/art/buffering.php * http://www.phpbuilder.com/columns/argerich20010125.php3 (taken from php manual) -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Meltem Demirkus Sent: Friday, September 06, 2002 3:47 PM To: [EMAIL PROTECTED] Subject: Fw: [PHP] question about Location I tried , but it is giving this error: Warning: Cannot add header information - headers already sent by (output started at C:\FoxServ\www\debugger\project_module\project_update_.php:2) in C:\FoxServ\www\debugger\project_module\project_update_.php on line 37 the line 2 is and start_html.php includes: and line 37 is the header I wrote - Original Message - From: "Marek Kilimajer" <[EMAIL PROTECTED]> To: "PHP" <[EMAIL PROTECTED]> Sent: Friday, September 06, 2002 12:55 PM Subject: Re: [PHP] question about Location > doesn't mean output unless you use echo or print or whatever to > output from there anything. > Just use header("Location: yournewpage.php"); at the end. > > Meltem Demirkus wrote: > > >>I mean I made a page with php and other stuff..And there is form .When I > >>click on okbutton php is dpoing what it should . But after want the page > >> > >> > >to > > > > > >>come to another link.I asked that before and they told me that .. there > >> > >> > >must > > > > > >>be no uotput but I am using which means output.. > >> > >>so I dont know what to do.. > >>meltem > >> > >> > >>- Original Message - > >>From: "Brad Bonkoski" <[EMAIL PROTECTED]> > >>To: "Meltem Demirkus" <[EMAIL PROTECTED]> > >>Cc: <[EMAIL PROTECTED]> > >>Sent: Friday, September 06, 2002 12:36 PM > >>Subject: Re: [PHP] question about Location > >> > >> > >> > >> > >>>Not quite sure what you are getting at here? A hyper link would direct > >>>the user to another page :-) > >>>If you mean after a timeout/auto-magically perhaps you can try meta > >>> > >>> > >>refresh: > >> > >> > >>>http://www.htmlhelp.com/reference/html40/head/meta.html > >>> > >>>HTH > >>>-Brad > >>> > >>>Meltem Demirkus wrote: > >>> > >>> > Is there anyway to direct my page to another after the php and output > process work on the page? > > thanks > meltem demirkus > > > > > > >>> > >>> > >>> > > > > > > > > > > > -- > 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] PHP/MySQL Search Engine Query Question
You can use explode/split functions on the search parameters - that will give u an array with each search token indexed individually. Suppose the search input was 'abc xyz' $strsearch = "abc xyz"; $search=explode(" ",$strsearch); your array "search" will contain $search[0]=abc $search[1]=xyz Now, you can iterate through the array members and create a SQL string out of it, join the elements with "LIKE" and "AND". so that you have something like SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search[0]% AND whatevercolumn LIKE '%$search[1]% Since you won't know how many search input 'tokens' will be searched on: Use a loop to create the SQL statement. You can also use the implode() function to create the SQL. Textual searches can be optimised somewhat by creating the appropriate indexes (refer to the MySQL manual). -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Paul Maine Sent: Sunday, July 28, 2002 8:02 AM To: PHP PHP Subject: [PHP] PHP/MySQL Search Engine Query Question I am currently working on a website that is implemented using PHP and MySQL. The site currently has a simple search engine that allows a shopper to type in a search string that is stored in $search. For example, if a shopper types in 1972 Ford Mustang $string ="1972 Ford Mustang" Using the following SQL statement: SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search% Records are returned that have this exact string and in this exact order (I'm aware a wild card character is included on the front and back of the string). My desire is to be able to logically AND each token of the search together independent or the order of the tokens. I want to return all records that have Mustang AND 1972 AND Ford. Since a shopper inputs the search string in advance I don't know how many tokens will be used. I would appreciate any suggestions. Regards, Paul -- 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] Password Generator Script
The following code was created to generate a random password. But it can be used to generate a random string for any purpose. The basic idea was to create an array that would contain all the letters of the English alphabet, and pick out random values from that array. I have outlined two methods below, please also read the explanation/comments provided below. Method 1: $strrandom=; $ivalfrom =ord("a"); $ivalto =ord("z"); for($i=$ivalfrom; $i<=$ivalto; $i++) $arralpha[] = chr($i); mt_srand ((double) microtime() * 100); $rand_al = array_rand ($arralpha, 3); $strrandom = $arralpha[$rand_al[0]] . $arralpha[$rand_al[1]] . $arralpha[$rand_al[3]]; $numpart=mt_rand(10,99); $strrandom .= $numpart; echo "random = $strrandom"; - Method 2: $strrandom=; $ivalfrom =ord("a"); $ivalto =ord("z"); for($i=$ivalfrom; $i<=$ivalto; $i++) $arralpha[] = chr($i); mt_srand ((double) microtime() * 100); $strrandom = $arralpha[mt_rand(0,25)].$arralpha[mt_rand(0,25)].$arralpha[mt_rand(0,25)]; $numpart=mt_rand(10,99); $strrandom .= $numpart; echo "random = $strrandom"; - Explanantion: /* I used a for loop to populate the array with the alphabets in lowercase (to increase the number of values, you could probably insert uppercase alphabets too). */ //first populate array with alphabets $ivalfrom =ord("a"); $ivalto =ord("z"); //add the alphabets to the array for($i=$ivalfrom; $i<=$ivalto; $i++) $arralpha[] = chr($i); /* $arralpha is an array variable which refers to the array of 26 alphabets. */ /* I seed the random generator */ mt_srand ((double) microtime() * 100); /* I wanted my string to contain 3 random letters. I use the array_rand() function, which takes as input an array, and the number of random values desired (which is 3 here, but it could be 26 too, equal to or less than the size of the array). It returns an array, which contains indexes taken at random from the array passed as the argument.*/ $rand_al = array_rand ($arralpha, 3); /* Here, $rand_al is another array variable which contains random indexes */ $strrandom=; $strrandom = $arralpha[$rand_al[0]] . $arralpha[$rand_al[1]] . $arralpha[$rand_al[3]]; /* In the above statement, the values in the $rand_al are really subscripts of the alphabet array, so I use them as subscripts to finally arrive at the random string. You could iterate through the generated $rand_al using a loop to get the subscripts */ /* Please note that array_rand() will work for PHP4 and above, it may not return random values if you do not seed the generator first, and it may still create a problem on some windows machines (a bug, which has been fixed on PHP 4.2.2 dev version). In such a case, use Method 2. */ /* The two lines below add a 2-digit number to the random string. */ $numpart=mt_rand(10,99); $strrandom .= $numpart; -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Liam MacKenzie Sent: Thursday, July 25, 2002 1:04 PM To: [EMAIL PROTECTED]; Monty Subject: Re: [PHP] Password Generator Script Random Password : In action: http://scripts.operationenigma.net/passgen.php Have fun :-) - Original Message - From: "Monty" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, July 25, 2002 2:49 PM Subject: [PHP] Password Generator Script > Can anyone recommend where I could find a decent script that automatically > generates passwords? I don't care if they are readable or just random > letters, numbers. > > 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
FW: [PHP] array_rand() and seed
First I seed the generator with mt_srand ((double) microtime() * 100); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Naintara Jain Sent: Tuesday, July 23, 2002 6:36 PM To: Php-General@Lists. Php. Net Subject: [PHP] array_rand() and seed Using Win2K Professional Server, IIS PHP Version 4.2.1 mt_getrandmax() returned 2147483647 I have an array of 26 characters. I want three random values from the array, I use the following: $rand_al = array_rand ($arralpha, 3); I get the same characters each and every time. The way I am handling it right now is generating random values using mt_rand(0,25) and using those random values as the index of the array to retrieve the value of. Any ideas on this? Thanks. Naintara -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array_rand() and seed
Using Win2K Professional Server, IIS PHP Version 4.2.1 mt_getrandmax() returned 2147483647 I have an array of 26 characters. I want three random values from the array, I use the following: $rand_al = array_rand ($arralpha, 3); I get the same characters each and every time. The way I am handling it right now is generating random values using mt_rand(0,25) and using those random values as the index of the array to retrieve the value of. Any ideas on this? Thanks. Naintara
RE: [PHP] CANT GET STUFF TO WORK
what OS are you running on? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Mike Sent: Tuesday, July 09, 2002 12:37 PM To: Jay Blanchard; [EMAIL PROTECTED] Subject: Re: [PHP] CANT GET STUFF TO WORK I have read that, I am still confused, I have made it so that the session_start is at the top of all the pages, and I can't get some of the variables out of the script (i.e. I set a variable with session_register('user')) and on the next page I could not get the user variable out of the session on the next page.. does that help out? Thank You, Mike - Original Message - From: "Jay Blanchard" <[EMAIL PROTECTED]> To: "'Mike'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, July 09, 2002 3:25 PM Subject: RE: [PHP] CANT GET STUFF TO WORK > http://www.php.net/manual/en/ref.session.php > > Start there, and then when you can tell us what the more specific problems > are with your sessions we will be able to help. > > Jay > > -Original Message- > From: Mike [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 09, 2002 2:20 PM > To: [EMAIL PROTECTED] > Subject: [PHP] CANT GET STUFF TO WORK > > > Hello, I am wondering if you could help me... I can't seem to figure out how > to get sessions working. > Thank You, > Mike > > > -- 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] session problem
Just thought I'd mail it here. It's a reported bug, Bug #16263. Discovered (after hours of agonizing). martin, values were being assigned and passed :) thanks anyway. -Original Message- From: Martin Clifford [mailto:[EMAIL PROTECTED]] Sent: Monday, July 08, 2002 6:29 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] session problem You have to set the variables before using session_register(). If you try registering a variable that has no value, then of course no value can be carried over to the next page. :o) Martin >>> "Naintara Jain" <[EMAIL PROTECTED]> 07/06/02 09:08PM >>> I am storing some values in session variables. The behavior of the session is pretty unpredictable. On the first page I begin with: session_name("aname") session_start() session_register("var1","var2") In another page I check for existing value of session variable "var2". In the next page I have the following code: session_name("aname") session_start() if(($var2)=="" || !isset($var2)) "invalid" But the strange thing is that the session value is not accessible in the other page. I have tried passing the session id though session_id() in the URL. Session handling has been giving me some trouble (windows 2000, IIS) The strange thing is that it works some times. Can anyone give any pointers? -- 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] Linked drop down selection lists and dynamically generated links
You can use both JavaScript and PHP. Initially use PHP to get your data, you can use 13 arrays to store this data. 1st array stores the options for the 1st list. The other 12 arrays can store options related to each item of the 1st list/array. Use JavaScript (client-side scripting, faster) to populate the 2nd list based on the selection in the 1st list. This way you do not run PHP (server-side scripting, slower) more than once on the same page. this is of course, keeping in mind, that your backend (database data) is not changing every few seconds. If you are dealing with dynamic data, such that the list options might be changing at every moment then you would need the latest database data and PHP would need to be used after the selection in the 1st list. -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Peter Goggin Sent: Saturday, July 06, 2002 10:31 PM To: [EMAIL PROTECTED] Subject: [PHP] Linked drop down selection lists and dynamically generated links I have two related tables. The first has about 12 records, each of which is related to about 12 records in the second table. I want to have two interconnectedt dropdown list fields. The fisrt is used to select from the first table and when the value has been selected, use it to determine the contents of the second drop down list. Once the second field has been selected I want to use this data to otain the name of the form to be used to display data selected using the two fields. Obviously I can do this by having interrelated pages where the value from the first fields is carried to the second page and used to populate the second drop down list. I can then presumably dynamically generate the link to the required page and pass over what paraeters are needed. Is there any way of doing this so within a single page? Can this be done using only PHP or do I need to use Javascripts? Where would I be able to find examples of code which does this sort of processing? Any adivice would be gratefully received. Regards Peter Goggin Regards Peter Goggin -- 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
FW: [PHP] session problem
One thing I forgot to mention is that the same code works perfectly on the web server (running on Apache and a Unix flavor). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Naintara Jain Sent: Saturday, July 06, 2002 6:09 PM To: Php-General@Lists. Php. Net Subject: [PHP] session problem I am storing some values in session variables. The behavior of the session is pretty unpredictable. On the first page I begin with: session_name("aname") session_start() session_register("var1","var2") In another page I check for existing value of session variable "var2". In the next page I have the following code: session_name("aname") session_start() if(($var2)=="" || !isset($var2)) "invalid" But the strange thing is that the session value is not accessible in the other page. I have tried passing the session id though session_id() in the URL. Session handling has been giving me some trouble (windows 2000, IIS) The strange thing is that it works some times. Can anyone give any pointers? -- 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] session problem
I am storing some values in session variables. The behavior of the session is pretty unpredictable. On the first page I begin with: session_name("aname") session_start() session_register("var1","var2") In another page I check for existing value of session variable "var2". In the next page I have the following code: session_name("aname") session_start() if(($var2)=="" || !isset($var2)) "invalid" But the strange thing is that the session value is not accessible in the other page. I have tried passing the session id though session_id() in the URL. Session handling has been giving me some trouble (windows 2000, IIS) The strange thing is that it works some times. Can anyone give any pointers? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FOXED - no success in replacing file content using fgets/fputs and str_replace
I need to replace some html code in about 100 files. Wanted to do this through code, and am using fgets() to get a line at a time from the file, this string is saved in variable $line. Then I check for the occurrence of the search string in $line using strpos(). If found, I echo some statements, and I wanted to replace the "search" text with "replace" text using str_replace(). The strange thing is that while the code is able to search out the strings correctly, it doesn't replace the text. The $line var loses its value for no reason. I check for the occurrence of the search string if($pos=strpos ($line, $strfrom)) but when within the if block I try to echo $line I don't get the value, so str_replace doesn't work either. everything else works fine, the strangest thing is that I tried echoing the $line value before the if block and it doesn't print anything, but it works for the if condition. I am getting the no of files and the line nos, where the search string occurs, but no replacements happening. This is the replacement code: $newline=str_replace ($strfrom, $strto,$line); echo "New Line $newline"; if(is_writable($file)) { echo "writable:"; if(fputs($fd,$newline)) $replaced_links++; } Am I missing something really obvious here? thanks. Naintara --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 06/05/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Trying to list a directory content HELP PLEASE
Is that a space in the directory path? I think you will have to use opendir() function first. "opendir: Returns a directory handle to be used in subsequent closedir(), readdir(), and rewinddir() calls. " The manual has some good examples. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of webmaster mbtradingco Sent: Thursday, June 06, 2002 3:56 PM To: 'Scott Hurring' Cc: [EMAIL PROTECTED] Subject: RE: [PHP] Trying to list a directory content HELP PLEASE Hey Scott, that at least helped me to find out what is going wrong. When I use the code as you told me... $fd=readdir("/home/casapu/paginas /image/caterleras/"); if (!$fd) die ("Can't read dir"); It gives me: Warning: Supplied argument is not a valid Directory resource in /home/casapu/paginas/mbt/php/dir.php on line 7 Can't read dir So I'm assuming is not accepting the directory. I have checked the permits, and it has all enabled, read, write and executable. I have tried with the final slash, and without it, and so far it keeps giving me that message... any ideas? -Mensaje original- De: Scott Hurring [mailto:[EMAIL PROTECTED]] Enviado el: Jueves, 06 de Junio de 2002 15:26 Para: '[EMAIL PROTECTED]' Asunto: RE: [PHP] Trying to list a directory content HELP PLEASE Instead of chdir() try putting the path directly into readdir(); it'll make the code a tiny bit cleaner. readdir("/home/casapu/paginas/images/carteleras"); ** and check return values! ** $fd = readdir(...) if (!$fd) die("Cannot readdir"); The code you have *should* work, but you'll never know why it's not working if you don't check return statuses --- Scott Hurring Systems Programmer EAC Corporation [EMAIL PROTECTED] Voice: 201-462-2149 Fax: 201-288-1515 > -Original Message- > From: Jason Wong [mailto:[EMAIL PROTECTED]] > Sent: Thursday, June 06, 2002 3:44 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Trying to list a directory content HELP PLEASE > > > On Friday 07 June 2002 00:47, webmaster mbtradingco wrote: > > I know my doubt is probable odd, but I would ask your help please. > > > > I need a user to be able to select an image from a directory, from a > > drop down box. For this I need to list all the images > available on the > > directory, hence, I have this code: > > > > > > > chdir("/home/casapu/paginas/images/carteleras"); > > $direc = opendir("."); > > while ($f = readdir($direc)); { > > print("".$f.""); > >} > > ?> > >."); > > > > but this is not working. I have reviewed the code against all the > > manuals/books I have, and it says it should work but it > doesn't. Anyone > > knows what I'm doing wrong? > > how doesn't it work? > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications > Development * > > /* > Fashions have done more harm than revolutions. > -- Victor Hugo > */ > > > -- > 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 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MySQL - Creating The Database
This is rather sad, the PHP mailing list is pretty good. Agreed, sometimes the answers are curt, that's because a lot of the questions have been asked a zillion times and can be found in the archives. And sometimes there's no response, perhaps the solution is not evident to those on the list. But I think there is such a thing as too much of a good thing. Very often the entire solution comes so readily through the list, that newbies tend to turn to the list for every little thing. It would help the newbie to do his/her research before turning to the list. And it would help in keeping the list healthy too. Try the CHM PHP4 manual, the site www.php.net and its partner sites. So, do a bit of research and when you can truly truly say that you give up, then the smart-asses are here to help you out. cheers. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Christopher Riordan Sent: Tuesday, June 04, 2002 6:51 AM To: PHP Mailing List Subject: Re: [PHP] MySQL - Creating The Database He'll Be Back, they all come back Chris - Original Message - From: "Jason Teagle" <[EMAIL PROTECTED]> To: "PHP Mailing List" <[EMAIL PROTECTED]> Sent: Tuesday, June 04, 2002 9:45 AM Subject: Re: [PHP] MySQL - Creating The Database > > - Original Message - > From: "David Freeman" <[EMAIL PROTECTED]> > To: "'Jason Teagle'" <[EMAIL PROTECTED]>; "'PHP Mailing List'" > <[EMAIL PROTECTED]> > Sent: Tuesday, June 04, 2002 1:58 PM > Subject: RE: [PHP] MySQL - Creating The Database > > How very sad. It's not new - I've seen things like this on many lists and > newsgroups. Apparently it is easier for people to be sarcastic and give a > flippant RTFM response than to actually help people. The only list I've ever > seen that actually treated newcomers with a bit of respect in most cases is > WinDev. > > Here's an example of what a good answer would have been: > > "MySQL databases aren't single files like other types. They're like > directories with files as tables. > PHP itself can create a database, take a look at mysql_connect(), > mysql_query() and the CREATE DATABASE SQL action." > > See? It gives the answer, involves no sarcasm or mockery, and above all, > actually HELPS the OP. > > But no... being a smart-ass is easier, right? > > The trouble with wise guys like these is that they assume: > > 1) That the OP has not bothered to try to find the answer. > We're not all geniuses, we can't all think laterally all the time, we can't > all come up with the right way of finding the answer. For the record, I > _did_ look online using Google and _did_ look around the PHP manual, but was > unlucky enough not to end up on the route that shows mysql_create_db(). My > misfortune. > > 2) That the OP already knows the answer. > Coming from a number of other programming languages where it is not possible > to create a database programmatically, it is natural to assume that the same > might be true of PHP. Had I known that PHP could create it from scratch, I > would not have needed to deal with this pathetic situation. But I didn't > know, so I stupidly thought that I might get some help from a list > pretending to help people trying to program in PHP. > > Obviously, I was wrong. Also my misfortune. > > Don't bother responding, I have left the list. Plenty of places where people > are actually willing to help. > > > _ _ > o oJason Teagle > < [EMAIL PROTECTED] > v > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
FW: [PHP] Logic -- conditional statements
One correction, Ricardo for appending the rows, you will have to change the condition //for 1st row if($valueChk >= 1 && $valueChk <= 3) //for 2nd row if($valueChk >= 2 && $valueChk <= 3) //for 3rd row if($valueChk == 3) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Naintara Jain Sent: Tuesday, June 04, 2002 2:37 PM To: Ricardo Fitzgerald; [EMAIL PROTECTED] Subject: RE: [PHP] Logic -- conditional statements The problem here is that you have defined three different variables $value1,$value2,$value3. Keep only one variable (say,$valueChk) that can take values 1,2 or 3. Then check for the condition. And there's another mistake in the script, you are checking ---if ($value2 ==0)--- twice, you probably mean to check for "$value1 ==1" (for the first of the "$value2 ==0" checks). Once you are through with these changes, your script will work perfectly. And if you feel like improving it you need not repeat the statements. You can merely append the additional rows depending on the value of the variable you set (say, $valueChk). the following isn't the actual script, but mainly the logic. $table="" if($valueChk==0) exit if($valueChk==1) { //.append the first statement to $table variable $table .= " "; } if($valueChk==2) { //.append the second statement to $table variable } if($valueChk==3) { //.append the third statement to $table variable } //now close the table tag and echo the $table variable you'll get the table with the desired number of rows. -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Ricardo Fitzgerald Sent: Friday, July 10, 2893 3:44 PM To: [EMAIL PROTECTED] Subject: [PHP] Logic -- conditional statements Hi to all, I'm trying to echo a neat table with values from a form, depending on the values it echoes a table with one row with two or with three: Then I have conditional nested statements, to validate these variables and wrote the table with the proper values in each case, the problem is the table is displayed 3 times instead of 1 each time it finds a value TRUE! I need it to display only once, I mean in the first instance the table, has 1 row, the second 2 rows, the third 3 rows, and they are independent. The code is something like: //Value1 is always 1 if ($value1 == 0) { exit } if ($value2 ==0) { echo // echoes the table . . ."$variable1 ... ."$variable2... ."$variable3 ... ."$variable4 ... } if($value2 == 0) { . . echo // echoes the table . . ."$variable1 ... ."$variable2... ."$variable3 ... ."$variable4 ... ." /next row . ."$variable5 ... ."$variable6... ."$variable7 ... ."$variable8 ... ." . . } if($value3 == 3) { . . echo // echoes the table . . ."$variable1 ... ."$variable2... ."$variable3 ... ."$variable4 ... ." /next row . ."$variable5 ... ."$variable6... ."$variable7 ... ."$variable8 ... ." . . ."$variable9 ... ."$variable10... ."$variable11 ... ."$variable12 ... ." . . //and then closes the php script, TIA Regards, Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Logic -- conditional statements
The problem here is that you have defined three different variables $value1,$value2,$value3. Keep only one variable (say,$valueChk) that can take values 1,2 or 3. Then check for the condition. And there's another mistake in the script, you are checking ---if ($value2 ==0)--- twice, you probably mean to check for "$value1 ==1" (for the first of the "$value2 ==0" checks). Once you are through with these changes, your script will work perfectly. And if you feel like improving it you need not repeat the statements. You can merely append the additional rows depending on the value of the variable you set (say, $valueChk). the following isn't the actual script, but mainly the logic. $table="" if($valueChk==0) exit if($valueChk==1) { //.append the first statement to $table variable $table .= " "; } if($valueChk==2) { //.append the second statement to $table variable } if($valueChk==3) { //.append the third statement to $table variable } //now close the table tag and echo the $table variable you'll get the table with the desired number of rows. -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Ricardo Fitzgerald Sent: Friday, July 10, 2893 3:44 PM To: [EMAIL PROTECTED] Subject: [PHP] Logic -- conditional statements Hi to all, I'm trying to echo a neat table with values from a form, depending on the values it echoes a table with one row with two or with three: Then I have conditional nested statements, to validate these variables and wrote the table with the proper values in each case, the problem is the table is displayed 3 times instead of 1 each time it finds a value TRUE! I need it to display only once, I mean in the first instance the table, has 1 row, the second 2 rows, the third 3 rows, and they are independent. The code is something like: //Value1 is always 1 if ($value1 == 0) { exit } if ($value2 ==0) { echo // echoes the table . . ."$variable1 ... ."$variable2... ."$variable3 ... ."$variable4 ... } if($value2 == 0) { . . echo // echoes the table . . ."$variable1 ... ."$variable2... ."$variable3 ... ."$variable4 ... ." /next row . ."$variable5 ... ."$variable6... ."$variable7 ... ."$variable8 ... ." . . } if($value3 == 3) { . . echo // echoes the table . . ."$variable1 ... ."$variable2... ."$variable3 ... ."$variable4 ... ." /next row . ."$variable5 ... ."$variable6... ."$variable7 ... ."$variable8 ... ." . . ."$variable9 ... ."$variable10... ."$variable11 ... ."$variable12 ... ." . . //and then closes the php script, TIA Regards, Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] delete file contents before writing?
If you really want to delete the file contents then open the file in write-only mode, like so: $open_file = fopen("$file_name","w"); -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Jas Sent: Monday, June 03, 2002 8:37 AM To: [EMAIL PROTECTED] Subject: [PHP] delete file contents before writing? Not sure how I could do this as I could not find a functions on php.net to allow me to first delete the entire contents of a file "before" writting the changes supplied by a textarea. Here is what I have thus far: Page one - Form: Page two - open file and write changes: As of right now it opens the file and writes your changes, however it simply goes to the end of the file then begins writting. I would like to delete the contents of the file, then write the changes. Any help or pointers are appreciated! Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another Header headed nowhere
Use JavaScript within PHP. If you want to open a new browser window, add the following to the script window.open('url','winname','window features');" ; ?> look up the 'open' method in JavaScript. - Original Message - From: "Hugh Danaher" <[EMAIL PROTECTED]> To: "Php-General" <[EMAIL PROTECTED]> Sent: Friday, October 05, 2001 1:30 PM Subject: [PHP] Another Header headed nowhere What I want to do is to open a new browser page after some data is entered in a form. I have a $php_self that enables $high_value and $low_value to become set and the code snip comes after the end of the form. From reading a help book and looking at the on-line manual, I think I need to send a header() command (this might not be true, if there is another way, I'll try it too).The following code snip is several lines below the top and it gives me the following error message: Warning: Cannot add header information - headers already sent by (output started at /www/serviceprovider/directory/page3.php:4) in /www/serviceprovider/directory/page3.php on line 364 code snip if (isset($high_value) and isset($low_value)) { header("location: http://www.serviceprovider.com/directory/page4.php";); / / this is line 364 exit; } Your help and advice on this will be greatly appreciated. Hugh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] popup window under php
You have the same requirement Put this wherever you want in your script. alert('Message!') "; } ?> - Original Message - From: "Eduardo Kokubo" <[EMAIL PROTECTED]> To: "Naintara Jain" <[EMAIL PROTECTED]> Sent: Thursday, October 04, 2001 4:56 PM Subject: Re: [PHP] something like alert (javascript) This is probably the best solution. I'll try something like this. Thanks. - Original Message - From: Naintara Jain <[EMAIL PROTECTED]> To: Eduardo Kokubo <[EMAIL PROTECTED]> Sent: Thursday, October 04, 2001 8:19 AM Subject: Re: [PHP] something like alert (javascript) > You could try: > if (files < 4) // whatever the condition > { > echo " >alert('Unfinished business!') "; > } > ?> > -Naintara > > - Original Message - > From: "Eduardo Kokubo" <[EMAIL PROTECTED]> > To: "Maxim Maletsky (PHPBeginner.com)" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Thursday, October 04, 2001 4:45 PM > Subject: Re: [PHP] something like alert (javascript) > > > I'm implementing a system that allows the users create pages on-line. They > can create several different pages to complete a site. What I want to do is > alert them that there are still pages to be created before they finish. I'm > trying to do it checking the files they create and alerting a message, but I > think javascript can not check the files and php can not alert the user with > a function like alert(). I'm using a simple print() (PHP) but alert() would > be much better. > > - Original Message - > From: Maxim Maletsky (PHPBeginner.com) <[EMAIL PROTECTED]> > To: 'Eduardo Kokubo' <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Wednesday, October 03, 2001 11:38 AM > Subject: RE: [PHP] something like alert (javascript) > > > > Then what do you need? > > > > We are not any sure on what your question is ... > > > > Maxim Maletsky > > www.PHPBeginner.com > > > > > > -Original Message- > > From: Eduardo Kokubo [mailto:[EMAIL PROTECTED]] > > Sent: mercoledì 3 ottobre 2001 16.31 > > To: [EMAIL PROTECTED] > > Cc: [EMAIL PROTECTED] > > Subject: [PHP] something like alert (javascript) > > > > > > Is there any function in PHP that is similar to alert() or confirm() of > > javascript ? I tried die() but that's not what I need. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > - Original Message - From: "Tim Sawyer" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 05, 2001 12:46 AM Subject: [PHP] popup window under php I want to open a popup window under php control. So lets say I have an if statement which if true opens the window. if ($something) { JavaScript:window.open("test.php",blah...); } Guess I'm saying that I want to call a Javascript function without the user clicking on anything. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Session and header() errrors
There are 2 things you are doing here: 1) Session start 2) page redirection put session_start() as the 1st line in your script. Echo commands in the included file causes such warnings: "Warning: Cannot send session cookie - headers already sent by (output started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9)" The first two warnings are on account of the above problem. The 3rd warning is becoz of the php.ini that Dimitris talks about. For the last warning, another simple mistake: <---echo "session_id: ".session_id()."";--> comment this line and then redirect the page. the header() function will cause errors if you have already written, sent output ('echoed', etc) to the current page. -Naintara - Original Message - From: "Dimitris Kossikidis" <[EMAIL PROTECTED]> To: "Web user" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, October 04, 2001 4:48 PM Subject: Re: [PHP] Session and header() errrors You should change sessions configuration in php.ini The default value for sessions dir /tmp. In windows shoud point to c:\tmp The header error occurs because you get a warning about session. - Original Message - From: "Web user" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 04, 2001 11:51 AM Subject: [PHP] Session and header() errrors > Why do the errors occur while running the scripts below? It seems that the > errors occured at the part of session and header(). Please give me some > advice! > Thank you! > > Mike > > System: PHP4.06 + Apache 1.3.20 Win32 + Win98 (the session configurations > are default in php.ini) > > when the 1.php is running, the IE shows errors info as below : > - > Warning: Cannot send session cookie - headers already sent by (output > started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9) > in c:\program files\apache group\apache\htdocs\web1\1.php on line 3 > > Warning: Cannot send session cache limiter - headers already sent (output > started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9) > in c:\program files\apache group\apache\htdocs\web1\1.php on line 3 > > Warning: open(/tmp\sess_96ae897bcb501486860552d2df862863, O_RDWR) failed: m > (2) in c:\program files\apache group\apache\htdocs\web1\1.php on line 3 > session_id: 96ae897bcb501486860552d2df862863 > > > Warning: Cannot add header information - headers already sent by (output > started at c:\program files\apache group\apache\htdocs\web1\html-head.inc:9) > in c:\program files\apache group\apache\htdocs\web1\1.php on line 9 > > - > The scripts of 1.php: (1.php and 2.php are under the same base directory) > require("html-head.inc"); > session_start(); > $name="user"; > session_register("name"); > echo "session_id: ".session_id().""; > sleep(10); > header("Location: 2.php"); > require("html-foot.inc"); > ?> > > - > The scripts of html-head.inc: > > > > page title > > > > - > The scripts of html-foot.inc: > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php in css not working with IF's
Maybe you can try simplifying your logic. Why don't you avoid nested IFs till later, and keep to simple IFs. If you want to check for $site_style not equal to 10 and also not equal to 9 then you can say ($site_style != 10 && $site_style != 9) or even !($site_style == 10 || $site_style == 9) then later if you want to check for $site_style == 10 make a separate IF rather than use a elsif, just for ease of comprehension. -Naintara - Original Message - From: "Jason Dulberg" <[EMAIL PROTECTED]> To: "Rasmus Lerdorf" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, October 04, 2001 11:12 AM Subject: RE: [PHP] php in css not working with IF's Thanks for sticking with me here and for your examples!! So basically, I need to use AND instead of OR. if (($site_style!=="10") && ($site_style!=="9") && ($site_style!=="8")) { } elseif ($site_style=="10") { } hrm... it didn't work. Sorry for being such a dope about this :( Jason > Ok, you are clearly not following along here... ;) > > You have (let $site_style = A for brevity): > > if( A!=10 OR A!=9 OR A!=8 ) > > When A=10 this becomes: > > if( 10!=10 OR 10!=9 OR 10!=8 ) > falsetrue true > > if( false OR true OR true ) is the same as if (true) > > Seriously, try drawing the Venn diagram for your expression. > > Or try substituting common english. > > if Jason is not 21 or Jason is not 20 or Jason is no 19 let him into the > cool club. > > Say Jason is 21, is he allowed in? Sure he is, because one of the > conditions for getting into the cool club is that Jason is not 20. It > doesn't matter that one of the other conditions says to not let Jason in. > If the people writing the rules wanted to force all the conditions to > apply they would have written: > > if Jason is not 21 AND Jason is not 20 AND Jason is not 19, let him into > the cool club. > > -Rasmus > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] array_search in 2-D array
I have a 2D array wherein each row is an associative array (which has keys that are column names of a certain MySQL table) the array name is "sess_arrayPhotos". I need to match PhotoId (2nd dimension key) for every row (numeric index) of the 2D array. I tried-- $keyPos=array_search($searchedforId,$sess_arrayPhotos); --but that didn't work. Right now, I am achieving it by: $sess_arrind=0; while(($sess_arrayPhotos[$sess_arrind]["PhotoId"] <> $photo) && ($sess_arrind < sizeof($sess_arrayPhotos))) { next($sess_arrayPhotos); $sess_arrind=$sess_arrind+1; } $keyPos=$sess_arrind; I would like to know if there is a way of doing this using array_search(). -in anticipation -Naintara -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] mysql_fetch_array() doesn't work
Hi Mike, The query $query="selct count(*) from users where sign=1"; should be "select" not "selct" -and in future to know if there is any error in your queries you might want to check this way: if(mysql_query($query) { --do statements-- } else -error msg- or even the following would be a convenient way to get your recordset and check for invalid query. just try this $result = mysql_query ("SELECT my_col FROM my_tbl") or die ("Invalid query"); IN YOUR CASE try: $res=mysql_query($query) or die ("Invalid query"); and let me know if you still have a problem. -Naintara - Original Message - From: "Web user" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 27, 2001 10:18 AM Subject: [PHP] mysql_fetch_array() doesn't work System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: "Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\web\site1\list.php on line --[the number of line]" What's the problem wiht mysql_fetch_array() or other? What does the T_STRING' or `T_VARIABLE' or `T_NUM_STRING' mean? THANKS Mike The full code below: User Added timeStatus"; $num=mysql_num_rows($res); for($i=0; $i<$num; $i++) { $arr=mysql_fetch_array($res); /* HERE is line where the error occurs!!! */ echo " $arr['user_name']>"; echo "$arr['time']"; echo "$arr['status']"; echo "$arr['comment']"; } echo ""; echo ""; /* show others in multi-pages */ for($i=0; $i<$pages; $i++){ echo " echo ($i+1).""; echo " "; } echo ""; ?> - create table users ( user_id int not null auto_increment primary key, user_name varchar(30), time datetime, status tinyint(1), comment text, sign tinyint(1) default '1' ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]