Re: [PHP] Loop, array, life....
You only want to retrieve the news from your table once. So, pull pull this code: $container[] = $message; while (list($news, $date) = mysql_fetch_row($newsfetch)) { $container[] = 'a href='newslink.php'' . $news . '/a'; $container[] = 'brhrbr'; } $container[] = '/body/html'; outside of (before) this loop: while ($data = mysql_fetch_row($emailfetch)) { ~Chris /\ \ / Microsoft Security Specialist: X The moron in Oxymoron. / \ http://www.thebackrow.net On Wed, 3 Apr 2002, Gerard Samuel wrote: Ok, this one is breaking my back all day. First some sudo-code - fuction email_to_user() { $sql = 'select distinct(email) from user'; $emailfetch = mysql_query($sql); $sql = 'select news, date from news order by sid desc limit 10'; $newsfetch = mysql_query($sql); while ($data = mysql_fetch_row($emailfetch)) { $container = array(); $container[] = 'htmlheadtitle/headbody'; $message = 'Have a nice day'; $container[] = $message; // PROBLEM IN THIS WHILE LOOP MAYBE // while (list($news, $date) = mysql_fetch_row($newsfetch)) { $container[] = 'a href='newslink.php'' . $news . '/a'; $container[] = 'brhrbr'; } $container[] = '/body/html'; $message = ''; foreach($container as $foo) { $message .= $foo; } mail(Send mail to $data[0]); unset($container); } } Basically it grabs all the user's email addresses, then loop them. On each loop grab all news items. Then emails results to the user and moves on to the next user. Im running this on my test box, that only has two users, but the 2nd user never gets the expected results. The first user get the message and the news. The second only gets the message. The code structure is pretty much unchanged from a working example till I started using $container to hold array elements. Could anyone see bad logic in the above code?? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular Expression Challenge
You won't be able to do that with a regexp alone. Recursively matching isn't possible. You'll need a little help from some additional code. ?php $string = wed-thurs 9:35, 14:56, 18:35; // YOUR STRING $regexp = ^([a-z]+)-([a-z]+)[\ ]+(.*)$; // GETS (day)-(day) (any/all times) $find = ereg( $regexp, $string, $matches ); $times = explode( ,, $matches[3] ); // BREAK APART (.*) print( $matches[1] . br\n . $matches[2] . br\n ); while( list( $key, $val ) = each( $times ) ){ print( trim( ${val} ) . br\n ); } ? That seems to do the trick. Hopefully that gets ya closer to where you want to go. If you really needed to regexp match on the times, you can do that within the while loop. g.luck, ~Chris /\ \ / Microsoft Security Specialist: X The moron in Oxymoron. / \ http://www.thebackrow.net On Mon, 25 Mar 2002, Cameron Just wrote: Hi, I am trying to pull out the following information via a regular expression. The string I am searching on is 'wed-thurs 9:35, 14:56, 18:35' and I want it to retreive wed thurs 9:35 14:56 18:35 The regular expression I am using is ([a-z]+)-([a-z]+) +([0-9]{1,2}:?[0-9]{0,2})[, ]* It seems to be grabbing the wed thurs 9:35 but I can't seem to retrieve the rest of the times. Anyone have any ideas? BTW There can be any number of 'times' in the string and also the 'times' can be with or without the colon and the minutes, hence the '}:?[0-9]{0,2}' part of the regexp. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retaining data across multiple sites
On Wed, 20 Feb 2002, Ben Sinclair wrote: I want to retain some data across my sites, which have different domain names. I can't use cookies because they rely on the domain name, and I'd rather not One way I handle this ... it's a work-around, so it's not all that pretty: In the doc root on all the domains, I keep a script which just prints out the cookie names values for any cookies accessible by the domain ... as JavaScript variables. Then that script can be used as the src in a script on any of your other domains. BINGO ... you've got cookies! Want milk? On domain_A, have this script (let's call it A_cookies.php): while( list( $key, $val ) = each( $HTTP_COOKIE_VARS ) ){ print( var $key = \$val\;\n ); } On domain_B, in an HTML document, use some JavaScript: script src=http://domain_A/A_cookies.php;/script The pitfalls: - not useful with users whom have JavaScript or cookies disabled - now you have to do all cookie data handling on the client side - this is a third-party activity[1] which more secure-minded people and browsers will disallow. (IE6, as a P3P-enabled user agent, is a prime example.) I only do this for data which makes the user experience better between two sites. It's one of those bells and whistles kind of deals. When it doesn't work as desired, the sites still function properly. If I were to try this to track data on a particular user between sites, I'd store only a session ID in a cookie (a la PHP sessions), use the above method to get the session ID data into a javascript variable and source it across sites, then use custom session handlers to put session data into a single database, with the data associated to the session ID. The same pitfalls apply ... so you'd lose track of some visitors when they switch sites. I don't consider this a big deal, because this is just how the Internet is evolving. g.luck ~Chris [1] Having a file from domain_B referenced from within a document on domain_A renders the file from domain_B a third-party document. There are inititives to control third-party cookie reading/writing, like banner ads, and they affect this method of cookie reading too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retaining data across multiple sites
On Wed, 20 Feb 2002, Ben Sinclair wrote: These are all workable solutions, but I also have to worry about https sites. I called it a work-around rather than a solution on purpose :) The only real solution is to collapse the different sites into one domain. If I link to hidden images on non-secure servers, the browser will display a warning. I'm also trying to avoid buying multiple certificates when all I want to do is brand a site. There's another pitfall. More users want better privacy and security ... they'll get it, some day. Like I said before, this is just how the Internet is evolving. As you're doing, the functionality being provided has to be judged against the practicality of its implementation. g.luck, ~Chris - Original Message - From: Christopher William Wesley [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Ben Sinclair [EMAIL PROTECTED] Sent: Wednesday, February 20, 2002 11:27 AM Subject: Re: [PHP] Retaining data across multiple sites On Wed, 20 Feb 2002, Ben Sinclair wrote: I want to retain some data across my sites, which have different domain names. I can't use cookies because they rely on the domain name, and I'd rather not One way I handle this ... it's a work-around, so it's not all that pretty: In the doc root on all the domains, I keep a script which just prints out the cookie names values for any cookies accessible by the domain ... as -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explode? (table field to a variable of same name)
This may not be what you want to do, but should give you some hints. (This is my code which I use to simply dump any SQL table into an HTML table I can view in a browser ... for small tables, of course.) Using MySQL as an example: // assuming you ran a query and stored results in $mysql_result_set // Get the number of fields to work with $num_fields = mysql_num_fields( $mysql_result_set ); // http://www.php.net/manual/en/function.mysql-num-fields.php // Print out a row of column headers print( tr ); for( $i = 0; $i $num_fields; $i++ ){ $fieldName = mysql_fetch_field( $mysql_result_set, $i ); // http://www.php.net/manual/en/function.mysql-fetch-field.php print( td . $fieldName-name . /td ); } print( /tr ); // Print out the data from the result records while( $record = mysql_fetch_row( $mysql_result_set ) ){ // http://www.php.net/manual/en/function.mysql-fetch-row.php print( tr ); foreach( $record as $field ){ ${$field} = $field; // The above is unnecessary, but answers your question. // It assigns a variable, named after a table column, //the value of that column (in this record). print( td${field}/td ); } print( tr ); } Hope that gives you something to work with. g.luck, ~Chris On Tue, 19 Feb 2002, Baloo :0) wrote: How can I assign automatically all fields of a database to a variable of the same name? Instead of having to manually do $user_id=$row[user_id]; etc Then how could I know the number of fields in the table so I can do a loop to print them all in html? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explode? (table field to a variable of same name)
oi ... typo! see below. sorry :( ~Chris On Tue, 19 Feb 2002, Christopher William Wesley wrote: This may not be what you want to do, but should give you some hints. (This is my code which I use to simply dump any SQL table into an HTML table I can view in a browser ... for small tables, of course.) Using MySQL as an example: // assuming you ran a query and stored results in $mysql_result_set // Get the number of fields to work with $num_fields = mysql_num_fields( $mysql_result_set ); // http://www.php.net/manual/en/function.mysql-num-fields.php // Print out a row of column headers print( tr ); for( $i = 0; $i $num_fields; $i++ ){ $fieldName = mysql_fetch_field( $mysql_result_set, $i ); // http://www.php.net/manual/en/function.mysql-fetch-field.php print( td . $fieldName-name . /td ); } print( /tr ); // Print out the data from the result records while( $record = mysql_fetch_row( $mysql_result_set ) ){ // http://www.php.net/manual/en/function.mysql-fetch-row.php print( tr ); I screwed it up here ... this foreach() loop should be as follows foreach( $record as $fieldName=$field ){ ${$fieldName} = $field; // The above is unnecessary, but answers your question. // It assigns a variable, named after a table column, //the value of that column (in this record). print( td${field}/td ); } print( tr ); } Again ... sorry about that. Oi ... and I see that someone else, wrote that bit of code correctly to the list just now :) (thx, Rasmus). Hope that gives you something to work with. g.luck, ~Chris On Tue, 19 Feb 2002, Baloo :0) wrote: How can I assign automatically all fields of a database to a variable of the same name? Instead of having to manually do $user_id=$row[user_id]; etc Then how could I know the number of fields in the table so I can do a loop to print them all in html? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Anyway to open a PHP file and view its code in the browser?
Create a script to which you can pass a file namem and calls show_source() on the file name. http://www.php.net/manual/en/function.show-source.php Be very careful to check the input, such that the file name parameter which eventually gets passed to show_source() cannot be one which you do not want to be displayed to everyone in the world. When using the function to show off living code, I make sure the only files that can be viewed are files in specific directories. I also make sure the file exists in the file system ... displaying an appropriate messages when the file will not be diplayed. g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Thu, 14 Feb 2002, Kevin Stone wrote: How can I open a local PHP script and view its code to the browser? The Readfile() method appears to parse and execute the code. The Fopen() method appears to parse and then not execute the code, leaving a blank screen, or at the very least displaying any non-PHP text existing in the script. This is obviously rare question because I can't find any references on this list or on Usenet. Is there a trick to this? Or is it simply not possible. Much Thanks, Kevin Stone [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filling Forms with $variables
On Wed, 13 Feb 2002, Steven Walker wrote: ?$name = Steven Walker? form name=form1 method=post action=infocollect.php input type=text name=name value=?echo $name;? /form In the browser, the name field is only filled with Steven, and drops off everything after the space. If I echo $name outside of the form it You need to put quotes around the value. value=?echo $name;?? g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fooling the client into thinking php script is .jpg
On Mon, 11 Feb 2002, Matt Moreton wrote: I have a script that outputs an image. Using the gd library. But the ... the image. Is it possible somehow to request the file as a .jpg? www.host.com/displayimage.php Assuming you're using Apache, you can use a rewrite rule (with mod_rewrite). http://httpd.apache.org/docs/mod/mod_rewrite.html Turn the rewrite engine on, then specify a rewrite rule which tells apache to execute your script when a certain file is requested. Using the file names you specified, add this to your httpd.conf (or your .htaccess): RewriteEngine on RewriteRule ^/displayimage.jpg$ /displayimage.php [L] You can then just use /displayimage.jpg as an image src, then when a visitor's browser requests it, apache will execute return /displayimage.php instead, and the visitor will never know. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with mt_rand()
On Thu, 31 Jan 2002, Benjamin deRuyter wrote: I need to generate a random number (range is not crucial) and I have been trying to use mt_rand(). However, I am finding that is generates the same value EVERY time. This is true whether I supple a range or not. For example, the follow line of code generated 13 EVERY time... 27-Mar-2001 07:29 Don't forget to do mt_srand() before the mtrand() or you wil get the same values every time you'll go back to the same page.Not when you refresh the page, only when you open the page in a new browserwindow and the history is empty. http://www.php.net/manual/en/function.mt-rand.php ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] suppressing division by zero errors
You really need to do some error checking on the denominator. $num = 5; $den = 0; echo $den != 0 ? $num/$den : 0; A number divided by zero isn't defined, so you have to circumvent the situation by making sure it never happens. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Fri, 1 Feb 2002, Martin Towell wrote: Is there a way to suppress division by zero errors? echo 5/0; // this give a warning - obviously!! @echo 5/0; // this gives a parse error echo @5/0; // this still comes up with a warning unless I turn error_reporting off before and turn it back on afterwards, but I don't want to do that unless I REALLY have to Martin -- 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] URL Parsing Help
$myPairs = explode( /, $PATH_INFO ); while( list( $key, $val ) = each( $myPairs ) ){ if( !empty( $val ) ){ $myVar = explode( =, $val ); ${$myVar[0]} = $myVar[1]; } } For you example URI, index.php/option=contact/step=view you would then have $option and $step available, with the assigned values of contact and view, respectively. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Tue, 29 Jan 2002, Shane Lambert wrote: I am trying to write software that will allow me to pass variables to a php script like: index.php/option=contact/step=view When I do this, I get the varibal PATH_INFO which contains /option=contact/step=view. Now, what I want is to have the following: $option = contact $step = view I tried using '$array = explode(/,$PATH_INFO);' which gives me the array: $array[1] = option=contact $array[2] = step=view This of course is not what I want. I want: $array[option] = contact $array[step] = view So that when I use the extract($array) command I get the variables: $option = contact $step = view Like I want. If you aren't lost and you know the answer, PLEASE HELP! -- 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] RTFM
On Sat, 19 Jan 2002, Shane Wright wrote: Maybe this list should be split - kindof into a php-newbies and a php-advanced ? So all the newbies can help all the newbies, and all the advanced people can help the advanced people? That wouldn't work out. All the newbies would subscribe to the advanced list, and advanced users who like helping newbies would subscribe to the newbies list. And we'd have two of the same list. I don't see a problem with this list. The person who started this thread, after being on the list for only a week, made a very uninformed decision to say something so devoid of value or thought that it makes less sense than when a newbie asks a question without checking the manual first. After being on the list for a year, and following the newsgroup for a year prior to subscribing to the list, I've noticed very few people asking questions that are answered in the manual more than once ... repeat offenders if you will. And there are even fewer people who are dumb enough to make an issue out of it. This list is actually quite friendly to newbies, and is a primary reason why I stay on subscribed. I like helping new php developers (in terms of using php), and I like that that there are good number of people who like helping new php developers in a very friendly manner. I suspect that those are the same reasons why new php users subscribe to the list or follow the news group for a while. On Fri, 18 Jan 2002, Nick Wilson wrote: just a very quick note: I've been following the list for about a week and I probably follow one or two threads a day. Some of the stuff here is *very* interesting. Unfortunately most of the stuff posted is a little ridiculous in that it's posted by people that clearly don't know where the online manual is located. If you notice someone asking a question that has been asnwered in the manual, and you're going to spend the time writing to the list, you might as well be as helpful as possible. Answer a question, politely note that the manual is a great first-source for anwers, and provide a link into the manual where the person can find that you're telling the truth. Everyone has a lapse in judgement or knowledge at some point, and if that annoys you, note that it annoys us to hear that it annoys you. People are more receptive to someone who treats them with respect than to people who preach down from a self-built soap box. I'm not your mom, nor a list moderator ... so take the above as advice that will help you not look like more of a fool than those whom you think are foolish. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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 Security - view source code
On Thu, 17 Jan 2002, [EMAIL PROTECTED] wrote: I've seen a number of sites for example that didn't have the .inc extension registered, include() doesn't care about that, but if your includes are under the document root of your website (that happens a lot too, i don't know why ?) and you specify the exact name of the include in your browser (or worse, the directory is browsable from the web), the webserver will default to text/plain content and display the source. Bad thing since includes usually contain passwords and stuff. It also doesn't make a difference to PHP if your include files are in the web server's document root, or not. If you have important information in your include files, you'll be better off placing them in a directory which is not in your web server's document root. The web server will still need to access them, so you'll probably have to leave the permissions on the directory/files such that any users on the local system can read them (just like docs in the web root ... this is not a change), but at least the whole world isn't one HTTP request away from obtaining your important information. If you are the server's admin, or know the person well, you can tighten the file permissions down more with a little administrative work ... adding a new group of which your user and the web server are a member, and only permitting access to your files to that group and yourself. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Another question - not exactly what i was looking for
$where_conditions = array(); if( !empty( $lastname ) ){ $where_conditions[] = lastname like '%${lastname}%'; } if( !empty( $firstname ) ){ $where_conditions[] = firstname like '%${firstname}%'; } if( !empty( $age ) ){ $where_conditions[] = age = ${age}; } if( !empty( $weight ) ){ $where_conditions[] = weight = ${lastname}; } $where_clause = ; $num_conditions = sizeof( $where_conditions ); if( $num_conditions 0 ){ $where_clause = where ; for( $c = 0; $c $num_conditions; $c++ ){ $where_clause .= $where_conditions[$c]; if( $c $num_conditions - 1 ){ $where_clause .= ; } } } $query = select * from table ${where_clause}; ... that should be flexible enough for you to add new fields to check, by only having to add column = $value values to the $where_conditions array. g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Tue, 15 Jan 2002, Phil Schwarzmann wrote: Yo, thanks for all your help. But it isn't exactly what im looking for. Let's say you had a database with the following four columns... -LastName -FirstName -Age -Weight ...and you wanted a page that would allow a user to search for one or more of these fields within the database. It would be easy if the user could only pick just one of the fields. But let's say that want to search only lastname and firstname, or maybe all four, or maybe just one. How could this be done? If I have code that looks like this... $query = select * from table where lastname='$lastname' and firstname='$firstname' and age='$age' and weight='$weight'; $result = mysql_query ($query); $num_results = mysql_num_rows($result); ...the $num_results is ALWAYS zero unless I typed in all four fields. Any help? Thanks! -- 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 timesheets?
On Mon, 7 Jan 2002, Christian Calloway wrote: Are there any PHP coded timesheet type web application? And if so, what would we be suggested. Thanks, Take a look at these: http://freshmeat.net/search/?site=Freshmeatq=timesheet+phpsection=projects ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] An idea for a PHP tool
On Fri, 4 Jan 2002, Jason Murray wrote: I've seen bookmarks that pop up a javascript input window and then use the input in the resulting URL. So, take the manual query via javascript input and then append it to the www.php.net url. There are tips on the php site for making the quick-reference bookmarks, and other widgets, here - http://www.php.net/tips.php ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Logo proposal
I think an animal mascot is a beat idea. Needlenose pliers. Enough said! ;) ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Objects and sessions
On Mon, 26 Nov 2001, Greg Sidelinger wrote: Can someone tell me how to store a class in a session var. I want to There are several things you need to do. 1) include the class definition before you do anything 2) start the session shortly thereafter 3) register a session variable 4) create your object 5) serialize your object 6) store the serialized object (now a string) in your registered session variable Then to use the object again, you just have to 7) start the session back up 8) get the serialized value of your object from the registered session variable 9) unserialize the string value back into an object Wanna see how this works? I have a trivial example below, which involves 3 files. - chair.class is my class definition. - chair1.php sets up the session, creates the object, serializes and stores it in a registered session variable. - chair2.php gets the session variable's value, unserializes it, and uses the object again. -- chair.class ?php class chair{ // DATA MEMBERS var $num_legs; var $num_arms; // CONSTRUCTOR function chair( $legs = 3, $arms = 0 ){ $this-num_legs = $legs; $this-num_arms = $arms; } // SETTERS function setLegs( $legs ){ $this-num_legs = $legs; return true; } function setArms( $arms ){ $this-num_arms = $arms; return true; } // GETTERS function getLegs( ){ return $this-num_legs; } function getArms( ){ return $this-num_arms; } } ? -- chair1.php ?php include( chair.class ); session_start(); $myChair = new chair( 5, 3 ); print( My chair has . $myChair-getLegs() . legs, and . $myChair-getArms() . arms. ); $serChair = serialize( $myChair ); session_register( aChair ); $aChair = $serChair; ? -- chair2.php ?php include( chair.class ); session_start(); $myChair = unserialize( $aChair ); print( My chair has . $myChair-getLegs() . legs, and . $myChair-getArms() . arms. ); ? g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Segmented Code/HTML VS. ECHO??
I _hate_ echo'n out big batches of HTML, so I never do it. I prefer to include HTML, or have a class or function write HTML. However, printing in heredoc style is very handy ... more so than sliced bread. For example: ?php $color = #FFCC00; $name = Yogi; print EOF font color=${color}The bear is ${name}./font !-- this can be as much plain HTML intermixed with PHP variables as you like -- EOF; print( date() ); ? PHP code, followed by plain HTML (I put in some PHP variables, but they aren't necessary) (without a bunch of echo/print calls, or having to escape quotes), followed by more PHP ... wash, rinse, repeat as much as necessary ... you get the picture. It works out rather nicely. $0.02 ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Sun, 18 Nov 2001, Brad Melendy wrote: Hello, Other than the fact that sometimes, you just can't get raw HTML to process properly by dropping out of PHP code, what are the pros and cons of using RAW HTML or just ECHOING everything in PHP? Thanks for any insights. ..Brad -- 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] relative paths
On Sat, 17 Nov 2001, Mitja Pagon wrote: I want to know if there is a way to include(require) a file using a path relative to web server root. I think you'll find the $DOCUMENT_ROOT environment variable handy :) ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers -- 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] Question on variable variables
On Fri, 16 Nov 2001, Jeff Lewis wrote: What I need to do, however, is append a variable portion to a constant prefix. So I have a set of variables that are named $MYdog, $MYcat etc. and I need to do $a = dog ${MY$a} being the same as $MYdog Can this be done, and if so - how? I can't get it to work. So what you want is a base name with a vaiably-changing portion concatenated? Gotcha! // you variable base name $myVarBase = MY; $a = cat; $something1 = This Var Likes Cats; $b = dog; $something2 = This Var Likes Dogs; $myVarName1 = $myVarBase . $a; $myVarName2 = $myVarBase . $b; // The same as $Mycat = This Var Likes Cats; ${$myVarName1} = $something1; // The same as $Mydog = This Var Likes Dogs; ${$myVarName2} = $something2; g.luck ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Question on variable variables
You sure can. You can use variable variables wherever you can use regular variables. They're really no different than regular variables, except you have to keep track of what the variable will be named while coding :) ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Fri, 16 Nov 2001, Jeff Lewis wrote: Yes trying to get this to work: $curline = preg_replace(/yabb\s+(\w+)/,$$1,$curline); So for the current line I am looking for something like yabb copyright I want to replace that with the contents of $copyright. Can variable variables be used in regular expressions? Jeff - Original Message - From: Christopher William Wesley [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Jeff Lewis [EMAIL PROTECTED] Sent: Friday, November 16, 2001 10:38 PM Subject: Re: [PHP] Question on variable variables On Fri, 16 Nov 2001, Jeff Lewis wrote: What I need to do, however, is append a variable portion to a constant prefix. So I have a set of variables that are named $MYdog, $MYcat etc. and I need to do $a = dog ${MY$a} being the same as $MYdog Can this be done, and if so - how? I can't get it to work. So what you want is a base name with a vaiably-changing portion concatenated? Gotcha! // you variable base name $myVarBase = MY; $a = cat; $something1 = This Var Likes Cats; $b = dog; $something2 = This Var Likes Dogs; $myVarName1 = $myVarBase . $a; $myVarName2 = $myVarBase . $b; // The same as $Mycat = This Var Likes Cats; ${$myVarName1} = $something1; // The same as $Mydog = This Var Likes Dogs; ${$myVarName2} = $something2; g.luck ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Cookies, Sessions and Login Proceess
Just do your authentication before you send any HTML (including any whitespace). I actually recommend not sending ANY HTML from your authentication script. Authenticate them, set your cookie, and redirect the visitor to an appropriate next page, based on whether or not they've successfully authenticated. BTW - storing the username/password in the cookie makes no sense They've already authenticated ... just store a user-is-logged-in cookie which expires after X minutes/hours/etc. It's a good practice for when you'll have to deal with privacy security concerns. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Mon, 12 Nov 2001, Joe Van Meer wrote: Hi there, I'm new to php coming from an asp background and would like to know the easiest way to automate a login process. I have one page called 'index.php' and it contains a form with 2 elements, username and password. This page is posted to th 'login.php' and here I do a check against the database to see if the person is who they say they are. This where I came across a problem...I would like to set a cookie on the user's machine once I know they are who they say they are. So I attempted to create a cookie to hold their username and password upon successful login..I received the following error...Warning: Cannot add header information - headers already sent by (output started at E:\ez\codesnipits\login.php:16) in E:\ez\codesnipits\login.php on line 66. So I looked up in the manual and found that I can't do it this way. I can't send header info after the header has been sent for obvious reasons. So how the heck do I manage to do this? What I would to do is have the user login once, and each subsequent time they visit , skip the login process via their username and password in the cookie. Any insight to this type of process would greatly be appreciated. Thx Joe p.s Sorry about the bold font ;) -- 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] Cookies, Sessions and Login Proceess
On Mon, 12 Nov 2001, Joe Van Meer wrote: Thx Christopher for replying. Ok, let me see if I understand you correctly... The user enters username and password on index.php, this is posted to login.php. On login.php after I verify the user is who he/she says they are I set a cookie called accessedbefore to yes and redirect them to the Exactly. main page. Am I allowed to set a cookie and redirect them after determining who the user is? How would I redirect them after setting the cookie? Header You can set a cookie any time before any standard output is sent to the browser (and before you send a new Location header). Your login.php can look something like this (with pseudo-ish code) ... ?php $input_ok = validate_user_input( $username, $password ); if( $input_ok ){ $user_ok = authenticate_user( $username, $password ); if( $user_ok ){ setcookie( myuser, ok, time()+7200, / ); header( Location: congratulations.html ); } else { header( Location: go_away.html ); } } else { header( Location: go_away.html ); } ? ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Getting uploaded filename directory
If the path doesn't ride along in the _name variable (and I don't know of a case when it would), Nope. The value of the input element when the type = file isn't useable, except as an initial file name, so using JavaScript won't be helpful. I think the input element is implemented for type = file that way on purpose. Providing user/visitor filesystem information is a privacy/security risk. Your last chance to get the path info would be to ask the user to explicitly put it into a text form field ;) ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Mon, 12 Nov 2001, Boget, Chris wrote: In setting up a form to allow a user to upload a file, upon submission of that form, you can get the actual file name that is being uploaded by accessing the variable: $userfile_name (assuming the form element's name where the user specifies the file is $userfile). Is there a way to get the full path as well? ie: c:\program files\this directory\uploaded_file.txt ? I tried echoing out $userfile to no avail. I also tried some javascript that when the form was submitted, the value for the userfile element was copied to a hidden form element, but that didn't work either. Any ideas? Suggestions? Chris -- 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] some questions on sessions (long)...
Your problem probably is including the miec.php from the .shtml document. Does the .shtml document send any output to the browser before including your .php script? If so, you're not going to be able to send any cookies from the .php script. Once any standard output makes it to the browser (including any leading whitespace), no more headers can be sent to the browser. PHP sends cookies to the browser as header data. Hence, if your .shtml document has any output before your .php document is included, your session cookie cannot be sent. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Mon, 12 Nov 2001, Christian Dechery wrote: I've recently had a problem with sessions, and came up with a problem that apparently has no solution... I want to understand why EXACTLY it does't work... From what I understand about sessions (reading PHP Docs), cookies are default and URLs holding the session_id are used if the cookies can be used to get the current session_id right? So if, there's a cookie indicating a session, PHP will detect it and the session will work beatifully.. If when a session is created, a cookie cannot be set, then the URLs come into play.. right? -- I'm I right so far? -- So, I can only presume, that whenever I can see those URLs with session_ids, this means that no cookie was created... and if one of those URLs is clicked, the session will persist, since the URL is carrying the session_id. Well, now to the problem with no solution... I've described it here on the list a couple of times... sorry if this is getting too annoying. 1 - I have a PHP script, that uses sessions, it's called miec.php miec.php uses both cookies and sessions... the cookie holds the user_id and the session holds an array of every product the user has seen, so they won't repeat... of course, the session only gets initialized if the cookie with the user id is found... if not, a login form is shown... 2 - I have a html file, demo.shtml, which with SSI includes miec.php The inclusion works fine, even the cookie with the user id gets detected and the username is shown as expected Now, the problem. If I run miec.php solo on the browser, everything works perfectly. But if I call demo.shtml, something goes wrong, and I want to know what. When demo.shtml is called, the cookie works (the user id is detected) and the session gets started. I can see the URLs with the session id AND the session file in my webserver. The problem is that, the session doesn't persist, each time I reload demo.sthml, a new session is created. Now get this... if I call miec.php and then demo.shtml, everything works. Why? My guess is, miec.php running solo is able to create the cookie with the session id, while when SSI included it can't, which explain the URLs. Obviously, URLs (example: demo.shtml?sID=3897348734) aren't helpful here, since it's a html file, and it can't parse the query string to send the variable to an SSI included php file. But why the cookie can't be created? Headers aren't the problem... if a session can be created and the session vars registered it's because the headers have not been sent, so why can't a cookie be created in this conditions. Does anyone has a clue?? p.s: the problem is solved, I force the user to login in case of miec.php is SSI included, which works, since the session is created elsewhere (login.php). _ . Christian Dechery . . Gaita-L Owner / Web Developer . . http://www.webstyle.com.br . . http://www.tanamesa.com.br -- 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] Question....
try not setting the domain. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Tue, 13 Nov 2001, Chris Kay wrote: I have a simple question that bugging me.. I have a site which I am designing with users auth, I have decided to use cookies as I need to store variables after the user leave the site.. Problem I am having is the domain I set it on, If the user logs into http://www.mysite.com and later logs into http://mysite.com without the www the cookie will not work.. Is this because I am setting the domain wrong? I have tried .mysite.com mysite.com $HTTP_HOST Is some1 able to point me in the right direction -- 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] for loop problem?
I just ran your code as you pasted earlier, and set up a mysql database with the table defined below ... and it inserted 223,110 passcodes into the table. PHP 4.0.99-3 (Identifies itself as 4.1.0RC1) MySQL 3.23.43-3 ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Mon, 12 Nov 2001, Tyler Longren wrote: Hi John, MySQL Version: MySQL 3.23.44-nt SQL: CREATE TABLE passcodes ( id int(11) NOT NULL auto_increment, passcode varchar(255) NOT NULL default '', PRIMARY KEY (id), KEY id (id,passcode) ) TYPE=MyISAM; I'm beginning to think it's a MySQL problem also because this PHP SHOULD work. Tyler - Original Message - From: John Steele [EMAIL PROTECTED] To: PHP General List [EMAIL PROTECTED] Sent: Monday, November 12, 2001 3:33 PM Subject: Re: [PHP] for loop problem? Hi Tyler, This doesn't sound like a problem with PHP, but MySQL. Can you show your CREATE TABLE and MySQL version? John Hi Martin, I just got done doing that, and i got the same thing! :-( Here's something interesting though. There's an id field that's set to AUTO_INCREMENT. I did a SELECT * FROM passcodes WHERE passcode='P100' This gave me this: id | passcode --- 1 |P100 82145 |P100 209398 |P100 Shouldn't the ID's be further apart than that? Know what I'm saying? Tyler - Original Message - From: Martin Towell [EMAIL PROTECTED] To: 'Tyler Longren' [EMAIL PROTECTED]; Jack Dempsey [EMAIL PROTECTED] Cc: PHP-General [EMAIL PROTECTED] Sent: Monday, November 12, 2001 10:45 PM Subject: RE: [PHP] for loop problem? How about changing the logic lightly? try this: $value1 = 0; $value2 = 223109; for($i=$value1; $i=$value2; $i++) { $tmp = sprintf(1%06d\n, $i); mysql_query(INSERT INTO passcodes (passcode) VALUES ('P$tmp')); basically taking away 1,000,000 from the numbers then adding it back on later Martin T -Original Message- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 13, 2001 3:38 PM To: Jack Dempsey Cc: PHP-General Subject: Re: [PHP] for loop problem? I've ran it a few times without the MySQL code in there. Runs just fine that way for me too. After it's run a few times for me (with the MySQL code), I start getting duplicate entries of codes in there. For example, I'll end up with a few 'P100' entries in the 'passcodes' field. Oh well, here I come perl! Thanks, Tyler - Original Message - From: Jack Dempsey [EMAIL PROTECTED] To: Tyler Longren [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, November 12, 2001 10:43 PM Subject: RE: [PHP] for loop problem? ran it (without mysql queries) and worked finereal strange. have you tried the loop without the mysql queries? -Original Message- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Monday, November 12, 2001 11:28 PM To: Jack Dempsey; [EMAIL PROTECTED] Subject: Re: [PHP] for loop problem? Exact code: ? $connection = mysql_connect(host_here,user_here,pass_here); $db = mysql_select_db(db_here, $connection); $value1 = 100; $value2 = 1223109; for($i=$value1; $i=$value2; $i++) { mysql_query(INSERT INTO passcodes (passcode) VALUES ('P$i')); if (mysql_error() != ) { print font face=Arial size=2.mysql_error()./font; exit; } } mysql_close($connection); ? Tyler - Original Message - From: Jack Dempsey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 12, 2001 10:34 PM Subject: RE: [PHP] for loop problem? paste the complete code in and myself and others can run your exact copy -Original Message- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Monday, November 12, 2001 11:22 PM To: Martin Towell; [EMAIL PROTECTED] Subject: Re: [PHP] for loop problem? I removed all of the quotes that could be affecting it. Still, it loops until I stop it. I let it go all the way up to 350,000 or so. Any other ideas anyone? Thank you! Tyler - Original Message - From: Martin Towell [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 12, 2001 10:06 PM Subject: RE: [PHP] for loop problem? hmmm... I just tried : $value1 = 100; $value2 = 1223109; for($i = $value1; $i = $value2; $i++) { echo $i\n; } and it spat out all 223109 numbers (albiet after a VERY long time)
Re: [PHP] HTTP_POST_VARS: Data there, but can't get to it
Name the form element without the brackets ... just whatdo instead of whatdo[]. When $whatdo[] makes it to your formhandler, it's an array. (You _could_ access $whatdo[0] ... but that may or may not be more confusing.) ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Sat, 10 Nov 2001, Lara J. Fabans wrote: Just an addendum, I changed it from radio buttons to a pop up menu p select name=whatdo[] id=whatdo option value=load selectedLoad/option option value=deleteDelete/option option value=changeChange Category/option /select /p Again, if I print_r (HTTP_POST_VARS), I can see the Array ( [whatdo] = Array ( [0] = load [1] = delete), [other stuff]) but I cannot access it. I'm doing the same exact syntax for the image name=image[] which works perfectly. I can find nothing on this in the documentation or any of the other wonderful books websites out there. Please, what am I doing wrong in trying to access the HTTP_POST_VARS? Thanks, Lara At 08:36 AM 11/10/2001 -0800, Lara J. Fabans wrote: My bad for typing it in from memory. I'd retyped it in a few times, so I thought i had it perfect. Here's the exact code: print_r ($HTTP_POSTVARS); // yeilds the array that I pasted down below if ($flag==process) { $whatdo = $HTTP_POSTVARS['whatdo']; print_r($what_do); // blank . . . for ($x=0;$x=$row;$x++) { $whatdox = $whatdo[$x]; print $whatdox; // blank . . . //loop start tr td nowrap p input type=radio name=whatdo[?php print $row?] value=load checked Loadbr input type=radio name=whatdo[?php print $row?] value=delete Deletebr input type=radio name=whatdo[?php print $row?] value=change Change Category/p /td . . . - Lara J. Fabans Lodestone Software, Inc [EMAIL PROTECTED] At 09:41 AM 10/11/01, Lara J. Fabans wrote: Hi, I'm having some difficulties accessing HTTP_POST_VARS The original form has a table where each row has a set of 3 radio buttons name=whatdo?php print $x?[] where $x is the row counter. (I'm using PHP to pull info into a table, then the user manipulates the info, and it places the info into 2 other tables depending upon what the choice is for the 3 radio buttons). So, on submit, it reloads the page, and I pull in all of the areas. All work except the radio buttons. I've tried: $submitted_vars = $HTTP_POST_VARS; $whatdo = $submitted_vars[whatdo]; --- and $whatdo = $HTTP_POST_VARS[whatdo]; -- but when I do a print_r($whatdo) it's blank When I do a print_r($HTTP_POST_VARS) I get Array ( [whatdo] = Array ( [0] = load [1] = delete), [other stuff]) What am I doing wrong :-) How do I access this data? It's so frustrating since all the rest of the postvars are working, and I can see that the data's there in the HTTP_POST_VARSI just can't get to it. (pun not intended) - Lara J. Fabans Lodestone Software, Inc [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] HTTP_POST_VARS: Data there, but can't get to it
On Fri, 9 Nov 2001, Lara J. Fabans wrote: The original form has a table where each row has a set of 3 radio buttons name=whatdo?php print $x?[] where $x is the row counter. Well, for a set of raido buttons, they should all have the same name. In your case, all 3 radio buttons should be named whatdo. Don't put on any brackets ... that will cause whatdo to be an array when it's being handled by the form handler. Then you can check $HTTP_POST_VARS['whatdo'] for the value of the checked radio button when the form was submitted. g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] HTTP Headers
On Fri, 9 Nov 2001, Mike Harvey wrote: Is it possible to redirect to an IP address but have the browser address bar show an URL? Assuming that you meant hostname instead of URL since the browser address bar will always display a URL ... No. ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Apache Request Ids?
On Tue, 23 Oct 2001, Brian White wrote: process ID belongs to Apache. What I was wondering was there any kind of ID that was attached to a particular CGI request that I could access and use? Yes. Use the Apache module, mod_unique_id, and then in your environment, $UNIQUE_ID will be available. Every request to httpd gets its own UNIQUE_ID. Details here: http://httpd.apache.org/docs/mod/mod_unique_id.html ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Using Logical OR operator in IF statement???
I'm a bit confused by the logic used (your conditionals are looking for NOT -, but then the printed statement indicates you were looking for the -), but anywho ... try these on for size. if (substr($sString,-1,1)==-) { print You can't have a dash at the end of your string.; } if (substr($sString,0,1)==-) { print You can't have a dash at the beginning of your string.; } if ((substr($sString,-1,1)==-) or (substr($sString,0,1)==-)) { print you can't have a dash at the beginning or end of your string.; } (They reflect me thinking that you just had a logic mix-up, and I simplified the call to substr() ... the strlen() was overkill.) g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Sat, 20 Oct 2001, Brad Melendy wrote: Hello, Ok, this works: if (substr($sString,(strlen($sString)-1)!=-)) { print You can't have a dash at the end of your string.; } and this works: if (substr($sString,0,1)!=-) { print You can't have a dash at the beginning of your string.; } But, this doesn't work for any case: if ((substr($sString,(strlen($sString)-1)!=-)) or (substr($sString,0,1)!=-)) { print you can't have a dash at the beginning or end of your string.; } What could be wrong? I've used a logical OR operator in the middle of an IF statement like this before, but for some reason, this just isn't working. Anyone got any ideas? I suppose I can just evaluate this with two different IF statements, but it seems like I shoud be able to do it in one and reduce duplicate code. Thanks very much in advance. .Brad -- 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] delete html
use the strip_tags() function to remove HTML tags from strings. http://www.zend.com/manual/function.strip-tags.php ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Sun, 21 Oct 2001, jtjohnston wrote: How can I delete html from an input type=text ? Signed Perl user converted :) An email post reply would come in ral handy. John -- 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] Using Logical OR operator in IF statement???
That's odd ... the code I gave you I tested prior to pasting into my email, and it worked fine ... and still does. I'm not aware of any bugs with logical or in any versions of PHP. If this doesn't work for you, I'm not sure where to go. (It works on my server ... PHP 4.0.6-5 ... and my personal preference for || over or is reflected :) ?php $sString = foo-; if( substr( $sString, 0, 1 ) != - ){ print( no - at beginning of stringbr ); } if( substr( $sString, -1, 1 ) != - ){ print( no - at end of stringbr ); } if( ( substr( $sString, 0, 1 ) != - ) || ( substr( $sString, -1, 1 ) != - ) ){ print( - missing from beginning or end of stringbr ); } ? g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Sun, 21 Oct 2001, Brad Melendy wrote: Thanks Chrisopher, Yeah, I was a tad confused. What I wanted to say in my statement was really this: if ((substr($sString,-1,1)!=-) or (substr($sString,0,1)!=-)) { print do this if there isn't a dash at the beginning or end of your string; } else { print you can't have a dash at the beginning or end of your string.; } I like the simplifying of the statement by counting backwards regardless of the string length. But I still can't get the darn thing to work if I use: if ((substr($sString,-1,1)!=-) or (substr($sString,0,1)!=-)) It only works if I use (substr($sString,-1,1)!=-) or (substr($sString,0,1)!=-) by themselves. That only catches one half of what I am trying to do though. I get the results I expect indivitually so that -hello fails with one part of the statement and hello- fails with the other part, but when I use them together with the OR operator, it doesn't pick up either case, -hello or hello-. I think I'm going to have to resort to evaluating the string with more than just the one IF statement and use an ELSEIF and duplicate some code to make this work. Thanks very much in advance. Brad Christopher William Wesley [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm a bit confused by the logic used (your conditionals are looking for NOT -, but then the printed statement indicates you were looking for the -), but anywho ... try these on for size. if (substr($sString,-1,1)==-) { print You can't have a dash at the end of your string.; } if (substr($sString,0,1)==-) { print You can't have a dash at the beginning of your string.; } if ((substr($sString,-1,1)==-) or (substr($sString,0,1)==-)) { print you can't have a dash at the beginning or end of your string.; } (They reflect me thinking that you just had a logic mix-up, and I simplified the call to substr() ... the strlen() was overkill.) g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Sat, 20 Oct 2001, Brad Melendy wrote: Hello, Ok, this works: if (substr($sString,(strlen($sString)-1)!=-)) { print You can't have a dash at the end of your string.; } and this works: if (substr($sString,0,1)!=-) { print You can't have a dash at the beginning of your string.; } But, this doesn't work for any case: if ((substr($sString,(strlen($sString)-1)!=-)) or (substr($sString,0,1)!=-)) { print you can't have a dash at the beginning or end of your string.; } What could be wrong? I've used a logical OR operator in the middle of an IF statement like this before, but for some reason, this just isn't working. Anyone got any ideas? I suppose I can just evaluate this with two different IF statements, but it seems like I shoud be able to do it in one and reduce duplicate code. Thanks very much in advance. .Brad -- 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] Form Question
On Sun, 21 Oct 2001, Chip Landwehr wrote: if ($T3==){header (Location: new_narrative.php?FilledName=No);} How do I change this to include a Post? You can put it back on as a query string (kinda dirty, but you can't POST it back). ?php $myQueryString = FilledName=No; while( list( $key, $val ) = each( $HTTP_POST_VARS ) ){ $myQueryString .= . $key . = . $val; } if( $T3 == ){ header( Location: new_narrative.php? . $myQueryString ); } ? ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Re-send (Download the whole directory using PHP)
On Sun, 21 Oct 2001, Mark Lo wrote: I have been asking this for so many times, and I never get a reply for this !!! Please help me. I would like to know how to download the whole directory using PHP. Can anyone supply me some sources code for this. I see a few reasons why you won't get an answer to your question: 1) you didn't ask a well-formed question. your question was vague. 2) you didn't provide any information about your setup or environment. 3) you didn't ask for help. you asked for code. 4) you didn't demonstrate that you're trying to come up with your own solution, and need some help to make your solution work. You're free to make such inqueries, but we're also free to ignore them. (Most people regard your type of inquery as rude, and delete them.) If you remedy the conditions mentioned above, I'm sure people on the list would be glad to help. g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] Stopping the browser from continuing to load
For a process that takes a long time, I usually break the user interaction the processing apart. For instance, when the user makes a submission from the browser interface, the PHP takes the submitted data and stores it someplace on the file system or in a database. This being a quick operation, the user can be safely notified that their submission is complete, and the user can go about his/her business within the browser interface. Then there is a process that runs on the server, say every minute (asynchronously from visitors triggering the PHP script), that is looking for new data in the location the PHP script deposits the submitted data, and processes it. It's a bit more work than just making the PHP script execute for hours, but it is far better use of the server's resources, and gives you much more flexibility to alter the processing w/o affecting the user experience (actually creating a better user experience). g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Fri, 19 Oct 2001 [EMAIL PROTECTED] wrote: Hi All- I have a script in which I use ignore_user_abort() to perform some extensive processing that can take a few hours which there is no need for users to wait for. I display a message saying their submission is complete and continue to run the PHP script in the background. It doesn't matter if they close their browser or whatever, as the script continues to run. My problem is, I want the browser to stop waiting for more output from the script. It confuses people when it says you may now close the browser when the icon in the top right is still moving and the progress bar is still moving. Is there any way in PHP (or even Javascript) that I can tell the browser to close the connection (ie. the equivalent of hitting the stop button). Apparently window.stop() in javascript works in Netscape Navigator but not in IE. I really need this to work in IE (and it only need be IE!). Any ideas? PS/ Not really keen on running a cron job to do the same thing when it would be easier just to stop the browser from loading. -Adam -- 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] InterBase transaction ...
Just use one argument or the other ... not both. ibase_commit($myTrans); OR ibase_commit($myDB); g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Fri, 19 Oct 2001, Yoel Benitez Fonseca wrote: Hi! Someone can explain me (or give me an example or more) about the function: ibase_commit() I am using PHP 4 and InterBase 6.0 over IIS 5.0, in the version of the manual that I have the following description appears: int ibase_commit ([int link_identifier, int trans_number]) but when I use it in my script, for example: ibase_commit($myDB, $myTrans); I receive the following error: . Wrong parameter count for ibase_commit () in. thank you in advance, Yoel. -- 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] how to move one element of an array to the end of thearray
Splice the array at the point in your result array where No make specified is, for one element, then append it back onto the result array. Here ... $noMake = array_splice( $resultArray, array_search( No make specified, $resultArray ), 1); // This should be one line, sorry :) $newResults = array_merge( $resultArray, $noMake ); // Two lines total g.luck, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Fri, 19 Oct 2001, Tom Beidler wrote: I'm running a query that pulls up automotive makes for a given year and orders them alphabetically. One of the options is no make specified which I would like to always move to the end of the mysql_fetch_array. So my while loop would pull up AMC Ford Volkswagon No make specified Instead of AMC Ford No make specified Volkswagon After looking over the php site it doesn't look like there is an easy way to do it. Should I take the array, remove the element and then add it to the end? The no make specified unique id in the make database is 1. I could order by id, use array_shift to pop off the first element, sort the array by asort, and then add it on the end using array_push. Is there a better way? Thanks, Tom -- 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] mssql freetds php4 linux
I'm running php 4.0.6.7rc2-3 with freetds 0.52-3 support on a debian linux server. This is a winning combination to work with MSSQL2000. However I'm running into some odd behavior when performing multiple queries on the same connection (link) identifier. I create a connection to the dbms and select a database. Then I perform an insert. [ $CN01 = mssql_connect('host','uname','passwd'); mssql_select_db('mydb',$CN01); $RS01 = mssql_query(insert into foo values ('bar1','bar2'), $CN01); ] I folllow this operation by a select on table 'foo'. [ $RS02 = mssql_query(select * from foo, $CN01); ] This second query is never successful. It appears that the link ($CN01) is destroyed after the first query (the insert). When I print $CN01 before the first query, it's value is Resource id #1 but when I print $CN01 after that query and before the second query, it is null. I can successfully perform the second query by opening a new connection to the dbms and using it for the second query. ALSO, I can successfully perform the queries in reverse order, select first then insert, without using a new connection. (A bit more experimentation shows I don't have this problem with mod_perl.) I've also tried this with the sybase_*() functions, and I get the same results. Is there any reason why I must open a new connection to perform a select after performing an insert on an mssql2K table [using php]? THX, ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] problem with getting data from NNTP server
On Sun, 16 Sep 2001, Luboslav Gabal ml. wrote: I have script for getting header of article from NNTP server using sockets: output have look so: From: Antonin Mohaupt [EMAIL PROTECTED] but it is only From: Antonin Mohaupt What's the problem ? I tried higher raise length of data (second argument of Anything between and will look like an HTML tag to your browser. If you view the source of the HTML in your browser, I'm sure you'll see [EMAIL PROTECTED] :) You browser just doesn't know how to display that tag (because it's not one). Change your echo line from echo $result.br; to echo htmlspecialchars($result).br; This will convert to lt; and to gt; so it will be displayed in your browser correctly. For more info: http://php.net/htmlspecialchars ~Chris /\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden -- 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] CheckBoxes and Arrays
On Tue, 11 Sep 2001, Ryan Stephens wrote: Im trying to output a list of options, each with a checkbox named ChkBox ... Name each checkbox ChkBox[] ... the brackets are the key. When the form is submitted, you'll have an array called $ChkBox that will contain the data only from the checked checkboxes. You can loop over that array pretty simply. for( $i = 0; $i sizeof( $ChkBox ); $i++ ){ print( $ChkBox[$i] . was checkedbr ); // Delete the row from the database, etc ... } ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] Carriage return.
On Wed, 5 Sep 2001, Johan Vikerskog (EMP) wrote: My php script is generating a file that is saved in Unix format. I automatically get the ^M in the end of everyline. Is there a way of saving this without getting the ^M in the end of each line? The ^M you see is a DOS carriage return/line feed. It seems your PHP script is printing \r\n at the end of lines. If you want Unix line feeds, your PHP script should print \n only. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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 on Solaris / Linux with MSSQL Server 7.0 or 2000 onWin2K
On Tue, 4 Sep 2001, Boaz Yahav wrote: I'm currently using PHP 4 on Solaris on a front end server with MySQL on Solaris as a db server. ... I want to work with MSSQL Server 2000 instead of MySQL, does anyone have experience with working with such a combination? PHP4 on Solaris as front and Win2K with MSSQL Server 2000 If you'd like to stick with a well supported DBMS (from a PHP interactivity point of view) on Solaris, take a look at using PostgreSQL (postgresql.org, pgsql.com, postgresql.com). If you have your heart set on using MSSQL Server, you can use FreeTDS (freetds.org) w/ PHP to talk to MSSQL Server directly. I've used ODBCSocketServer (odbc.sourceforge.net ... very cool project) to talk to MSSQL Server via ODBC (with the DSN residing on the DB Server), and it worked nicely. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] an error Maximum execution time of 30 seconds exceededin C:\...
On Wed, 5 Sep 2001, nyon wrote: I got an error Maximum execution time of 30 seconds exceeded in C:\... on line 224 while accessing a PHP page tie to a Mysql database. 3. How to I set it to 60 seconds ? This is the default PHP configuration. In your php.ini file, look for this line: max_execution_time = 30 ; Maximum execution time of each script, in seconds Change the 30 to 60, and restart your web server. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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_encode doesn't work....
On Mon, 3 Sep 2001, Dhaval Desai wrote: session_encode($dhaval); ... when I check out the c:\tmp\ directory and check out the session data I can still read the same as dhaval=trythisout and it's not encoded...is it coz the session_encode() returns a string for you to use in a PHP script. It doesn't encode or encrypt the session data on the server. If you need to encode or encrypt the data on the server, you have to create an encoding or encrypting scheme within your PHP scripts. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] replacing a carriage return with an html break
On Mon, 3 Sep 2001 [EMAIL PROTECTED] wrote: I am filling out a form text area, and submitting it to the next page which just prints what I submitted, but it doesnt print any returns, i used when i filled out the previous text area Try using nl2br() in the output script (page). http://php.net/nl2br ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] If PHP4 existed in 1995 we would of taken over the worldby now
On Mon, 3 Sep 2001, Bob wrote: look. What I am looking for is the cool factor. I know technology needs time to improve but what's going to be cool in PHP5??? It's like a race that never finishes and who is winning? ASP or PHP? PHP5 will still run on your Free OS, your CLI OS, your Pay OS, your GUI OS, etc. ASP (of the VBSchidtz flavor) will only run on your Illegal Monopoly OS. It's so cool it burns! Flexibility, portability, and cost-effectiveness ... you won't get burned. Ras ... ROCK ON!! ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] Am I right or wrong?
On Tue, 4 Sep 2001, Seb Frost wrote: I have a folder of ~80kb images that are dynamically resized using PHP into ~1.4kb thumbnails. Now for each one the PHP server sends an HTTP request for the 80kb image, and this is being counted against my 10,000MB. Should it? Am I in the right in thinking that it shouldn't? So, your PHP scripts are on one server, and your big images are on a separate server? If so, you are generating traffic between the two servers ... at which point you need to consult your service contract. Your contract should tell you for what traffic (including between which servers, across which networks) you will be billed. It's kind of strict to charge for traffic across a local network ... I wish you luck fighting your ISP if the contract doesn't define for which traffic you'll be billed. Aside from the ISP issue ... dynamically resizing 80K images on the fly is frightful thing. Creating thumbnails [once/at regular intervals] would be a wise step to take. It takes the load off the web server and will cut your network traffic. The tradeoff is disk space usage ... but you can store 57 1.4KB thumbnails in the same space as one 80KB image :) Good trade! ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] How to index HTML fields for Javascript and PHP at sametime?
On Mon, 3 Sep 2001, Miguel wrote: I need to refer these fields like vector in PHP and Javascript mode. When I write input type=text name=myfield[]... then I can see values in PHP sccript, BUT can't see values in javascript mode, thats to say document.form.myfield[index].value doesnt work. On the other side, when I make input type=text name=myfield I can see indexed values in Javascript BUT not in PHP script. Try giving the input fields id's that you can use from JavaScript. i.e.- input type=text id=field1 name=myfield[] then from your JavaScript, you can refer to that field by referencing document.myForm.field1.value (for Netscape and IE) And you can still use $myField[] in PHP. Check out this small test ... // HTML FORM html head titleTest/title script language=JavaScript function setField( ){ document.testForm.field1.value = Woot!; document.testForm.field2.value = I Really Hope; document.testForm.field3.value = This Works For You!; } /script /head body form name=testForm action=test.php method=POST input type=text id=field1 name=myfield[] value= input type=text id=field2 name=myfield[] value= input type=text id=field3 name=myfield[] value= input type=button onClick=setField() value=Click! /form /body /html // PHP Form Handler (test.php) for( $i = 0; $i sizeof( $myfield ); $i++ ){ print( $myfield[$i] ); } (Step through the array any way you please :) ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] Newbie Question: Converting PHP3 files to PHP4?
On Mon, 3 Sep 2001, Michelle Marcicki wrote: website. It is using PHP3 and MySQL. We had to move it to a new server, that as it turns out only supports PHP4. I have been looking through all the FAQs, Are you running an Apache web server? If so, add this line to your httpd.conf file and restart Apache: AddType application/x-httpd-php .php3 (You'll find similar lines in your httpd.conf file ... add this line in the same part of the file so you can find it easily next time.) ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] Newbie Question: Converting PHP3 files to PHP4?
On Mon, 3 Sep 2001, Michelle Marcicki wrote: I am NOT running the server. I am using a local ISP (excellent guy but not really accessible on this long weekend), so I have no control over what the OOOH ... Nasty! If the admin can't add the .php3 extension for you, then you'll be stuck renaming files, and correcting references within them. If it's a unix host, it's not that painful ... just a small shell script, and a sed script. (In Illegal Monopoly OS, it may be lots more painful.) Good luck, ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] Want mysql dump to be mailed to me....
On Tue, 4 Sep 2001, sagar wrote: I have a remote server running my website. I've to make the backup of the mysql db i'm using. i can use mysqldump for this. but i'm not sure where the file will be created on the server and also i want to make that file to .zip and then download it to my pc. how can i do this. Please help. Create a shell script to run mysqldump then compress it (I like bzip), and schedule it to run nightly. For future reference, check in the MySQL documentation and mail lists: http://www.mysql.com/documentation/index.html http://www.mysql.com/documentation/lists.html There's not much MySQL/system maintenance support offered in this list by comparison. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] Side Comment (was: Newbie Question: Converting PHP3 filesto PHP4?)
On Tue, 4 Sep 2001, Jason Murray wrote: Nah, in Illegal Monopoly OS, its just as easy as Apache. Rather than the web server config, I was referring to renaming all the .php3 files to have .php extensions, and combing through all the files, finding all references to .php3 files, and changing them to refer to .php files. I know exactly how to do it ... I do similar tasks routinely ... on my Linux servers. I don't know how to make that task easy in Illegal Monopoly OS. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] Side Comment (was: Newbie Question: Converting PHP3 files to PHP4?)
On Tue, 4 Sep 2001, Jason Murray wrote: But then, the right tools make the job easy regardless of platform. For sure! I don't bother with all that clicking ... now you [Unix folk] don't have to either :) #!/bin/sh for PHP3FILE in `find . -type f -name *.php3 -print` do PHP4FILE=`echo ${PHP3FILE} | sed 's/\.php3/\.php/g'` sed 's/\.php3/\.php/g' ${PHP3FILE} ${PHP4FILE} done #END OF SCRIPT That recursively finds all files starting in whatever directory you like, and creates the newly-named files with all the references corrected as desired (with a small addition, the old files can be archived or removed). I just had some fun with that script and a copy of an old doc root ... 17 directories, deepest directory was at 3 levels, and 216 .php3 files (from 1998 :) ... took a few seconds to make all the modifications. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] header,session stuff works on live fails on dev...?
On Fri, 31 Aug 2001, Nic Skitt wrote: Warning: Cannot add header information - headers already sent by (output started at c:\apache\apache\htdocs\client-secure.php:11) in c:\apache\apache\htdocs\client-secure.php on line 18 Which would indicate that the line 11 is sending output to the browser. Line 11 is: $uid=$HTTP_SESSION_VARS[userid]; How can this be sending an output? I also get this: The error you get isn't saying that line 11 is sending output; the error is saying that output was sent prior to line 11. You'll get the error if you have any code that sends output to STDOUT, or if you have any HTML or even whitespace before your opening PHP tag, and then try to send header data. (Once the browser starts getting the data your PHP script sends to STDOUT and other HTML and spaces, the browser has all the header data its going to use, and sending more is erroneous.) Warning: Undefined index: userid in c:\apache\apache\htdocs\client-secure.php on line 11 Which would indicate that it cant find the session info. If it cant find it does it write it? Make sure you registered userid as a session variable i.e. - session_register(userid); And/Or make sure you make a call to session_start() before trying to check the session variable(s) if you registered the variable in another script and/or don't have session.auto_start set to 1. (http://www.php.net/manual/en/ref.session.php) ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] fpassthru (was: fgets)
On Thu, 30 Aug 2001, Joseph Bannon wrote: What exactly does fpassthru do? Does it download it to my server and then shoot it to the browser?? (http://php.net/fpassthru) For the file pointer on which it operates, it reads the file pointer until EOF and sends the data to STDOUT. It is very much like the 'cat' command in Unix. The file pointer can be to a local or remote file opened with fopen(), or a remote data source opened with fsockopen(). And as always, there's a gem in the docs ... readfile() does the same thing as fpassthru() but doesn't need a file pointer. It just needs a path to a file, so you can eliminate the fopen(). ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] fpassthru (was: fgets)
On Thu, 30 Aug 2001, Joseph Bannon wrote: The thing I want to avoid is using my server's bandwidth. Each member gets a profile and can have a photo referenced from their homepage. I use to allow people to upload photos, but I'm getting close to using my 60GB bandwith limit. The people that have photos on geocities couldn't reference a photo because their servers don't allow remote hosts displaying pictures off their site. Using 'fpassthru' fixed that. However, my next question is if the 'fpassthru' brings the information to my server and then shoots it to the visitor's browser. I know I'm not saving their photos to my server, I just want to make sure I'm not killing my alotted bandwith. Does 'fpassthru' do this? If so, is there another solution? If the image you're sending to the browser comes from a remote host, unfortunately, yes, that image data does get transferred to your server, and then gets transferred again to the users' browsers. Since PHP is a server-side solution, there isn't a way to skip out on the data transfer to your server and use PHP to send the image. The image data has to come from your server when using PHP. You may have to get creative with HTML, DHTML, etc. to work around displaying the remote images from your site. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] fgets
On Wed, 29 Aug 2001, Joseph Bannon wrote: I want to use fgets to get an image off the server and then print it. Kinda like if you call the script picture.php, an image will appear. How do I do I do this, with fopen() and fpassthru() ... $im = fopen( myImage.jpg, r ); if( !$im ){ // FILE WASN'T FOUND } else { // ALL GOOD - SEND IT TO THE BROWSER fpassthru( $im ); } fclose( $im ); For the sake of simplicity, I left off additional error checking I do ... but this is the core of the idea. The image functions (http://www.php.net/manual/en/ref.image.php) work well too. When just pushing out an unmodified image, the above code has proven simplest for me. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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] Re: Need help on putting variable into form
On Tue, 28 Aug 2001, Hugh Danaher wrote: I think at one time I tried using double quotes but didn't get good results. If you have time to answer, why the backslash and what the hell is foo? Using the backslash escapes the double quote ... tells php to not use the double quote (as it does to end a string assignment), but to print it instead. And foo is just a seemingly universal place-holder for a string or something else that you can replace with just about anything. ~Chris /\ \ / Pine Ribbon Campaign Microsoft Security Specialist X Against Outlook The moron in Oxymoron. / \ http://www.thebackrow.net -- 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]