php-general Digest 6 May 2004 13:06:59 -0000 Issue 2747 Topics (messages 185491 through 185521):
Class Help 185491 by: PHP Email List 185494 by: Curt Zirzow Re: remove soap header 185492 by: Chhai T Re: HTTP_REFERER ... ? 185493 by: David Robley 185509 by: Tristan.Pretty.risk.sungard.com Re: Regular Expression 185495 by: Tumurbaatar S. strip comments from HTML? 185496 by: Justin French 185501 by: Marius Dascalu 185505 by: David T-G 185506 by: David T-G 185510 by: Marius Dascalu 185516 by: Tom Rogers 185518 by: John W. Holmes Class Help Extended 185497 by: PHP Email List 185498 by: Richard Harb 185500 by: PHP Email List 185502 by: Torsten Roehr Re: how does PHP handle kerberos authentication? 185499 by: Burhan Khalid I can't make session work, but cookie can, why? 185503 by: TooooOld 185504 by: Torsten Roehr Login page 185507 by: Erik Gjertsen 185511 by: Jay Blanchard 185513 by: Angelo Zanetti 185514 by: Jay Blanchard 185520 by: Erik Gjertsen File management. 185508 by: Carles Xavier Munyoz Baldó 185512 by: Jay Blanchard Way OT MySql Update 185515 by: Dave Carrera 185519 by: John W. Holmes 185521 by: Angelo Zanetti gifs, icons etc 185517 by: Brent Clark 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] ----------------------------------------------------------------------
--- Begin Message ---Why is it in a class, so important for you to initialize your $variables? In the following example, I have my class started and then took out or atleast commented my "var $variable" and the code still does what it should. So why is it so important that you initialize these variables this way? [:::CODE:::] <?php class test { //var $z; <------This is the part I don't see the relevance in doing as here this is commented out and the class works as expected. function z(){ $this->z = 250; return $this->z; } function test1($a,$b){ $this->tested = $a + $b; return $this->tested; } function test2($c,$d,$e,$f){ $this->test2 = $c + $d; $this->test3 = $this->test1($e,$f) + $this->test2 + $this->z(); return $this->test3; } } $whynot = new test(); echo $whynot->test2(10,10,10,20); ?> [:::/CODE:::] I don't have any real use for this code to work after this point, I'm just trying to generate somesort of script that makes sense to me. As my previous attempt at jumping feet first into classes failed miserably. I guess I'm just confused on why you would want to initialize a variable and not assign a value to it if you know what it is? Like in my Database class, I made my username, pass, localhost, etc variables initiated with their values, but kept getting errors from mysql that I didn't have a "Valid" mysql resource. I guess after reading this in 4 books and on php.net, they all do this but none of them go into WHY it's so important. Part of my concern is that I'm being told, or atleast reading that you initialize them for the class, but if the class structure is already in place for the variables inside each method to be local to that class, I don't see the relevance for initialization. Man this sounds dumb cuz I just know there's a reason, I just can't find it. Any help would be appreciated. Thanks. Wolf
--- End Message ---
--- Begin Message ---* Thus wrote PHP Email List ([EMAIL PROTECTED]): > Why is it in a class, so important for you to initialize your $variables? > > In the following example, I have my class started and then took out or > atleast commented my "var $variable" and the code still does what it should. > So why is it so important that you initialize these variables this way? > > [:::CODE:::] > <?php > class test { > > //var $z; <------This is the part I don't see > the relevance in doing as here this is > commented out and the class works as expected. > ... > > I guess I'm just confused on why you would want to initialize a variable and > not assign a value to it if you know what it is? Like in my Database class, > I made my username, pass, localhost, etc variables initiated with their > values, but kept getting errors from mysql that I didn't have a "Valid" > mysql resource. I guess after reading this in 4 books and on php.net, they > all do this but none of them go into WHY it's so important. Defining a variable in a class using 'var $z', keeps some sort of structure for the class. PHP has always kept the creation of variables simple for the programmer and classes arn't an exception. You will find, however, that most classes you'll see will have the variables defined. PHP5 actuall expands on the declaration of variables, it adds a few new ways to define variables: class test { /* Accessable to any body */ public $public_var; /* Only accessable to any instance of 'test' or any class that inherits 'test' via Extends */ protected $protected_var; /* Only accessable to instances of class 'test' */ private $private_var; /* the static keyword makes this variable shared accoss all instances of 'test'. and is applied to either public, protexted or private scope */ static public $static_var; These keywords can also be applied to the declaration of functions ie: public function test_func() { } Curt -- "I used to think I was indecisive, but now I'm not so sure."
--- End Message ---
--- Begin Message ---What are you using to access the soap server? If you use the modules such as NuSOAP or SOAP built in for PHP5 you wouldn't have to worry about the response header. Chhai "Diana Castillo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Any ideas how to remove the soap header from the xml response? > > -- > Diana Castillo > Global Reservas, S.L. > C/Granvia 22 dcdo 4-dcha > 28013 Madrid-Spain > Tel : 00-34-913604039 > Fax : 00-34-915228673 > email: [EMAIL PROTECTED] > Web : http://www.hotelkey.com > http://www.destinia.com
--- End Message ---
--- Begin Message ---[EMAIL PROTECTED] (Tristan Pretty) wrote in news:OF19FCC4A7.F49C9B83-ON80256E8B.00544E7D- [EMAIL PROTECTED]: > if ($_SERVER['HTTP_REFERER'] == 'http://www.mysite.com/') { > // Stuff > } > > Now why does this not work? > I wanna asign varibales based on certain referers... > but this is not working? > > Any ideas why? HTTP_REFERER is empty because the page was not called from a link? Or HTTP_REFERER is empty because the browser doesn't supply the value? Echo the variable and see what you get.
--- End Message ---
--- Begin Message ---I echoed it, and got a blank variable... We ahve full admin rights on my server, and the one we're checking the referer from... Basically, our system has an exsiting user database, and we wanna allow users to loging as per usual, and but allow them (and only them) to veiw pages on the new server... I just thought that htt_referer was the easiest way to do that, as I only wanna let people in, who have signed in on the first server first.. Am I making any snece? David Robley <[EMAIL PROTECTED]> 06/05/2004 02:46 To [EMAIL PROTECTED] cc Subject [PHP] Re: HTTP_REFERER ... ? [EMAIL PROTECTED] (Tristan Pretty) wrote in news:OF19FCC4A7.F49C9B83-ON80256E8B.00544E7D- [EMAIL PROTECTED]: > if ($_SERVER['HTTP_REFERER'] == 'http://www.mysite.com/') { > // Stuff > } > > Now why does this not work? > I wanna asign varibales based on certain referers... > but this is not working? > > Any ideas why? HTTP_REFERER is empty because the page was not called from a link? Or HTTP_REFERER is empty because the browser doesn't supply the value? Echo the variable and see what you get. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ********************************************************************* The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. ***********************************************************************
--- End Message ---
--- Begin Message ---Because the substrings can contain any char-s including commas. Also I use reg exp not for splitting only but for validating whether whole string and the substrings are correctly formatted. Using reg exp requires much less coding than traditional programming. > > Why not just strip out the braces and explode on commas? That'll be > lighter than regexps any day. If the input is guaranteed to be > formatted the way you describe, you could do something like: > > $out = explode(",", substr($in, 1, strlen($in)-2)); > > -- > Paul Chvostek <[EMAIL PROTECTED]> > it.canada http://www.it.ca/ > Free PHP web hosting! http://www.it.ca/web/
--- End Message ---
--- Begin Message ---Hi,
This isn't working: $text = preg_replace('/<!--(.*)-->/','',$text);
Can someone advise what characters I need to escape, or whatever to get it going?
TIA
--- Justin French http://indent.com.au
--- End Message ---
--- Begin Message ------ Justin French <[EMAIL PROTECTED]> wrote: > Hi, > > This isn't working: > $text = preg_replace('/<!--(.*)-->/','',$text); > > Can someone advise what characters I need to escape, > or whatever to get > it going? > > TIA > > --- > Justin French > http://indent.com.au > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Hi, You must escape "-" (minus sign) because is a meta-character for regular expressions. See http://www.php.net/manual/en/pcre.pattern.syntax.php. Your line of code might be: <CODE> $text = preg_replace('/<!\-\-(.*)\-\->/','',$text); </CODE> This line of code, if you are parsing HTML file row by row, strips only "one line" comments. Comments spanned on multiple lines are unaffected. HTH Marius __________________________________ Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs http://hotjobs.sweepstakes.yahoo.com/careermakeover
--- End Message ---
--- Begin Message ---Justin -- ...and then Justin French said... % % Hi, Hi! % % This isn't working: % $text = preg_replace('/<!--(.*)-->/','',$text); % % Can someone advise what characters I need to escape, or whatever to get % it going? Well, what do you want it to do? On my system that properly replaces the entire commented string with nothing. An example which puts something else there instead: <?php $text = "<body>\n<h1>Hi</h1>\n<!-- foo --></body>\n" ; $text = preg_replace('/<!--(.*)-->/','blah',$text) ; print "text is .$text.\n"; ?> This yields text is .<body> <h1>Hi</h1> blah</body> . as expected. Note that since you're just replacing the entire comment with '' you needn't bother with the () around whatever may be in the middle, too. % % TIA % % --- % Justin French % http://indent.com.au HTH & HAND :-D -- David T-G [EMAIL PROTECTED] http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!pgpvjRxbrMbZS.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---Marius, et al -- ...and then Marius Dascalu said... % % --- Justin French <[EMAIL PROTECTED]> wrote: % > % > This isn't working: % > $text = preg_replace('/<!--(.*)-->/','',$text); ... % % Hi, Hello! % % You must escape "-" (minus sign) because is a % meta-character for regular expressions. See What? No. % http://www.php.net/manual/en/pcre.pattern.syntax.php. From that same link: Part of a pattern that is in square brackets is called a "character class". In a character class the only meta-characters are: \ general escape character ^ negate the class, but only if the first character - indicates character range ] terminates the character class So you only have to worry about a minus if you're in a [a-z] range, and even then you can put a minus in without having to resort to backslashes. % Your line of code might be: % % <CODE> % $text = preg_replace('/<!\-\-(.*)\-\->/','',$text); % </CODE> Then, again, it might not ;-) % % This line of code, if you are parsing HTML file row by % row, strips only "one line" comments. Comments spanned % on multiple lines are unaffected. Agreed. Let's leave that to the student to work out, shall we? :-) % % HTH % % Marius HTH & HAND :-D -- David T-G [EMAIL PROTECTED] http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!pgpOw4LsPySuX.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ------ David T-G <[EMAIL PROTECTED]> wrote: > Marius, et al -- > > ...and then Marius Dascalu said... > % > % --- Justin French <[EMAIL PROTECTED]> wrote: > % > > % > This isn't working: > % > $text = preg_replace('/<!--(.*)-->/','',$text); > ... > % > % Hi, > > Hello! > > > % > % You must escape "-" (minus sign) because is a > % meta-character for regular expressions. See > > What? No. > > > % > http://www.php.net/manual/en/pcre.pattern.syntax.php. > > From that same link: > > Part of a pattern that is in square brackets is > called a "character > class". In a character class the only > meta-characters are: > > > \ > > general escape character > > > > ^ > > negate the class, but only if the first > character > > > - > > indicates character range > > > > ] > > terminates the character class > > So you only have to worry about a minus if you're in > a [a-z] range, and > even then you can put a minus in without having to > resort to backslashes. > > > % Your line of code might be: > % > % <CODE> > % $text = > preg_replace('/<!\-\-(.*)\-\->/','',$text); > % </CODE> > > Then, again, it might not ;-) > > > % > % This line of code, if you are parsing HTML file > row by > % row, strips only "one line" comments. Comments > spanned > % on multiple lines are unaffected. > > Agreed. Let's leave that to the student to work > out, shall we? :-) > > > % > % HTH > % > % Marius > > > HTH & HAND > > :-D > -- > David T-G > [EMAIL PROTECTED] > http://justpickone.org/davidtg/ Shpx gur > Pbzzhavpngvbaf Qrprapl Npg! > > > ATTACHMENT part 2 application/pgp-signature K, my fault (but the script is functional in both variants - tested in SciTE). That is 2nd faulty response sended by me to list. At the 3rd I will unsubscribe :-) HAND __________________________________ Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs http://hotjobs.sweepstakes.yahoo.com/careermakeover
--- End Message ---
--- Begin Message ---Hi, Thursday, May 6, 2004, 3:02:16 PM, you wrote: JF> Hi, JF> This isn't working: JF> $text = preg_replace('/<!--(.*)-->/','',$text); JF> Can someone advise what characters I need to escape, or whatever to get JF> it going? JF> TIA JF> --- JF> Justin French JF> http://indent.com.au you may need '/<!--.*?-->/s' if your comment spans lines -- regards, Tom
--- End Message ---
--- Begin Message ---From: "Justin French" <[EMAIL PROTECTED]> > This isn't working: > $text = preg_replace('/<!--(.*)-->/','',$text); > > Can someone advise what characters I need to escape, or whatever to get > it going? $text = preg_replace('/<!--.*-->/su','',$text); The 's' modifier will allow the expression to pick up multi-line comments by allowing the dot character to match newlines and the 'u' modifier makes it 'ungreedy', so that if you have <!-- comment 1 --> HTML example <!-- comment 2 --> only the comments themselves are matched and not everything from the first "<!--" to the last "-->". ---John Holmes...
--- End Message ---
--- Begin Message ---First off thanks Curt for the attempt at explaining what the purpose was for those, I'm convinced enough to start doing that since that's what the "pros" use. :) However, I know have another concern. As for as class security. Is it wrong to initialize the static variables for my database assignment class ie.. [..Example..] <?php class db_connection { var $user = "dbuser"; var $pass = "dbpass"; var $db = "db"; var $host = "localhost"; var $connection; ....?> [../Example..] or should I still be using the normal seperate file for those values ie... [..Example2..] <?php include_once("dbconn.php"); class db_connection { var $user; var $pass; var $db; var $host; var $connection; ...?> [../Example..] Where in the included file I have the variables listed as $user = username; $pass = password; etc..... The Class files that I am creating are going to be seperate "template" includes if you will where they also are going to be "include_once()" items aswell. Is it over redundant to have both of the files includes? Any help is much appreciated as I'm still learning this exciting language! :) TIA, Wolf
--- End Message ---
--- Begin Message ---More often than not it's a good thing to assign 'default' values to class variables like that. In this case though I've observed that common practice is to get the user/pass values from a config file and pass them along as variables when creating an instance of the class. Classes are most beneficial if you can take your class include file from one project to the next and just pass along different parameters and they work. Including user/pass would force you to edit/change those values on every project you use that class in. HTH Richard Thursday, May 6, 2004, 7:56:01 AM, thus was written: > First off thanks Curt for the attempt at explaining what the purpose was for > those, I'm convinced enough to start doing that since that's what the "pros" > use. :) > However, I know have another concern. As for as class security. Is it wrong > to initialize the static variables for my database assignment class ie.. > [..Example..] > <?php > class db_connection { > var $user = "dbuser"; > var $pass = "dbpass"; > var $db = "db"; > var $host = "localhost"; > var $connection; ....?>> > [../Example..] > or should I still be using the normal seperate file for those values ie... > [..Example2..] > <?php > include_once("dbconn.php"); > class db_connection { > var $user; > var $pass; > var $db; > var $host; > var $connection; ...?>> > [../Example..] > Where in the included file I have the variables listed as > $user = username; > $pass = password; > etc..... > The Class files that I am creating are going to be seperate "template" > includes if you will where they also are going to be "include_once()" items > aswell. Is it over redundant to have both of the files includes? > Any help is much appreciated as I'm still learning this exciting language! > :) > TIA, > Wolf
--- End Message ---
--- Begin Message ---> More often than not it's a good thing to assign 'default' values to > class variables like that. > > In this case though I've observed that common practice is to get the > user/pass values from a config file and pass them along as variables > when creating an instance of the class. > > Classes are most beneficial if you can take your class include file > from one project to the next and just pass along different parameters > and they work. Including user/pass would force you to edit/change > those values on every project you use that class in. > > HTH > Richard True, I do realize that classes are "suppose" to be as portable as possible. I just wasn't sure from a security stand point that if the dbconfig file is in with the dbclass file, if it really made a difference since they are both off of the webtree and being "included" if you will. :) I much appreciate the feed back. Thanks for your time. Man PHP ROCKS!! However I only feel that I've only begun to scratch the surface of it's power. I still haven't done file uploads and directory listings yet, soon Danielson.....soon. And the sad part is...sigh, I've just finished a b.e.a.utiful login script for one of my client's and now I need to rewrite it so that it's a class, cuz heck I want it for my site too. $smiley = ":)"; include_once(evil_laugh.php); echo $laugh $smiley; //Echo'd: Muuuhahahahahah :) Thanks again. :} Wolf
--- End Message ---
--- Begin Message ---"Richard Harb" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > More often than not it's a good thing to assign 'default' values to > class variables like that. > > In this case though I've observed that common practice is to get the > user/pass values from a config file and pass them along as variables > when creating an instance of the class. I'm defining things like DB access values as constants in my config file rather than as global variables. This way I can make absolutely sure that they are not accidently changed anywhere in my application. As constants are globally available you don't need to pass them to every class method that is using them. <?php class db_connection { var $user = CONFIG_DB_USER; var $pass = CONFIG_DB_PASSWORD; var $db = CONFIG_DB_NAME; var $host = CONFIG_DB_HOST; var $connection; ....?> Regards, Torsten > > Classes are most beneficial if you can take your class include file > from one project to the next and just pass along different parameters > and they work. Including user/pass would force you to edit/change > those values on every project you use that class in. > > HTH > Richard
--- End Message ---
--- Begin Message --- Bing Du wrote:I need to code kerberos authentication in PHP. Like in Perl, it has Authen::Krb5 module. How the similar tasks are done in PHP? I've searched (all site) 'kerberos' on www.php.net but did not find any information that I need.
http://www.faqts.com/knowledge_base/view.phtml/aid/777
--- End Message ---
--- Begin Message ---I can't make session work if I set "session.use_trans_sid = 0", or I must append SID to the URI to get session work. And, the cookie works OK. Here is my test code: <?php session_start(); if (!isset($_SESSION['test'])) { // First time you call it. echo "<P>No session found - starting a session now."; $_SESSION['test'] = "welcome back!"; } else { // Subsequent times you call it echo "<P>Session found - ".$_SESSION['test']; echo "<P>Sessions are working correctly</P>"; } //not work echo "<P><A HREF=session-test.php>Reload this page 1</A></P>"; echo "<P><A HREF=session-test.php?random=" . rand(1,10000) . ">Reload this page 2</A></P>"; echo "<P><A HREF=session-test.php?random=" . rand(1,10000) . SID . ">Reload this page 3</A></P>"; //only this URL works OK. echo "<P><A HREF=session-test.php?" . SID . ">Reload this page 4</A></P>"; ?> My system: system: Windows 2000 Apache 1.3.29(and also tested under Apache 2.0.43) PHP 4.3.5(SAPI) php.ini settings: Directive Value -------------------------------------------- session.auto_start Off session.bug_compat_42 Off session.bug_compat_warn On session.cache_expire 180 session.cache_limiter nocache session.cookie_domain no value session.cookie_lifetime 3600 session.cookie_path c:\cookie session.cookie_secure Off session.entropy_file no value session.entropy_length 0 session.gc_divisor 1000 session.gc_maxlifetime 1440 session.gc_probability 1 session.name PHPSESSID PHPSESSID session.referer_check no value session.save_handler files session.save_path c:\cookie session.serialize_handler php session.use_cookies On session.use_only_cookies Off session.use_trans_sid Off Thanks for any advice.
--- End Message ---
--- Begin Message ---"Tooooold" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I can't make session work if I set "session.use_trans_sid = 0", or I must > append SID to the URI to get session work. > And, the cookie works OK. > > Here is my test code: > > <?php > session_start(); > > if (!isset($_SESSION['test'])) { // First time you call it. > echo "<P>No session found - starting a session now."; > $_SESSION['test'] = "welcome back!"; > > } else { // Subsequent times you call it > echo "<P>Session found - ".$_SESSION['test']; > echo "<P>Sessions are working correctly</P>"; > } > > file://not work > echo "<P><A HREF=session-test.php>Reload this page 1</A></P>"; > echo "<P><A HREF=session-test.php?random=" . rand(1,10000) . ">Reload this > page 2</A></P>"; > echo "<P><A HREF=session-test.php?random=" . rand(1,10000) . SID . ">Reload > this page 3</A></P>"; > > file://only this URL works OK. > echo "<P><A HREF=session-test.php?" . SID . ">Reload this page 4</A></P>"; > ?> If this works, where's your problem? Regards, Torsten > > My system: > system: Windows 2000 Apache 1.3.29(and also tested under Apache 2.0.43) > PHP 4.3.5(SAPI) > > php.ini settings: > Directive Value > -------------------------------------------- > session.auto_start Off > session.bug_compat_42 Off > session.bug_compat_warn On > session.cache_expire 180 > session.cache_limiter nocache > session.cookie_domain no value > session.cookie_lifetime 3600 > session.cookie_path c:\cookie > session.cookie_secure Off > session.entropy_file no value > session.entropy_length 0 > session.gc_divisor 1000 > session.gc_maxlifetime 1440 > session.gc_probability 1 > session.name PHPSESSID PHPSESSID > session.referer_check no value > session.save_handler files > session.save_path c:\cookie > session.serialize_handler php > session.use_cookies On > session.use_only_cookies Off > session.use_trans_sid Off > > > Thanks for any advice.
--- End Message ---
--- Begin Message ---I have made a login page but I got an error on line 1..... Can some one please help me to solve the problem <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>LoggInn</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php # login.php if (isset($_POST['submit'])) { // Handel the form. require_once('../../../Connections/innlogging.php'); mysql_select_db($database_innlogging, $innlogging); $query_logginn = "SELECT usrid, username, password1 FROM users"; $logginn = mysql_query($query_logginn, $innlogging) or die(mysql_error()); $row_logginn = mysql_fetch_assoc($logginn); $totalRows_logginn = mysql_num_rows($logginn); // Crating a function for escaping the data. function escape_data ($data) { global $dbc; //meed the connection if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } 1........ return mysql_real_escape_string($data, $dbc); } // end of function $message = NULL; // Create an enpty new variable // Check for a username if (empty($_POST['username'])) { $username = FALSE; $message .= '<p>You forgot to enter your username!</p>'; } else { $username = escape_data($_POST['username']); } // Check for a Password if (empty($_POST['password1'])) { $password1 = FALSE; $message .= '<p>You forgot to enter your password!</p>'; } else { $password1 = escape_data($_POST['password1']); } if ($username && $password1) { //if everything's ok. //Retrieve the user_id an name for that username and password combination. $query = "SELECT usrid name FROM users WHERE username='$username' AND password1=PASSWORD('$password1')"; $result = @mysql_query ($query); //Run the query $row = mysql_fetch_array ($result, MYSQL_NUM); //Return a record, if applicable. if ($row) { //A record was pulled from the database. //Set the cookies & redirect. setcookie ('name', $row[1]); setcookie ('usrid', $row[1]); header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/Loggedin.php"); exit(); //Quit the script } else { // No record matched the query. $message = '<p>The username and password entered do not match on file.</p>'; } mysql_close(); // Close the databaseconection. } else { $message = '<p>Please try again.</p>'; } } // End of themail submitconditional. //Print the error message if ther is one if (isset($message)) { echo '<font color="red">', $message, '</font>'; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset><legend>Enter your information in the form below:</legend> <p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p> <p><b>Password:</b> <input type="password1" name="password1" size="20" maxlength="20" /></p> <div align="center"><input type="submit" name="submit" value="Login" /></div> </fieldset> </form> </body> </html> Thanks Erik Gjertsen
--- End Message ---
--- Begin Message ---[snip] I have made a login page but I got an error on line 1..... [/snip] What is line 1? and what error do you get?
--- End Message ---
--- Begin Message ---# login.php?? -----Original Message----- From: Erik Gjertsen [mailto:[EMAIL PROTECTED] Sent: Thursday, May 06, 2004 12:43 PM To: [EMAIL PROTECTED] Subject: [PHP] Login page I have made a login page but I got an error on line 1..... Can some one please help me to solve the problem <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>LoggInn</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php # login.php if (isset($_POST['submit'])) { // Handel the form. require_once('../../../Connections/innlogging.php'); mysql_select_db($database_innlogging, $innlogging); $query_logginn = "SELECT usrid, username, password1 FROM users"; $logginn = mysql_query($query_logginn, $innlogging) or die(mysql_error()); $row_logginn = mysql_fetch_assoc($logginn); $totalRows_logginn = mysql_num_rows($logginn); // Crating a function for escaping the data. function escape_data ($data) { global $dbc; //meed the connection if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } 1........ return mysql_real_escape_string($data, $dbc); } // end of function $message = NULL; // Create an enpty new variable // Check for a username if (empty($_POST['username'])) { $username = FALSE; $message .= '<p>You forgot to enter your username!</p>'; } else { $username = escape_data($_POST['username']); } // Check for a Password if (empty($_POST['password1'])) { $password1 = FALSE; $message .= '<p>You forgot to enter your password!</p>'; } else { $password1 = escape_data($_POST['password1']); } if ($username && $password1) { //if everything's ok. //Retrieve the user_id an name for that username and password combination. $query = "SELECT usrid name FROM users WHERE username='$username' AND password1=PASSWORD('$password1')"; $result = @mysql_query ($query); //Run the query $row = mysql_fetch_array ($result, MYSQL_NUM); //Return a record, if applicable. if ($row) { //A record was pulled from the database. //Set the cookies & redirect. setcookie ('name', $row[1]); setcookie ('usrid', $row[1]); header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/Loggedin.php"); exit(); //Quit the script } else { // No record matched the query. $message = '<p>The username and password entered do not match on file.</p>'; } mysql_close(); // Close the databaseconection. } else { $message = '<p>Please try again.</p>'; } } // End of themail submitconditional. //Print the error message if ther is one if (isset($message)) { echo '<font color="red">', $message, '</font>'; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset><legend>Enter your information in the form below:</legend> <p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p> <p><b>Password:</b> <input type="password1" name="password1" size="20" maxlength="20" /></p> <div align="center"><input type="submit" name="submit" value="Login" /></div> </fieldset> </form> </body> </html> Thanks Erik Gjertsen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -------------------------------------------------------------------- Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
--- End Message ---
--- Begin Message ---[snip] # login.php?? [/snip] If that is in fact line 1 then the # sign is the problem. Use either // or /* */ style comments.
--- End Message ---
--- Begin Message ---I forgot the error messages: Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home2/erik/gjertsen-www/Skole22/Loggin/login.php on line 28 Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home2/erik/gjertsen-www/Skole22/Loggin/login.php on line 28 and 1.. is line 28 there error massages com. thanks Erik Gjertsen. "Erik Gjertsen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have made a login page but I got an error on line 1..... > > Can some one please help me to solve the problem > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <title>LoggInn</title> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> > </head> > > <body> > <?php > # login.php > if (isset($_POST['submit'])) { // Handel the form. > require_once('../../../Connections/innlogging.php'); > > mysql_select_db($database_innlogging, $innlogging); > $query_logginn = "SELECT usrid, username, password1 FROM users"; > $logginn = mysql_query($query_logginn, $innlogging) or die(mysql_error()); > $row_logginn = mysql_fetch_assoc($logginn); > $totalRows_logginn = mysql_num_rows($logginn); > > > // Crating a function for escaping the data. > function escape_data ($data) { > global $dbc; //meed the connection > if (ini_get('magic_quotes_gpc')) { > $data = stripslashes($data); > } > 1........ return mysql_real_escape_string($data, $dbc); > } // end of function > > $message = NULL; // Create an enpty new variable > // Check for a username > if (empty($_POST['username'])) { > $username = FALSE; > $message .= '<p>You forgot to enter your username!</p>'; > } else { > $username = escape_data($_POST['username']); > } > // Check for a Password > if (empty($_POST['password1'])) { > $password1 = FALSE; > $message .= '<p>You forgot to enter your password!</p>'; > } else { > $password1 = escape_data($_POST['password1']); > } > if ($username && $password1) { //if everything's ok. > //Retrieve the user_id an name for that username and password combination. > $query = "SELECT usrid name FROM users WHERE username='$username' AND > password1=PASSWORD('$password1')"; > $result = @mysql_query ($query); //Run the query > $row = mysql_fetch_array ($result, MYSQL_NUM); //Return a record, if > applicable. > if ($row) { //A record was pulled from the database. > //Set the cookies & redirect. > setcookie ('name', $row[1]); > setcookie ('usrid', $row[1]); > header ("Location: http://" . $_SERVER['HTTP_HOST'] . > dirname($_SERVER['PHP_SELF']) . "/Loggedin.php"); > exit(); //Quit the script > } else { // No record matched the query. > $message = '<p>The username and password entered do not match on > file.</p>'; > } > mysql_close(); // Close the databaseconection. > } else { > $message = '<p>Please try again.</p>'; > } > } // End of themail submitconditional. > > //Print the error message if ther is one > if (isset($message)) { > echo '<font color="red">', $message, '</font>'; > } > > ?> > > <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> > <fieldset><legend>Enter your information in the form below:</legend> > <p><b>User Name:</b> <input type="text" name="username" size="10" > maxlength="20" value="<?php if > (isset($_POST['username'])) echo $_POST['username']; ?>" /></p> > > <p><b>Password:</b> <input type="password1" name="password1" size="20" > maxlength="20" /></p> > <div align="center"><input type="submit" name="submit" value="Login" > /></div> > </fieldset> > </form> > </body> > </html> > > > Thanks > Erik Gjertsen
--- End Message ---
--- Begin Message ---Hi Is there any php set for file management ? The only thing I want is a set of PHP functions that allows me add and remove lines from a file. Is there any thing done ? Greetings. --- Carles Xavier Munyoz Baldó [EMAIL PROTECTED] http://www.unlimitedmail.net/ ---
--- End Message ---
--- Begin Message ---[snip] Is there any php set for file management ? The only thing I want is a set of PHP functions that allows me add and remove lines from a file. Is there any thing done ? [/snip] See http://www.php.net/fopen
--- End Message ---
--- Begin Message ---Hi List, Sorry for this being way off topic but I need some help with a MySql sql update. I have a date column and have added a datenew column and want to do a table wide update to make datenew 1 year more that date. So: Date = 2003-05-06 Datenew should be 2004-05-06 Each row should update the datenew for 1 year more that date col value. Thank you for any help you may give and once again sorry for being ot. Dave Carrera --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.677 / Virus Database: 439 - Release Date: 04/05/2004
--- End Message ---
--- Begin Message ---From: "Dave Carrera" <[EMAIL PROTECTED]> > I have a date column and have added a datenew column and want to do a table > wide update to make datenew 1 year more that date. UPDATE yourtable SET datenew = dateorig + INTERVAL 1 YEAR; Although... if "datenew" is always one year more than "dateorig", why would you need another column? SELECT dateorig, dateorig + INTERVAL 1 YEAR AS datenew, ... FROM ... ?? ---John Holmes...
--- End Message ---
--- Begin Message ---tried the mysql manual??? its got the date_Add function DATE_ADD(date,INTERVAL expr type) from manual: mysql> SELECT DATE_ADD("1999-01-01", INTERVAL 1 DAY); -> 1999-01-02 mysql> SELECT DATE_ADD("1999-01-01", INTERVAL 1 HOUR); -> 1999-01-01 01:00:00 If you use really incorrect dates, the result is NULL. If you add MONTH, YEAR_MONTH, or YEAR and the resulting date has a day that is larger than the maximum day for the new month, the day is adjusted to the maximum days in the new month: mysql> SELECT DATE_ADD('1998-01-30', INTERVAL 1 MONTH); -> 1998-02-28 hope this helps Angelo -----Original Message----- From: John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Thursday, May 06, 2004 2:22 PM To: Dave Carrera; [EMAIL PROTECTED] Subject: Re: [PHP] Way OT MySql Update From: "Dave Carrera" <[EMAIL PROTECTED]> > I have a date column and have added a datenew column and want to do a table > wide update to make datenew 1 year more that date. UPDATE yourtable SET datenew = dateorig + INTERVAL 1 YEAR; Although... if "datenew" is always one year more than "dateorig", why would you need another column? SELECT dateorig, dateorig + INTERVAL 1 YEAR AS datenew, ... FROM ... ?? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -------------------------------------------------------------------- Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Technikon or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
--- End Message ---
--- Begin Message ---Hi all I would like to know if any body has a url for free some icons and, or small pics that can be used in a site \ page development. I was looking at a project call dotproject. And I noticed a lot of kewl small pics. I dont want to infringe on any licenses etc Kind Regards Brent Clark
--- End Message ---