php-general Digest 4 Jul 2004 16:14:54 -0000 Issue 2857
php-general Digest 4 Jul 2004 16:14:54 - Issue 2857 Topics (messages 189657 through 189667): user-defined superglobals 189657 by: Michael Collins 189658 by: Michael Gale 189659 by: John W. Holmes 189660 by: Jason Barnett 189661 by: Michael Collins 189662 by: Jason Barnett 189665 by: Steve Douville User Logon Procedure Fails 189663 by: Harlequin 189666 by: Torsten Roehr Re: Obtain NT Logon 189664 by: Harlequin Unable to retrieve value from database and echo on screen 189667 by: Harlequin Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. -- Michael __ ||| Michael Collins ||| Kuwago Inc ||| Singapore and Seattle USA ---End Message--- ---BeginMessage--- Hello, I am not a programmer so I do not know if you can create a superglobal variable. I am sure there is a problem with this ... any ways I user: require(db_access.php); at the top of all my pages that require db access for a application that way the db access gets set on a per page bases. Which would be safe then a superglobal one. Michael. On Sun, 4 Jul 2004 14:22:09 +0800 Michael Collins [EMAIL PROTECTED] wrote: I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. -- Michael __ ||| Michael Collins ||| Kuwago Inc ||| Singapore and Seattle USA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Michael Collins wrote: I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. You can do the same thing with a PHP file and have it auto_prepended to your scripts or just include() it yourself. You can't make your own superglobals, but you can assign keys to the existing ones, if you really want. $_SERVER['MY_DATABASE_USER'] = 'user'; $_SERVER['MY_DATABASE_PASS'] = 'pass'; mysql_connect('localhost',$_SERVER['MY_DATABASE_USER'],$_SERVER['MY_DATABASE_PASS']); etc... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com ---End Message--- ---BeginMessage--- About the only user-defined superglobals are constants. If you really want to get the value of a global variable while inside of a function, you could just use GLOBAL. Or if you REALLY wanted to, you could store the variables in the $_SESSION superglobal array. But I'm curious, why do you want superglobal-like access for your database connection? Jason ---End Message--- ---BeginMessage--- At 2:57 AM -0400 7/4/04, John W. Holmes wrote: Michael Collins wrote: I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. You can do the same thing with a PHP file and have it auto_prepended to your scripts or just include() it yourself. I think I will opt for the strategy to prepend a file using the auto_prepend_file directive in the php configuration file: php_value auto_prepend_file /path/prepend.php This was helpful (which I was able to find after getting the terminology of auto_prepend): http://www.zend.com/zend/spotlight/prepend.php At 3:12 AM -0400 7/4/04, Jason Barnett wrote: About the only user-defined superglobals are constants. If you really want to get the value of a global variable while inside of a function, you could just use GLOBAL. Or if you REALLY wanted to, you could store the variables in the $_SESSION superglobal array. But I'm curious, why do you want superglobal-like access for your database connection? In part, I am looking for a way to have a standardized library of functions that are available everywhere without having to do an include on every page. auto_prepend
[PHP] user-defined superglobals
I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. -- Michael __ ||| Michael Collins ||| Kuwago Inc ||| Singapore and Seattle USA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] user-defined superglobals
Hello, I am not a programmer so I do not know if you can create a superglobal variable. I am sure there is a problem with this ... any ways I user: require(db_access.php); at the top of all my pages that require db access for a application that way the db access gets set on a per page bases. Which would be safe then a superglobal one. Michael. On Sun, 4 Jul 2004 14:22:09 +0800 Michael Collins [EMAIL PROTECTED] wrote: I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. -- Michael __ ||| Michael Collins ||| Kuwago Inc ||| Singapore and Seattle USA -- 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] user-defined superglobals
Michael Collins wrote: I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. You can do the same thing with a PHP file and have it auto_prepended to your scripts or just include() it yourself. You can't make your own superglobals, but you can assign keys to the existing ones, if you really want. $_SERVER['MY_DATABASE_USER'] = 'user'; $_SERVER['MY_DATABASE_PASS'] = 'pass'; mysql_connect('localhost',$_SERVER['MY_DATABASE_USER'],$_SERVER['MY_DATABASE_PASS']); etc... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: user-defined superglobals
About the only user-defined superglobals are constants. If you really want to get the value of a global variable while inside of a function, you could just use GLOBAL. Or if you REALLY wanted to, you could store the variables in the $_SESSION superglobal array. But I'm curious, why do you want superglobal-like access for your database connection? Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] user-defined superglobals
At 2:57 AM -0400 7/4/04, John W. Holmes wrote: Michael Collins wrote: I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. You can do the same thing with a PHP file and have it auto_prepended to your scripts or just include() it yourself. I think I will opt for the strategy to prepend a file using the auto_prepend_file directive in the php configuration file: php_value auto_prepend_file /path/prepend.php This was helpful (which I was able to find after getting the terminology of auto_prepend): http://www.zend.com/zend/spotlight/prepend.php At 3:12 AM -0400 7/4/04, Jason Barnett wrote: About the only user-defined superglobals are constants. If you really want to get the value of a global variable while inside of a function, you could just use GLOBAL. Or if you REALLY wanted to, you could store the variables in the $_SESSION superglobal array. But I'm curious, why do you want superglobal-like access for your database connection? In part, I am looking for a way to have a standardized library of functions that are available everywhere without having to do an include on every page. auto_prepend helps solve part of the issue but the trouble with auto_prepend_file, or with including the library on each page, is that php has to parse and process these pages for each and every script. For performance reasons it would be much better if certain values or code could be cached, as is the case with the ASP global.asa file. If the files and scope was limited to an application, or Web site, then a certain level of security should be possible. -- Michael __ ||| Michael Collins ||| Kuwago Inc ||| Singapore and Seattle USA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] user-defined superglobals
every script. For performance reasons it would be much better if certain values or code could be cached, as is the case with the ASP global.asa file. If the files and scope was limited to an application, or Web site, then a certain level of security should be possible. Well if you're looking for caching there are a couple of options available. Zend and APC come to mind, YMMV. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] User Logon Procedure Fails
Another day another problem. This time it appears that users are able to enter their details but I get a query execution error with the following section of code: /* Verify Login */ $sql = SELECT UserFirstName,UserID,UserPassword FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]'; $result = mysql_query($sql) or die (couldn't select database); $num = mysql_num_rows($result); if ($num == 1) //Login Name Was Found { $sql = SELECT UserID FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]' AND password=UserPassword('$_POST[TXT_UserPassword]'); $result2 = mysql_query($sql) or die(Couldn't execute query #2.); The next to last line is bugging me though. AND password= etc. because I have a variable declared earlier in the logon page for TXT_UserPassword and the UserPassword column exists but where in the hell is password...? Is this another of MySQLs on the fly variables...? -- - Michael Mason Arras People www.arraspeople.co.uk - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Obtain NT Logon
Martin John is right. I have used this facility with VB, VBA and VBS but not in PHP. However, the principle is the same. Disable anonymous logins and use the code John is suggesting and it should work a treat. I'd recommend outputting this data to a TXT file or MySQL dbase also. -- - Michael Mason Arras People www.arraspeople.co.uk - John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Manuel Lemos wrote: I have a web form with a field for username, this is a corporate site so will be the users NT logon. Would it be possible using PHP to obtain this information directly from the client pc? Assuming that you Web server is configured to require Windows NT domain authentication for serving that PHP script, I suppose you can get the user with GetEnv(LOGON_USER) . It's available directly in $_SESSION['LOGON_USER'], also. Like Manuel said, though, you have to turn off anonymous browsing in (assuming) IIS and enable NT authentication. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] user-defined superglobals
Or if you wanted it to be pretty... define('MY_DATABASE_USER', 'user'); define('MY_DATABASE_PASS', 'pass'); mysql_connect('localhost',MY_DATABASE_USER,MY_DATABASE_PASS); - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: Michael Collins [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Sunday, July 04, 2004 2:57 AM Subject: Re: [PHP] user-defined superglobals Michael Collins wrote: I am relatively new at PHP and wondering why there is no mechanism to create user-defined superglobals? For example in ASP.Net I can setup a global.asa to define database connections or any named value I want to be available anywhere in an application. It would be great to have something like that in PHP. You can do the same thing with a PHP file and have it auto_prepended to your scripts or just include() it yourself. You can't make your own superglobals, but you can assign keys to the existing ones, if you really want. $_SERVER['MY_DATABASE_USER'] = 'user'; $_SERVER['MY_DATABASE_PASS'] = 'pass'; mysql_connect('localhost',$_SERVER['MY_DATABASE_USER'],$_SERVER['MY_DATABASE _PASS']); etc... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: User Logon Procedure Fails
Harlequin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Another day another problem. This time it appears that users are able to enter their details but I get a query execution error with the following section of code: /* Verify Login */ $sql = SELECT UserFirstName,UserID,UserPassword FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]'; If your user id is of type int you don't need the quotes around the value. But you definitely need quotes around your POST array key: $sql = SELECT UserFirstName,UserID,UserPassword FROM RegisteredMembers WHERE UserID = $_POST['TXT_UserID']; $result = mysql_query($sql) or die (couldn't select database); $num = mysql_num_rows($result); if ($num == 1) file://Login Name Was Found { $sql = SELECT UserID FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]' AND password=UserPassword('$_POST[TXT_UserPassword]'); You already have the user id ($_POST[TXT_UserID]), so why select it? Regards, Torsten $result2 = mysql_query($sql) or die(Couldn't execute query #2.); The next to last line is bugging me though. AND password= etc. because I have a variable declared earlier in the logon page for TXT_UserPassword and the UserPassword column exists but where in the hell is password...? Is this another of MySQLs on the fly variables...? -- - Michael Mason Arras People www.arraspeople.co.uk - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unable to retrieve value from database and echo on screen
I know, I know. Simple stuff to you guys, but I am learning more every day and believe me - I won't be recommending Bill's software for web development from now on :) /* Select User's First Name From Table */ $sql = SELECT UserFirstName FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]'; $result5 = mysql_query($sql) or die (couldn't select UserID from database); $num = mysql_num_rows($result); /* Welcome Registsred Member */ echo welcome to the registered members area ; echo ($result); I know iit has the data in there as I echoed an entire error statement and the correct user was selected. I just need to echo a different field value from those alraedy selected previously in the page. -- - Michael Mason Arras People www.arraspeople.co.uk - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dissappering Tables Server wide
Hi All. What would cause all the tables in all the databases to be deleted all at once? TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: web page output as we go
Jason, et al -- ...and then Jason Barnett said... % % Is there any way I can tell the web browser to start trickling the data % onto the page? % % As Torsten so kindly pointed out to me before, your friend is the % flush() function: % http://www.php.net/flush Aha! It looks like it's just my browser, since even flush() didn't help me but when I started poking around under Win (ugh!) both Mozilla and IE scrolled the data down the screen. The manual seems to frown upon using flush(), so I'll experiment with it some more, but I suspect that Linux/LYNX simply won't do this for me and that's no big deal since few of our customers use it. % % Jason Thanks for the pointing :-) :-D -- David T-G [EMAIL PROTECTED] http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgpsz8lKlPcZV.pgp Description: PGP signature
Re: [PHP] Unable to retrieve value from database and echo on screen
/* Select User's First Name From Table */ $sql = SELECT UserFirstName FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]'; $result5 = mysql_query($sql) or die (couldn't select UserID from database); $num = mysql_num_rows($result); /* Welcome Registsred Member */ echo welcome to the registered members area ; echo ($result); There are a few problems here: 1) Your query result is assigned to $result5 but then you use $result in the mysql_num_rows() function. 2) You never fetch any information. You need something like $row = mysql_fetch_array($result5). 3) You're trying to print the query result when you should be printing the fetched information like so echo $row['UserFirstName']; Hope that helps, Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] compiling 3'd party php modules
Hello, I need to compile sqlanywhere module. http://www.sybase.com/detail/1,6904,1019698,00.html Theyr documentation says that i need to compile the whole php source tree. That is not an easy task on gentoo with ebuilds. Well i managed to do that. But maybe there is an easier way? To compile seperate modules and just load them with dl() function.. Thanks Bye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP doesnt work!
PHP relies on a server side interpreter that normally runs under an apache web server and you reference those files by having your browser fetch those files through a URL that maps to your PHP files, beginning with something like http://hostname.com/program.php. If you opened the files directly with your browser, you have bypassed the apache server and PHP interpreter, which of course, would not allow the PHP code to actually be executed. Not real sure this is what you might have done, but it's a common mistake. good luck, Warren Vail [EMAIL PROTECTED] -Original Message- From: Jason Barnett [mailto:[EMAIL PROTECTED] Sent: Saturday, July 03, 2004 9:13 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: PHP doesnt work! Gmo Baez wrote: Hello, I have a Freebsd server 5.2.1 with Apache 2.0.48 and PHP 4.3.4. After the installation everything looks normal, but after i created some PHP web files to test it, I found that PHP is not working. When i open de PHP document with the browser i only receive a blank page. But if i check the source code, all the PHP code is in there. What kind of code are you using to test the script? Not every script outputs html... have you tried phpinfo()? It is unclear what your problem may be from what you've given us. Jason -- 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] PHP5 / MySQLi + Apache: InnoDB access problems
L.S. I can't get PHP5 / MySQLi (improved mysql) working. Here's the setup: Linux apache-2.0.50 mozilla mysql-4.1.3 php-5.0.0RC3 (configured --with-mysqli --without-mysql) All are compiled and installed as per their respective configure files and Makefiles (PHP developers take note: php needed a manual addition of ZEND_EXTRA_LIBS=-lstdc++ after configure ran). I have mysqld and apache running. Mysqld runs as user mysql.mysql, Apache runs as www.sys. MySQL itself and Apache itself are working flawlessly, and I've been using them for some time now. Also php is installed with proper php.ini that's basically the one from the package (php-medium.ini). From Mozilla, this script for instance runs fine: --- html headtitle phptest.php -- PHP / MySQLi Test /title/head body ? echo $_SERVER['HTTP_USER_AGENT']; phpinfo(); ? /body /html --- Then in Mozilla I load this script, mysqli.php: --- html head title mysqli.php -- PHP / MySQLi Test /title /head body ?php $database=MYDB; $table=`TABLE`; $link = mysqli_connect( localhost, root, , $database ); if (!$link) { printf( Punable to connect to the MySQL server at this time; error: %s/P, mysqli_connect_error() ); exit(); } $sql = select * from . $table . ;; if (($result=mysqli_query( $link, $sql ))) { echo( font face=fixed ); while ( $row = mysqli_fetch_assoc( $result ) ) { printf( %s %sbr, $row[Name], $row[Date] ); } echo( /font ); mysqli_free_result( $result ); } else { echo( Perror getting table . $table . /P); } mysqli_close( $link ); ? /body /html --- This script, mysqli.php, runs (mutatis mutandis) fine from Mozilla under the 'old' PHP4/MySQL. With this PHP5/MySQL setup however, it doesn't produce any output. Tailing the Apache error.log there's this message: InnoDB: unable to create /usr/local/lib/mysql-4.1.3/var//innodb.status.1731: Permission denied 040704 17:11:20 Can't init databases [Sun Jul 04 17:11:21 2004] [notice] child pid 1728 exit signal Segmentation fault (11) This is with the mysql data-directory (/usr/local/lib/mysql/var/) set at permissions 755 (or 700 or 711), and user mysql.myqsl (as per the docs). So then I tried /usr/local/lib/mysql/var/ at permissions 777. Now the Apache error.log has: 040704 17:14:24 InnoDB: Operating system error number 13 in a file operation. InnoDB: The error means mysqld does not have the access rights to InnoDB: the directory. InnoDB: File name /usr/local/lib/mysql-4.1.3/var/ibdata1 InnoDB: File operation call: 'open'. InnoDB: Cannot continue operation. But still no go. I've played with other permissions, also for the Apache User/Group, libphp5.so, different parameters for mysqli_connect(), and quite a few other things, but I'm getting nowhere. The above script by the way does run OK with PHP5/MySQLi if I run it with php from the command-line, but only if the mysqld server is /not/ running. I suppose that's at least normal behaviour. I'm ready for any good suggestions and tips. Thanks for your time. BJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: web page output as we go
David T-G wrote: Jason, et al -- ...and then Jason Barnett said... % Is there any way I can tell the web browser to start trickling the data % onto the page? % % As Torsten so kindly pointed out to me before, your friend is the % flush() function: % http://www.php.net/flush Aha! It looks like it's just my browser, since even flush() didn't help me but when I started poking around under Win (ugh!) both Mozilla and IE scrolled the data down the screen. The manual seems to frown upon using flush(), so I'll experiment with it some more, but I suspect that Linux/LYNX simply won't do this for me and that's no big deal since few of our customers use it. The effect is going to be different for everyone, as you've found out, based upon their browser, ISP, your server setup, etc. The output could be cached and held at any point along the way from you to them regardless if you're using flush() in your PHP script. If you use tables, it'll be handled differently, too. Some browsers won't render a table until the /table is received. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Something like strip_tags?
i'd like to be able to strip only one type of HTML tag from a web document (a), but to do that with strip_tags(), i'd have to predict every possible HTML tag that might be used, except for the one i want to strip, and put those in the allowable tags parameter. That's why I was hoping someone knew of a better way to accomplish this. Any suggestions are welcome. Thanks in advance, ~j --- http://www.dailymedication.com - Everything you didn't know you needed until you went there and said to yourself, What did I do before I visited DailyMedication.com? and another part of you said, It does not matter. _ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Something like strip_tags?
Jason Paschal wrote: i'd like to be able to strip only one type of HTML tag from a web document (a), but to do that with strip_tags(), i'd have to predict every possible HTML tag that might be used, except for the one i want to strip, and put those in the allowable tags parameter. That's why I was hoping someone knew of a better way to accomplish this. Any suggestions are welcome. Something like $new_text = preg_replace('!a.*/a!iU','',$old_text); will get rid of the a tags and leave everything else. Honestly, though, if you're allowing everything else, why not allow these? I can just as easily set up the text with decorations to make it look like a link and give it an onclick action to load another page... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Including files within a class definition
Hi, I have a program which generates classes based on table structures within a database. However there are a few times where I need to put custom methods within these generated classes. I want to be able to do this but php gives an error for the following include class generatedClass { var $this = 0; function here($strVar){ echo 'this'; } include (extended_methods_stuff.php); } I know that I can probably extend this class to add the extra functionality however the other generated classes rely on the name of this class so I cannot just extend this class and it's name cannot change. Is there any way to have an include prior to the class being parsed? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] For/Next Help Needed
I'm using Jack's PHP FormMail script, and I need to change it. I know very little abou PHP, but here's what I very much need to do right away. I need the script to send the same hard coded message to each of 10 people. All of the email addresses do not need to be in the To field. Only the intended recipient needs to be there. So, I see the code as something line this: $recipient[1] = [EMAIL PROTECTED]; $recipient[2] = [EMAIL PROTECTED]; ... $recipient[n] = [EMAIL PROTECTED]; Then, something like this: for ($z=0;$zcount($val);$z++) mail($recipient[z$], $subject, $message, $headers); I realize there is a lot to it, but I'm stuck and in a time jam. If someone has another script that might be easier to modify, or if there is a script that already accomplishes this task, PLEASE let me know. You can see I'm a super novice. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unable to retrieve value from database and echo on screen
Larry E . Ullman wrote: /* Select User's First Name From Table */ $sql = SELECT UserFirstName FROM RegisteredMembers WHERE UserID='$_POST[TXT_UserID]'; $result5 = mysql_query($sql) or die (couldn't select UserID from database); $num = mysql_num_rows($result); /* Welcome Registsred Member */ echo welcome to the registered members area ; echo ($result); There are a few problems here: 1) Your query result is assigned to $result5 but then you use $result in the mysql_num_rows() function. 2) You never fetch any information. You need something like $row = mysql_fetch_array($result5). 3) You're trying to print the query result when you should be printing the fetched information like so echo $row['UserFirstName']; Hope that helps, Larry Larry: It's good to see you posting here. I'm on page 30 of your book and find it to be very helpful and extremely well written. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] For/Next Help Needed
mcp6453 wrote: I'm using Jack's PHP FormMail script, and I need to change it. I know very little abou PHP, but here's what I very much need to do right away. I need the script to send the same hard coded message to each of 10 people. All of the email addresses do not need to be in the To field. Only the intended recipient needs to be there. So, I see the code as something line this: $recipient[1] = [EMAIL PROTECTED]; $recipient[2] = [EMAIL PROTECTED]; ... $recipient[n] = [EMAIL PROTECTED]; Then, something like this: for ($z=0;$zcount($val);$z++) mail($recipient[z$], $subject, $message, $headers); for($z=0;$zcount($recipient);$z++) { mail($recipient[$z],$subject,$message,$headers); } -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session tracking and multiple form updates
Hello, I am working on a web site that is available only over HTTPS and am using session tracking. So far I am only saving the person's display name (different then login), site role and e-mail address in the $_SESSION data. The rest of the site is dynamic, now the question is on three particular pages the user fills in a form and hit's submit. Now at the moment on each page is a hidden variable containing a db primary key for which the data is getting updated. I know that hidden values are not a good idea since the user can change them ... so I was going to store the hidden value in a $_SESSION variable but then the problem is ... what happens when the user has two - three windows open and they are updating two - three different items. Each having it's own db key ? If I stored the key in a session variable the last one opened would over write any previous one. I hope I explained this correctly ... multiple updates and access to the site is allowed and can not be changed. Thanks. Michael. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] For/Next Help Needed
John W. Holmes wrote: mcp6453 wrote: I'm using Jack's PHP FormMail script, and I need to change it. I know very little abou PHP, but here's what I very much need to do right away. I need the script to send the same hard coded message to each of 10 people. All of the email addresses do not need to be in the To field. Only the intended recipient needs to be there. So, I see the code as something line this: $recipient[1] = [EMAIL PROTECTED]; $recipient[2] = [EMAIL PROTECTED]; ... $recipient[n] = [EMAIL PROTECTED]; Then, something like this: for ($z=0;$zcount($val);$z++) mail($recipient[z$], $subject, $message, $headers); for($z=0;$zcount($recipient);$z++) { mail($recipient[$z],$subject,$message,$headers); } Thanks, John. That's helpful. I'm not sure what other problems I'm going to run into. It looks like I may have to put the whole script inside the for loop. What is the difference between this code and using a foreach command? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] For/Next Help Needed
for($z=0;$zcount($recipient);$z++) { mail($recipient[$z],$subject,$message,$headers); } What is the difference between this code and using a foreach command? Nothing, really. Using a foreach() simply means you don't have to keep up with the $z count variable... foreach($recipient as $email) { mail($email,$subject,$message,$headers); } -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session tracking and multiple form updates
Hi, Monday, July 5, 2004, 1:27:12 PM, you wrote: MG Hello, MG I am working on a web site that is available only over HTTPS and am MG using session tracking. MG So far I am only saving the person's display name (different then MG login), site role and e-mail address in the $_SESSION data. MG The rest of the site is dynamic, now the question is on three particular MG pages the user fills in a form and hit's submit. Now at the moment on MG each page is a hidden variable containing a db primary key for which the MG data is getting updated. MG I know that hidden values are not a good idea since the user can change MG them ... so I was going to store the hidden value in a $_SESSION MG variable but then the problem is ... what happens when the user has two MG - three windows open and they are updating two - three different items. MG Each having it's own db key ? MG If I stored the key in a session variable the last one opened would over MG write any previous one. MG I hope I explained this correctly ... multiple updates and access to the MG site is allowed and can not be changed. MG Thanks. MG Michael. store it in the session like: $_SESSION[session_id()]['dbkey'] = $dbkey; then get it back with $dbkey = (isset($_SESSION[session_id()]['dbkey']))? $_SESSION[session_id()]['dbkey'] : 0; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session tracking and multiple form updates
Michael Gale wrote: Now at the moment on each page is a hidden variable containing a db primary key for which the data is getting updated. I know that hidden values are not a good idea since the user can change them ... so I was going to store the hidden value in a $_SESSION variable but then the problem is ... what happens when the user has two - three windows open and they are updating two - three different items. Each having it's own db key ? What's the impact if the variable is changed? There should still be some validation of the value on the server side, so changing it should be detected. If it's changed to another valid ID that the user has access to, then who cares if they change it? If they change it to an invalid value, you're validation will catch it and spit out an error. If they try to change it to an ID that they do not have access to, you're validation should catch and log that, also. The security problem isn't in the hidden form elements, it's in how you're validating them. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session tracking and multiple form updates
Tom Rogers wrote: store it in the session like: $_SESSION[session_id()]['dbkey'] = $dbkey; then get it back with $dbkey = (isset($_SESSION[session_id()]['dbkey']))? $_SESSION[session_id()]['dbkey'] : 0; That doesn't negate the problem of people having more than one window open and editing records in each one. The session_id() is going to be the same for each window, so the last window opened will contain the ID and you'll lose the id for the other windows. The OP could generate a code using uniqid() and store that in a hidden field. Then associate the database id to the unique code generated in the session... $code = uniqid(); $_SESSION['dbkey'][$code] = $id; input type=hidden name=code value=?=$code? -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals - www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session tracking and multiple form updates
Hello, Thanks for the replies ... I valid all the data and input from the user. So if the user changes the value nothing bad will happen: I have in the code: if ($var != $hiddenvar) { e-mail blank saying Blank has been updated } That is it ... I made a mistake in my last e-mail .. the value of hidden is not a DB primary key just a important column in a table. Michael. On Sun, 04 Jul 2004 23:41:24 -0400 John W. Holmes [EMAIL PROTECTED] wrote: Michael Gale wrote: Now at the moment on each page is a hidden variable containing a db primary key for which the data is getting updated. I know that hidden values are not a good idea since the user can change them ... so I was going to store the hidden value in a $_SESSION variable but then the problem is ... what happens when the user has two- three windows open and they are updating two - three different items. Each having it's own db key ? What's the impact if the variable is changed? There should still be some validation of the value on the server side, so changing it should be detected. If it's changed to another valid ID that the user has access to, then who cares if they change it? If they change it to an invalid value, you're validation will catch it and spit out an error. If they try to change it to an ID that they do not have access to, you're validation should catch and log that, also. The security problem isn't in the hidden form elements, it's in how you're validating them. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php