php-general@lists.php.net
Ok, this may have already been posted to the list already, but the archives don't seem to like the & and && characters. I'm running into some code that looks like this: Define('INPUT', 2); if($search->level & INPUT) $tmp.= $search->input(); Ok, what's the & mean? As far as I could tell from the very little documentation I was able to scrape up on google, & is a bit-by-bit operator. Thus, if either INPUT or $search->level, we get TRUE... If that's the case, what's the point of using it instead of || ? Or, do I just totally not understand the point of this. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general@lists.php.net
Where can I read more about this? I'm not sure that I understand why 4 & 4 == 4. -Original Message- From: Greg Beaver [mailto:[EMAIL PROTECTED] Sent: Friday, March 07, 2003 11:04 PM To: [EMAIL PROTECTED]; James Taylor Subject: [PHP] Re: Difference between & && Hi James, & is a bit-wise AND. && is a logical AND. The bitwise AND will return a number, the logical AND will return true or false boolean values. It's a subtle distinction, but important. 4 & 4 == 4 4 && 4 == true == 1 Regards, Greg -- phpDocumentor http://www.phpdoc.org James Taylor wrote: > Ok, this may have already been posted to the list already, but the > archives don't seem to like the & and && characters. > > I'm running into some code that looks like this: > > > Define('INPUT', 2); > > if($search->level & INPUT) $tmp.= $search->input(); > > > Ok, what's the & mean? > > As far as I could tell from the very little documentation I was able > to scrape up on google, & is a bit-by-bit operator. Thus, if either > INPUT or $search->level, we get TRUE... If that's the case, what's the > point of using it instead of || ? > > Or, do I just totally not understand the point of this. 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] Ldap_Add driving me nuts
I'm having trouble with the ldap_add function in my script. There are 4 possible classes in the ldap schema that would be used - organization, person, qmailUser, inetOrgPerson. The ldap_add script will every time return LDAP-Errno: 65 LDAP-Error: Object class violation UNLESS I include data for person, qmailUser, and inetOrgPerson. There's nothing in the schema that should be doing this, so I'm not sure why PHP is complaining about it. Here's some example code real quick: There's really no reason why this shouldn't work as far as I can tell. Here's the objectClasses for the classes that I'm actually using. objectclass ( 1.3.6.1.4.1.7914.1.2.2.1 NAME 'qmailUser' DESC 'QMail-LDAP User' SUP top AUXILIARY MUST ( mail $ uid ) MAY ( mailMessageStore $ homeDirectory $ userPassword $ mailAlternateAddress $ qmailUID $ qmailGID $ mailQuota $ mailHost $ mailForwardingAddress $ deliveryProgramPath $ qmailDotMode $ deliveryMode $ mailReplyText $ accountStatus $ qmailAccountPurge ) ) objectclass ( 2.5.6.4 NAME 'organization' SUP top STRUCTURAL MUST o MAY ( userPassword $ searchGuide $ seeAlso $ businessCategory $ x121Address $ registeredAddress $ destinationIndicator $ preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $ telephoneNumber $ internationaliSDNNumber $ facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $ postalAddress $ physicalDeliveryOfficeName $ st $ l $ description ) ) objectclass ( 2.5.6.6 NAME 'person' SUP top STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) ) objectclass ( 2.16.840.1.113730.3.2.2 NAME 'inetOrgPerson' DESC 'RFC2798: Internet Organizational Person' SUP organizationalPerson STRUCTURAL MAY ( audio $ businessCategory $ carLicense $ departmentNumber $ displayName $ employeeNumber $ employeeType $ givenName $ homePhone $ homePostalAddress $ initials $ jpegPhoto $ labeledURI $ mail $ manager $ mobile $ o $ pager $ photo $ roomNumber $ secretary $ uid $ userCertificate $ x500uniqueIdentifier $ preferredLanguage $ userSMIMECertificate $ userPKCS12 ) ) objectclass ( 2.5.6.0 NAME 'top' ABSTRACT MUST objectClass ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] processing form checkboxes
Heya folks, not sure if this is more of a php question or an html question, though I'm right now leaning towards a 50% php, 50% html, so I think this is on topic still. I have a form filled with checkboxes, each representing one of the 50 states. A user can check as many states as they want, then post the data - The checkbox form would look *something* like: Alabama Alaska Arizona Instead of assigning a unique name to each checkbox, I know there's *some* way to make it so the same name has multiple values, as I've seen it done before (somehow). When posting the data though, the script is only recognizing the box checked with the highest value foreach ($_POST as $value) { echo "$value\n"; } ^^^ Only shows the highest value Any ideas on how to do this without having to check for isset($_POST['california']), isset($_POST['alabama']) etc. etc.? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session_start... twice?
I have a single page site I'm working on that displays the contents of your current session. Users can clear the contents by clicking a link that triggers a $PHP_SELF?clear=1 - Before any headers are sent out, the script checks for $_GET['clear'], and if it's set, it does a session_destroy();. For some reason though, the contents of the session are STILL displayed until you do a refresh on the page. However, for some bizarre reason, if I call session_start() at the very beginning, call session_destroy(); and then session_start() AGAIN after the destroy, it seems to work like it's supposed to. Is this a bug, or is it working properly? Also - I'm sure there's a better method than this - Any suggestions on what that might be? If there are no better methods well... Are there any downsides to what I'm doing? Below is a "sample" version of the script, to give you an idea of what I mean incase my ramblings above didn't make sense. Thanks!. (some other stuff) \n"; } } // and lastly, here's our "clear session" link below ?> Clear the session -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_fetch_row options
There's got to be a better way to go about this: I am constantly doing mysql queries where I am doing a count(), so a sample query would be like this: "select count(*) from database". I'm expecting only ONE value back exactly, and that's the count results. However, to get this data into a variable, i'm having to write code like this: $result = mysql_query("select count(*) from database", $db); $myrow = mysql_fetch_row($result); $staticvar += $myrow[0]; $staticvar will never be an array, it's just a simple variable storing a number. I *could* do it like this: $result = mysql_query("select * from database", $db); $staticvar += mysql_num_rows($result); However, the mysql query will be much, much slower if I do it like this. Basically, what I'm asking, is how to do something like: $staticvar += mysql_fetch_row($result); I want to eliminate step two, and I don't want to involve any temporary arrays when there's always just one value. Any suggestions? Thanks a bunch! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] "Please Wait"
Just curious if anyone out there knows how to do a "Please wait" type screen while the script is running in the background.. Like say PHP is doing a large select from a database, while the user waits for the script I'd like a graphic or something saying to wait... Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Payflow Pro
Has anyone used the PHP functions to integrate with Payflow Pro? Before I fork out the cash to sign up for an account with them, I'd like to know how solid the SDK and integration is. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Restrict file access from web users?
Ok, I have something like this set up: 1. User logs into site. Authenticates through a mysql table which basically just has username/password columns. Session is set. 2. User goes through site looking for information he'd like to purchase based on specific fields. After the gathering of information is done, a script dumps the text into a CSV file and zips it. 3. The user then downloads the zip. What I can't figure out though, is in step number 3 - How do I secure this? The filenames are randomly generated, but if someone felt like saving a few bucks, they could write a program to try and brute force the guessing of filenames. I need to somehow have an .htaccess type system, WITHOUT .htaccess since the usernames are all just in a standard MySQL table. Any suggestions? Store the file in a table blob? I can't really think of anything. Thanks for your help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Restrict file access from web users?
Thank you sir, problem solved :) -Original Message- From: Justin French [mailto:justin@;indent.com.au] Sent: Sunday, November 10, 2002 11:21 PM To: James Taylor; [EMAIL PROTECTED] Subject: Re: [PHP] Restrict file access from web users? You still need to restrict the files from being served directly over http... this can be done via a .htaccess, or just stored outside the document root. Then, you create a script called download.php, which INSN'T a html page -- it sets a content header, and passes a .zip file through itself to the user. Start by reading this article: http://www.zend.com/zend/trick/tricks-august-2001.php Cheers, Justin on 11/11/02 4:10 PM, James Taylor ([EMAIL PROTECTED]) wrote: > Ok, I have something like this set up: > > 1. User logs into site. Authenticates through a mysql table which basically > just has username/password columns. Session is set. > > 2. User goes through site looking for information he'd like to purchase > based on specific fields. After the gathering of information is done, a > script dumps the text into a CSV file and zips it. > > 3. The user then downloads the zip. > > What I can't figure out though, is in step number 3 - How do I secure this? > The filenames are randomly generated, but if someone felt like saving a few > bucks, they could write a program to try and brute force the guessing of > filenames. I need to somehow have an .htaccess type system, WITHOUT > .htaccess since the usernames are all just in a standard MySQL table. Any > suggestions? Store the file in a table blob? I can't really think of > anything. Thanks for your help. > Justin French Creative Director http://Indent.com.au Web Developent & Graphic Design -- 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] Sessions
Speaking of sessions, I was wondering if something like this is even possible: Users log on, each has their own unique session.. Is it possible to do some sort of instant messaging deal with this? Like, on the main page is displays everyone that's logged on, then you maybe choose their name from a form, type in a message, then a pop-up box appears with the message to the user? I only know how to use sessions for authentication, something like this I'd have no idea where to start. If it is possible, could someone point me in the right direction? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] good practice
Can someone recommend a better method for doing something like the following? All of my programs are written like this, but it's really poor form considering I'm not predeclaring my variables, etc. Only thing I can really think of is to assign a value in the form a number like 1 or something, then do a if $value == 1 {do something} but that seems kinda hokey. Here's an example of something I'd do: \n"; echo " \n"; echo " \n"; echo "\n\n"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
The thing about this is, what variables would I use regarding all active sessions, and the data that is stored in each session? Say there are three people logged on, each with the variable $name stored in their session which is their username - How do I get a list of all the names from the sessions along with their session ID's? On Thursday 14 February 2002 11:06 am, you wrote: > Maybe you can put a small iframe in the HTML which will refresh on some > basis (3secs for example), and in the HTML of this html you do the popup - > window() or alert(). what you choose. the message which is sent(from the > peer1 to server) is stored in db (or file) but have to stored somewhere > till it is sent to the end user. > > Best regards, > Andrey Hristov > - Original Message - > From: "James Taylor" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 14, 2002 9:02 PM > Subject: [PHP] Sessions > > > Speaking of sessions, I was wondering if something like this is even > > possible: Users log on, each has their own unique session.. Is it > > possible to do some sort of instant messaging deal with this? Like, on > > the main page is displays everyone that's logged on, then you maybe > > choose their name from a form, type in a message, then a pop-up box > > appears with the message to the user? > > > > I only know how to use sessions for authentication, something like this > > I'd have no idea where to start. If it is possible, could someone point > > me in the right direction? > > > > -- > > 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] Reading the value in a cookie
http://www.php.net/manual/en/function.setcookie.php Also, read up on any other cookie related functions linked from that page. On Wednesday 20 February 2002 10:04 am, you wrote: > Hello, > > I know how to set a cookie. How do I read the value of that cookie the > next time that person returns to my website? > > > Brandon Orther > WebIntellects Design/Development Manager [EMAIL PROTECTED] > 800-994-6364 > www.webintellects.com > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace("/^\//".. doesnt work?
try: $a = preg_replace("/^\//", "", $a); On Wednesday 20 February 2002 12:25 pm, you wrote: > Im having a weird regexp problem in PHP that I think is correct but it > doesnt appear to work. > > The code is this: > > $a = "/test/"; > preg_replace("/^\//", "", $a); > echo $a; > > I want preg_replace to replace the first '/' in $a with '' so that the > echo function echoes "test/", but instead it echoes "/test/" as if > preg_replace didnt worked? What am I doing wrong? > > Im using: > PHP Version 4.1.1 > Configure Command: './configure' '--with-mysql=/usr/local/mysql' > '--with-apxs=/usr/local/apache/bin/apxs' '--with-db2--disable-debug' > '--disable-static' '--enable-sockets' '--with-yp' '--with-zlib' > Regex Library: Bundled library enabled > PCRE (Perl Compatible Regular Expressions) Support: enabled > PCRE Library Version: 3.4 22-Aug-2000 > > > Please CC me since Im not a member of this maillinglist. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: preg_replace("/^\//".. doesnt work?
Err, that's what he wanted On Wednesday 20 February 2002 12:13 pm, you wrote: > Also note: > > "^" matches the beginning of the string, so "^\/" > will only match a "/" at the beginning of the > string (not the first occurence of "/") > > > -Original Message- > > From: Philip Hallstrom [mailto:[EMAIL PROTECTED]] > > Subject: [PHP] Re: preg_replace("/^\//".. doesnt work? > > > >$a = "/test/"; > >$a = preg_replace("/^\//", "", $a); > >echo $a; > > > > On Wed, 20 Feb 2002, John Ericson wrote: > > > I want preg_replace to replace the first '/' in $a with '' so that the > > > echo function echoes "test/", but instead it echoes "/test/" as if > > > preg_replace didnt worked? What am I doing wrong? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regex
I'm trying to come up with a regular expression that will match the TL and Second Level domain names in someone's email address ONLY. So, say someone's address is "[EMAIL PROTECTED]", I need to match ONLY pacbell.net. It shouldn't matter what the address looks like, I'm looking for any number of digits, a dot, any number of digits, and the end of the line. The closest thing I can come up with is /\@.+?(.+\..+)?$/, but, as you can guess, that matches everything except the very first character. Can anyone help me with this? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] INT function?
Just curious what the function is to convert x into an integer if it's a float Say for example I have something like this $x = 7; $y = 3; $z = $x / $y; I want $z to equal 2. In perl it would be $z = int($x / $y); I'm just not sure how to do this in PHP, as int apparently doesn't work (darn). I'm using 4.06 by the way, so if there's some new function in 4.1 that does this, I can't use it... so < 4.1 functions please -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] INT function?
Heh, that's interesting.. Only difference is you have to put parenthesis around int. Weird On Wednesday 20 February 2002 05:10 pm, you wrote: > $z = (int)($x / $y); // should work > > or > > $z = $x / $y; > settype($z, "integer"); > > -----Original Message- > From: James Taylor [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 21, 2002 12:07 PM > To: [EMAIL PROTECTED] > Subject: [PHP] INT function? > > > Just curious what the function is to convert x into an integer if it's a > float Say for example I have something like this > > > $x = 7; > $y = 3; > > $z = $x / $y; > > I want $z to equal 2. In perl it would be > > $z = int($x / $y); > > I'm just not sure how to do this in PHP, as int apparently doesn't work > (darn). I'm using 4.06 by the way, so if there's some new function in 4.1 > that does this, I can't use it... so < 4.1 functions please -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Guestbook question
I have a really simple guestbook that allows someone to post to the book, then it displays all the entries. Well, there are too many entries now for just one page and it looks kinda wacky, so I wanted to do something where it only displays 10 entries per page, then there are links for pages say 11-20, 21-30, etc. I have no idea how to do this - I only know how to limit the number of entries per page. So, the script that displays all the entries looks something like this: $counter = 0; $result = mysql_query("select name, post from guestbook order by id desc", $db); while (($myrow = mysql_fetch_row($result)) && ($counter < 10)) { echo "$myrow[0]\n"; echo "$myrow[1]\n"; ++$counter; } Well, that shows only the latest 10 alright, but what if I wanted to show entries 11-20? I figure I could get the number of posts through mysql_num_rows, I just can't piece it all together. Any suggestions would be really helpful. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sendmail, I've had enough of it!
Ha, I shouldn't even bother posting this as it's pretty irrelevant for this list but... forget qmail, go with Postfix :) Qmail doesn't have one centralized config file, and it gets annoying having to edit this one, then this one, then make this file, etc. Plus, I usually try to avoid Dan Bernstein projects! On Friday 22 February 2002 11:51 am, you wrote: > Go with QMAIL > > Lots of support (mailing lists, web-sites). Several books written on it. > Easier to set-up than sendmail. Very configurable. > Written by same gent that wrote ezmlm mailing list application (ezmlm > handles the PHP mailing lists). > > goto: http://cr.yp.to/qmail.html > > -Original Message- > From: Anas Mughal [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 22, 2002 1:41 PM > To: Liam MacKenzie; [EMAIL PROTECTED] > Subject: Re: [PHP] Sendmail, I've had enough of it! > > > I had suffered a little bit with sendmail myself last > week. It took me some reading, and I got it working > the second day. > > Here is a useful link: > http://www.samag.com/documents/s=1168/sam0002f/0002f.htm > > Also, check out the book titled "Essential System > Administration". > > That should be all you need -- if you decide to setup > sendmail... :) > > > > > > > --- Liam MacKenzie <[EMAIL PROTECTED]> > > wrote: > > ARGH!!! > > > > I'm seriously sick of this! I've spent days on end > > reading > > documentation, trying settings, seeking help, and it > > still > > won't bloody work! So I've taken the ultimate step, > > and > > applied the trusty rm -rf command to everything that > > has > > to do with sendmail! > > > > In other words, sendmail is no longer on my systems. > > > > Screw it, causes more bad than good! > > > > Ok, now surprisingly enough I do have a final > > question > > regarding PHP/Mail (And I mean final!) > > > > How can I get PHP to send mail through a local SMTP > > server? > > > > I'm running Linux RedHat 7.1, latest Apache and PHP. > > I have eXtremail installed locally. It's a > > POP3/SMTP > > server. Works fine - fact. > > > > There's 3 configuration options in php.ini that I've > > been > > playing with, no matter what the combination is, I > > don't > > really see it doing anything different. > > > > I've read everything relevant on php.net and still > > can't > > find anything. I'm sorry if this is a really stupid > > question. > > > > Thanks s much for all your help! > > > > Liam > > = > Anas Mughal > [EMAIL PROTECTED] > [EMAIL PROTECTED] > Tel: 973-249-6665 > > __ > Do You Yahoo!? > Yahoo! Sports - Coverage of the 2002 Olympic Games > http://sports.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Form Annoyances
I'm having this one issue that's really bugging me - I have a textarea where you can type in something - After typing it in, it goes to another page asking you to verify, if it's correct, it inserts it into a database. The page that asks you to verify holds the value of the textbox in a hidden form field. If the value the user entered in contains any single (') or double (") quotes, it will mess everything up. Single quotes end up having a backslash thrown automatically in front of it, and it inserts it into the database WITH THE backslash. If there are double quotes, the HTML will get messed up due to the fact that when it sees the quote, it will cut off the rest of the value because if: value="this is an example: "Hello how are you"." > everything after example: is going to get cut off. I tried putting the value in a query string, but when traveling across two pages, it seems to do the exact same thing. Any suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variables that can't be set by query string
I have a weblog type script I'm building for a friend where there are main posts then comments - Registered users can post comments, unregistered don't even have the option. I was thinking of making a page where a user logs on, then it registers a session with a few variables like $sid, $username, etc. IF a user is logged on, they can post, if not they don't even see the option. Instead of doing a SQL query everytime they look at the posts, I was thinking of registering a variable called like $true where if they're logged on, it's set, and if it's set they see the option to post. The only thing I'm worried about though is that someone could probably figure out to type in something like comments.php?true=1 and that would allow anonymous posting, which I don't want. Is there anyway to set a variable that can't be set in a query string? Or, is there even a better way of doing something like this? Sorry if I don't make much sense in this question, explaining what a script is supposed to do is kind of difficult for me :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re-Compiling PHP HELP
I'm trying to compile 4.1.2, and it just isn't happening... I originally had 4.0.6 installed, I go to compile 4.1.2 and it just doesn't seem to be 'taking' the compile. This is what I'm doing step by step: ./configure --with-apache=../apache_1.3.22 --with-mysql=/mysql/ --enable-track-vars --with-config-file-path=/etc make make install /www/bin/apachectl restart I check my php_info() page, and it still says I'm running v 4.0.6 Am I missing something here? Do I need to recompile apache also? My initial apache install had this line: ./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a So... What do I do here? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Value of $_* variables
I'm sure this has been asked before, but at least not within the last 600 messages (i checked): I have the session variable $_SESSION['id'] set. Well, I want to actually check the value of this variable, not just to check if it's set. I would be doing this in a mysql query mainly. Something like: $result = mysql_query("select user from users where id = $_SESSION['id]", $db); That just doesn't work, so I have to first go: $sid = $_SESSION['id']; $result = mysql_query("select user from users where id = $sid", $db); Anyway to get around this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Value of $_* variables
Yeah, the curly braces work great. I was at first doing a "where id = " . $_SESSION['id'], $db); but I like the curly braces better. Oh, for those wondering, this wasn't a copy/paste, I just made this up as an example and forgot to put the second quote on $_SESSION['id']; twas a typo :) On Tuesday 05 March 2002 06:04 pm, you wrote: > In article <[EMAIL PROTECTED]>, > > [EMAIL PROTECTED] (James Taylor) wrote: > > $result = mysql_query("select user from users where id = $_SESSION['id]", > > $db); > > > > That just doesn't work, so I have to first go: > > > > $sid = $_SESSION['id']; > > $result = mysql_query("select user from users where id = $sid", $db); > > > > Anyway to get around this? > > Curly braces: > > $result = mysql_query("select user from users where id = > {$_SESSION['id']}", $db); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multiple Time Stamps
I'm working on a project for a friend of mine that is basically a web log. When he makes a post, it inserts the data into a MySQL database, and also inserts a timestamp which is data("g:ia") (shows hh:mm am/pm). It then just displays all of the posts with the timestamps underneath them. Well, he wants the posts to be catergorized beneath a date, so it would be something like: Headlines for March 7th, 2002 Title 1 message text posted by friend at 1:00am Title 2 message text posted by friend at 9:10pm Healines for March 6th, 2002 Title 1 etc etc etc I'm trying to figure out a way to do this without really making things screwy and bug prone, but can't really come up with any good ideas. I know I'm going to have to have 2 time columns, one with the timestamp, another with the date, but trying to figure out how to organize this all is really frustrating me. Can someone figure out a way to do this without involving multiple embedded while loops, multiple SQL statements and a whole slew of temporary variables? I don't want example code or anything, just an idea of how to do something like this. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Guestbook previous 10/next 10
I have this sort of guest book that only will display 10 entries on the page at a time, after that you have the option of previous 10, and if you're not on the front page you also have next 10. I'm getting the ID of the VERY LAST POST listed on the page. So it's doing something like while ($myrow = mysql_fetch_row($result)) { $pid = $myrow[0]; print the post } $result = mysql_query("select * from posts limit $pid, 10", $db); Well, it seems to KIND of work, the only thing is that the ID's aren't necessarily sequential. If I delete a post, well, that ID is now missing, and when you click 'previous', it's displaying a couple of duplicate posts that were on the page before it. Any idea on a way to get around this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] More fun with sessions
How can I get a listing of all currently active sessions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FAQ
Has anyone given any thought to possibly maintaining a FAQ containing the answers to the most commonly asked PHP questions on this list? I notice duplicates roll through every couple of days, and it would probably be a really nice PHP resource. Or, does one already exist? Ha. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FAQ
You are correct sir. The purpose of the FAQ would be so that, like I said, similar questions that pop up say, once a week, could be answered in the FAQ instead of on the list - That way I won't get 300 messages a day :) On Friday 22 March 2002 11:36 am, you wrote: > Despite what Rasmus just said, I think that you are saying a PHP Mailing > List faq based on the q's that the mailing list gets, not the general PHP > faq. > > Scott > > -Original Message- > From: James Taylor [mailto:[EMAIL PROTECTED]] > Sent: Friday, March 22, 2002 2:30 PM > To: [EMAIL PROTECTED] > Subject: [PHP] FAQ > > > Has anyone given any thought to possibly maintaining a FAQ containing the > answers to the most commonly asked PHP questions on this list? I notice > duplicates roll through every couple of days, and it would probably be a > really nice PHP resource. > > Or, does one already exist? Ha. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IMAGE Manipulation
Hey, I'm not sure if anyone ever answered your question, but here's a little function I wrote for something similar to what you want to do and it doesn't require GD be installed. You need to modify the top portion, I just threw that in there to show you how it would work. $pic is the name of the image you want to display. $largestside is the largest width/height you'll want to be shown - So if the max height or width is supposed to only be 200, you'd set it to that, then it scales the other side so that it displays with the correct dimensions. This doesn't ACTUALLY resize the file, it just takes the image and then in HTML it sets the height and width. If you need to actually resize the file you will need GD to be installed. Hope this helps in some way! function resize($v_pic) { $largestside = 120; $size = GetImageSize ("$v_pic"); $width = $size[0]; $height = $size[1]; if ($width == $height) { $dimensions[0] = $largestside; $dimensions[1] = $largestside; } elseif ($width > $height) { $divisor = $width / $largestside; $height = $height / $divisor; $dimensions[1] = intval ($height); $dimensions[0] = $largestside; } elseif ($width < $height) { $divisor = $height / 120; $width = $width / $divisor; $dimensions[0] = intval ($width); $dimensions[1] = 120; } return $dimensions; } On Saturday 16 March 2002 04:56 am, you wrote: > Hi, > > I'm trying to resize images from a big image to smaller image in > dimension and also file size so that when a user upload an image into > server, when a browser display the picture it desn't have to be as big. > I hope my question make sense. > > I just don't know where to start. > > may be somebody could help me, please. > > thank you for reviewing my email. > > regards, > Dani -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FAQ
The PHP FAQ isn't really specific when it comes to most problems. The 'code' section has like 10 questions, the rest of the FAQ is mainly how to download/compile, what do these PHP errors mean, migration, etc. A FAQ that had answers to questions that people ask on this list on a frequent basis would be more helpful. On Friday 22 March 2002 12:05 pm, you wrote: > I just don't see what the difference is. This is a PHP mailing list which > supposedly gets questions about PHP. Why would the PHP FAQ not be the > right place for this? > > -Rasmus > > On Fri, 22 Mar 2002, James Taylor wrote: > > You are correct sir. The purpose of the FAQ would be so that, like I > > said, similar questions that pop up say, once a week, could be answered > > in the FAQ instead of on the list - That way I won't get 300 messages a > > day :) > > > > On Friday 22 March 2002 11:36 am, you wrote: > > > Despite what Rasmus just said, I think that you are saying a PHP > > > Mailing List faq based on the q's that the mailing list gets, not the > > > general PHP faq. > > > > > > Scott > > > > > > -Original Message- > > > From: James Taylor [mailto:[EMAIL PROTECTED]] > > > Sent: Friday, March 22, 2002 2:30 PM > > > To: [EMAIL PROTECTED] > > > Subject: [PHP] FAQ > > > > > > > > > Has anyone given any thought to possibly maintaining a FAQ containing > > > the answers to the most commonly asked PHP questions on this list? I > > > notice duplicates roll through every couple of days, and it would > > > probably be a really nice PHP resource. > > > > > > Or, does one already exist? Ha. > > > > -- > > 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] Regex Form Filter Help
I have a site where users can type whatever they want in and it posts it to a database. I'm trying to eliminate whatever types of abuse I can think of, and, since I'm using nl2br on the posts, I'm afraid a user might just hold down enter for a couple of seconds and scroll everything off the page. I'm trying to figure out a regex pattern that searches for say, more than 5 strings in a row, and anything after 5 gets stripped out. Any ideas on how to possibly do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_replace - regex for replace string
I'm trying to do something to the effect of this for a preg_replace statement: $string = "Hello\n\n\n\n\n\n\nHow are you?\n\n\n\n\n\n\n\nHi"; $string = preg_replace("/\n\n/", "/\n/", $string); But, it appears the 'replace' portion of the function doesn't allow for regex. How can I do this so that I CAN have the second statement be regex? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace - regex for replace string
This is just an example. There are some cases where I need the second option to be a regular expression, the same way that you can do in Perl regex... On Wednesday 27 March 2002 02:49 pm, you wrote: > On Wed, 27 Mar 2002, James Taylor wrote: > > I'm trying to do something to the effect of this for a preg_replace > > statement: > > > > $string = "Hello\n\n\n\n\n\n\nHow are you?\n\n\n\n\n\n\n\nHi"; > > $string = preg_replace("/\n\n/", "/\n/", $string); > > > > > > But, it appears the 'replace' portion of the function doesn't allow for > > regex. How can I do this so that I CAN have the second statement be > > regex? > > I think you just have your syntax messed up. You don't need delimiters > around the second argument. > > $string = preg_replace("/\n\n/", "\n", $string); > > miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace - regex for replace string
Ok, let me try to refine this as the big picture. User enters something into a form. We take that form value and convert newlines into though nl2br. Then, I want the limit the number of consecutive 's a user can enter, to avoid abuse via a person just holding down enter for a while. $message = nl2br($message); $message = preg_replace("/\n/", "", $message); while (stristr($message, '')) { $message = str_replace('', '', $message); } For some reason, nl2br leaves a newline after each in the actual code. So, If I type something in like: Hello How are you? The string will contain the value: Hello How are you? it NEEDS to say: HelloHow are you? I just can't get this to work at all. I think my head's going to explode, as I've been trying to get this to work for a few hours now On Wednesday 27 March 2002 02:53 pm, you wrote: > This is just an example. There are some cases where I need the second > option to be a regular expression, the same way that you can do in Perl > regex... > > On Wednesday 27 March 2002 02:49 pm, you wrote: > > On Wed, 27 Mar 2002, James Taylor wrote: > > > I'm trying to do something to the effect of this for a preg_replace > > > statement: > > > > > > $string = "Hello\n\n\n\n\n\n\nHow are you?\n\n\n\n\n\n\n\nHi"; > > > $string = preg_replace("/\n\n/", "/\n/", $string); > > > > > > > > > But, it appears the 'replace' portion of the function doesn't allow for > > > regex. How can I do this so that I CAN have the second statement be > > > regex? > > > > I think you just have your syntax messed up. You don't need delimiters > > around the second argument. > > > > $string = preg_replace("/\n\n/", "\n", $string); > > > > miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace - regex for replace string
Hm, nevermind my question :) I'm not thinking straight, not enough sleep. On Wednesday 27 March 2002 02:53 pm, you wrote: > On Wed, 27 Mar 2002, James Taylor wrote: > > On Wednesday 27 March 2002 02:49 pm, you wrote: > >> On Wed, 27 Mar 2002, James Taylor wrote: > >>> I'm trying to do something to the effect of this for a preg_replace > >>> statement: > >>> > >>> $string = "Hello\n\n\n\n\n\n\nHow are you?\n\n\n\n\n\n\n\nHi"; > >>> $string = preg_replace("/\n\n/", "/\n/", $string); > >>> > >>> > >>> But, it appears the 'replace' portion of the function doesn't allow for > >>> regex. How can I do this so that I CAN have the second statement be > >>> regex? > >> > >> I think you just have your syntax messed up. You don't need delimiters > >> around the second argument. > >> > >> $string = preg_replace("/\n\n/", "\n", $string); > > > > This is just an example. There are some cases where I need the second > > option to be a regular expression, the same way that you can do in Perl > > regex... > > Regular expressions are for matching. Can you provide an example that > illustrates what you're trying to do? > > miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting user name in text area
Well, let's see here.. $query = mysql_query("select name from users where uid = {$_SESSION['uid']}", $db); while ($name = mysql_fetch_row($query) { echo "$name[0]\n"; } hope that helps Jennifer Downey wrote: >Hi all, > >Here is what I have and what I am trying to do. > >I would like the user name to be printed in the Username text box but can't >seem to get it there. >I don't want the user to have to type there username in, just click the >submit button and it is entered into the db. >Can anyone show me what I have done wrong? > >$query="SELECT name FROM users WHERE uid={$session["uid"]}"; >$ret = mysql_query($query); >while(list($name)= >mysql_fetch_row($ret)) >print("$name"); > > >?> > > >print "Username: name=\"u_name\" size=30>"; >print "entry\">"; >?> > > >if($action = "Submit my entry"){ >if (!empty($name)){ >$enter = "insert into entry (id, user_name) values ('','$u_name')"; >mysql_query($enter) or die(mysql_error()); >} >} > > >TIA >Jennifer > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Connecting to multiple DB's
I host a few sites, and on usually each site will have it's own MySQL database in the background. I've decided that I want to link one site to another, and need to connect to more than one database at a time. I've found that when I try to connect to 2 or more, even if I assign the other database to another variable (ie . $db1 = @mysql_connect($dbhost, $dbuser, $dbpass); $db2 = @mysql_connect($dbhost2, $dbuser, $dbpass); ) , the last connect called is the only one that is active. Any work arounds to this? I've been having to do it where I connect to one when needed, then connect to the other, etc. I'm thinking there has to be a better way to do this. Also, what is the function to kill a connection to a db? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Fatal Error Handling
Hi, I have a set of functions which are potentially dangerous in terms of memory hogging, and need to protect from memory overflow - this is I want to detect when the memory overflow occurs. The manual says that eval() will return false on a fatal error, so I thought I could do something like the following, where it would produce a "O" for each itteration, and when it failed (memory overflow) it would continue and echo the last line. What I get however is this attached to the end. Any advice would be gratefully recieved (and perhaps, the documentation on eval updating if it can not catch all fatal errors) #! /usr/bin/php run: $ ./intellirun2.php OO Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4194305 bytes) in /home/jt/work2/sms/web/stats/intellirun2.php(8) : eval()'d code on line 1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fatal Error Handling
Richard Lynch wrote: James Taylor wrote: So finally quit that music thing and got a real job? :-) [Sorry. I'm sure you've heard them all, but I couldn't resist...] /me adds Richard Lynch onto the list of those who must die when the revolution comes... I have a set of functions which are potentially dangerous in terms of memory hogging, and need to protect from memory overflow - this is I want to detect when the memory overflow occurs. The manual says that eval() will return false on a fatal error, You may or may not have some success by preceding the eval with a @ and/or using http://php.net/error_reporting and/or using http://php.net/set_error_handler to trap the error. Ok, using the @ that would get rid of the error message agreed, but it still crashes the script (as a fatal error would and should). I took the code from set_error_handler and that does not seem to work in this instance - if I called the function with trigger_error then yes, it was ok, but the memory fail still caused the crash. Please note here, I dont really want to have to use eval - it is a null function in this situation, it only seemed (from the manual) provide a solution to my issue. Removing the eval (replacing the entire loop with a simple while(true){ $str .= $str . "."; } ) which undoubtly would crash after ten or so loops, does not throw my exception on the fatal error! There are other possible solutions which we may end up implementing which include a success monitor, ie each run enteres into a database a "start" and a "end" and then at some other time, another script can check for scripts that have started but not ended (ie crashed) and provide analysis, alerts and fixes for. If you are using PHP 5, a try/catch block may also be useful to consider. I am not (alas). I suspect that eval() DOES return false, once you get the error_reporting under control instead of relying on the rather crude default error handling. With error handling as normal, can it handle a fatal error? My issue is not it would not report a fatal error, it does not continue with the script. The last issue I am worried about is scope - if I have run out of memory, then what can I do - I seem to have issues running commands which go over this limit during the command (irrelevant of their end memory usage). Supposing I had enough memory to run the set_ini function and increase my memory limit, then I would be able to execute any command to roll back (transaction wise) the program execution so far, and email/notify/whatever. This is irellevant if a "success" orientated monitoring method is implemented. James Taylor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fatal Error Handling
-bash-2.05b$ php test.php Content-type: text/html X-Powered-By: PHP/4.3.10 Memory Limit: 32K Memory Used: 13432 Error (1024) in /www/l-i-e.com/web/test.php:12 - Test -bash-2.05b$ Note a complete lack of "Made it" nor an error message trapped by my error handler when the RAM runs out. :-( This is the symptom I had when I recoded t osomething very similar. Looks like the Memory limit is hard-coded and won't trigger an error handler nor will it give you any chance to catch it. Yes, This might be a mis-discription of error, that this error really is php-fatal not just script-fatal. With error handling as normal, can it handle a fatal error? My issue is not it would not report a fatal error, it does not continue with the script. I think maybe not -- but maybe only specific errors exhibit this feature. Memory limit and Time limit could be "weird" enough to need it. You could try some other fatal errors to see. Some errors do seem to be caught correctly such as Parse Error - (especially with Eval) which highlights my theory of fatal being either script-fatal or program-fatal. if its the PHP application that has died, then it would explain why the memory limit and some others might not execute correctly. I did not try time, but suspect that would be script-fatal. Both these limits are designed to protect your computer from crashing becuase of bad programmers (/me looks guilty), and it would be daft to allow a programer to continue with code once either of these have been breached. The last issue I am worried about is scope - if I have run out of memory, then what can I do - I seem to have issues running commands which go over this limit during the command (irrelevant of their end memory usage). Supposing I had enough memory to run the set_ini function and increase my memory limit, then I would be able to execute any command to roll back (transaction wise) the program execution so far, and email/notify/whatever. This is irellevant if a "success" orientated monitoring method is implemented. I think you would be well-served to figure out where the RAM is going, and making sure it's what it should be at various junctures. yes, I seem to have a memory leak, which has been explained to me by a collegue as a possibility that I am including a new object line inside the loop (being used to Java's garbidge collector (and my manual calling of it)) that would get recreated each loop, without much impact on memory, and that removing the new call to outside the loop, and placing a "refresh" or "renew" function into my object would save me memory. This is a little concern as this is difficult to find in the code - the only "large" (proportional to avail-mem) objects that Im using are in loops of ten to twenty seconds (due to database calls). Maybe you're trying to patch symptoms instead of debugging the true problem. Just a thought. Of course, an efficient elegant working program is always to be desired, but the nature of this problem is potentially a PEBCAK - I can not always limit the input ranges suitably (due to number of combinations of different variables), perhaps I should write a calculate function which takes the same arguments as the real function, and guesses to its length of time to run and its memory usage. That way I can make a descision as to whether to run it or not (of course it would take me a while to get the memory profile accurate, but would be nice to see). This isnt as easy as just saying if $x < 10 and $y < 10 or max $x must be inversly proportional to $y (so as $y increases the max $x can be must decrease) as it would involve actual data in the database and knowing how different data affects the speed / memory. But thats my problem and very specific to whats going on, so feel free to ignore... You could also maybe file this as a bug, after searching the bugs database to see if it's a known issue, or even a "feature" I dont think it is a bug I think it makes sense in its repeats, but I think I'll add a comment to the page on the php manual with my findings, and link to this discussion. Thanks for that -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Many forms in one php file
Nsk wrote: Hi I want to create a single php file which will be able to display multiple html forms. Like this: Form1 -> Form2 -> Form3. After the user completes and submits Form1, the script will process it and display a different form. etc... I am new to php, I would need some detailed instructions, or point me to an opensource php script which already does that so that I can analyse it. In a single script it could be a little nasty if you want more then one or two phases - its common to have a submit and view result on the same script, but multiple stages can become a maintaince nightmare, but you can do it like this: You could use a "mode" indicator and a session settings. Look for start_session() in the manual. Something like: if(!isset($_SESSION['mode'])){ $_SESSION['mode'] = 0; // first time round, on first screen } // function to test if mode is 0 AND button pressed (ie a submission, // deal (store) the information and increment mode if($_SESSION['mode'] == 0){ ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image Creation
Dude - that works fine! can you check your code - make sure you havnt got any white space at all before the php starts in ANY file, and then check that you've got ALL erros being reported (because you might have the error cant send headers, output allready sent at line x) which will prenvent the header being sent and then you dump the image to the screen which is the random wierd characters (that means the image create functions are all ok and installed, and you have an image object or similar). my code was simple NO WHITESPACE NO BLANK LINES NOTHING. (ps you might even have a php include in the php file (php prepend or something?) which might be inserting a space or a newline or ending headers or something. Look at error_reporting() or similar in the manual to turn error reporting on for your script. Hope you find the bug, thats quite a nice function you have there. J Aaron Todd wrote: I just wrote a little script to play around with the GD library but I am having a problem displaying it in the browser. I have not problem at all when I just run the script. But I was trying to make the image in a custom function which will return the image when its called. All I end up getting is a bunch of weird characters. Here's my code: function makepie($slice, $total){ $height = 150; $width = 150; $im = ImageCreate($width, $height); $bck = ImageColorAllocate($im, 255,255,255); $black = ImageColorAllocate($im, 0, 0, 0); $red = ImageColorAllocate($im, 255, 0, 0); imagefilledellipse($im, 75, 75, 125, 125, $red); imageellipse($im, 75, 75, 125, 125, $black); //Making the Slice $pieslice = (($slice / $total) * 360) + 315; imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, IMG_ARC_PIE); //Return header("Content-type: image/png"); echo ImagePNG($im); } Anyone have any idea why I cant return the image? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image Creation
Ahh now it becomes clear, you where trying to place the image inline. There is a way with base64 encoding, but it isnt supported by many browsers - you can actually say data:image/png,base64;[...]";> where the [...] is the base64 encoded image, so you would need to wrap an ob start and ob end around your code to catch output, then base64 encode it then display it. The problem is it dosnt work in IE because IE dosn't support this. Its also not very nice for anyone not wanting to view images as they will have downloaded the image even though they dont want to see it. There was a very good reason why I know that and have done it, but more then 99.9% of the time, its not the way to go. (the case in example was an embedded application on a machine that had a pseudo-web interface but no webserver - it would wait for a connection on a port then "dump" a stream of text which would be in HTML - there was no webserver there it would ignore any http headers sent). Aaron Todd wrote: Hey Guys, I think I fixed my own problem. I tried calling the PHP script from a different page like this: This gave me the results I wanted. Thanks for all your help. Aaron "Aaron Todd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I just wrote a little script to play around with the GD library but I am having a problem displaying it in the browser. I have not problem at all when I just run the script. But I was trying to make the image in a custom function which will return the image when its called. All I end up getting is a bunch of weird characters. Here's my code: function makepie($slice, $total){ $height = 150; $width = 150; $im = ImageCreate($width, $height); $bck = ImageColorAllocate($im, 255,255,255); $black = ImageColorAllocate($im, 0, 0, 0); $red = ImageColorAllocate($im, 255, 0, 0); imagefilledellipse($im, 75, 75, 125, 125, $red); imageellipse($im, 75, 75, 125, 125, $black); //Making the Slice $pieslice = (($slice / $total) * 360) + 315; imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, IMG_ARC_PIE); //Return header("Content-type: image/png"); echo ImagePNG($im); } Anyone have any idea why I cant return the image? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php