RE: [PHP] mail() silly question
As a general rule, use ' ' for literal strings and for strings you want escaped characters and such to take effect. Example: echo 'foo\nbar' will echo foo\nbar where as echo foo\nbar will echo foo bar Hope this helped. Brian Seymour Zend Certified Engineer AeroCoreProductions http://www.aerocore.net/ Cell: (413) 335-2656 -Original Message- From: Rodrigo Poblanno Balp [mailto:[EMAIL PROTECTED] Sent: Saturday, September 01, 2007 9:00 AM To: php-general@lists.php.net Subject: [PHP] mail() silly question I have a question that might be too silly for those of you who are PHP gurus. Here it comes: I had a mail (specifically in the headers) function call like this: $header = ; $header .= 'From: [EMAIL PROTECTED]; $header .= 'MIME-Version: 1.0\r\n; $header .= 'Content-type: text/html; charset=iso-8859-1\r\n; $header .= Reply-To: .utf8_decode($nombreVar). .utf8_decode($apellidosVar).$mailVar\r\n; $header .= X-Mailer: PHP/.phpversion().\r\n; $header .= X-Priority: 1; and the mail(...) function always returned TRUE, but the mail was NOT sent. After hours of... trial/error debugging, I noticed from an example that it should be: $header = ; $header .= 'From: [EMAIL PROTECTED]' . \r\n; $header .= 'MIME-Version: 1.0' . \r\n; $header .= 'Content-type: text/html; charset=iso-8859-1' . \r\n; $header .= Reply-To: .utf8_decode($nombreVar). .utf8_decode($apellidosVar).$mailVar\r\n; $header .= X-Mailer: PHP/.phpversion().\r\n; $header .= X-Priority: 1; Question: Why? What's the real difference between $header .= 'From: [EMAIL PROTECTED]' . \r\n; and $header .= 'From: [EMAIL PROTECTED]; ? If somebody knows, please let me know! Thank you in advance. -- 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] Authentication script working in firefox but strange results in ie7
I mostly use Firefox but still I check to make sure everything works in IE7 and other browsers equally as well. I had strange results here. I have a simple login form(user/pass field and submit button). I have the actual login request script in a common php file. I have an Authentication class that handles my auth stuff. With the code the way it is, it works perfectly in firefox. However, in IE7 when you log in it shows the restricted stuff but as soon as you navigate anywhere else you no longer have access. If you login again then it works fine just like the first time you logged in using firefox. Now if you change $_SESSION['uid']== to !isset($_SESSION['uid']) then it works perfectly on both browsers. Anyhow, rifle through the code -- just something to think about. Anybody else have a similar issue before? Web Code: Restricted stuff: ?php if ($_SESSION['uid']==){ $ops-postLogin($e); }else{ ? Logged in stuff(Restricted stuff) ?php } ? Common snippet: if ($_POST[action]==login){ $auth = new Authentication($host,$user,$pass,dbname,http://aerocore.net/;); if ($auth-verifyCreds($_POST['username'],$_POST['password'],base_contributors ,id)) { $_SESSION['uid'] = $auth-retId; $auth-failSafe(); break; } } Authentication: class Authentication extends SQL { public $errorMsg; public $retId; public $clean = array(); public $fail; public function __construct($host,$user,$pass,$dbname = null,$fail) { parent::__construct($host,$user,$pass,$dbname = null); $this-fail=$fail; } public function failSafe() { header(Location: {$this-fail}); } final public function sanitizeLoginCreds($user, $pass) { $this-clean['username']=strip_tags($user); $this-clean['password']=strip_tags($pass); if (!ctype_alnum($this-clean['username'])){ $this-clean['username']=; } if (!ctype_alnum($this-clean['password'])){ $this-clean['password']=; } } final public function verifyCreds($user, $pass, $table, $retVal = null) { $this-sanitizeLoginCreds($user,$pass); //$this-result = $this-query(SELECT * FROM $table where username='{$this-clean[username]}' and password='{$this-clean[password]}'); if ($this-fetchNumRows(SELECT * FROM $table where username='{$this-clean[username]}' and password='{$this-clean[password]}') == 0) { $this-errorMsg = Incorrect Username/Password Combo; $this-failSafe(); return false; } else { if (isset($retVal)) { $this-retId = $this-fetchArray(SELECT * FROM $table where username='{$this-clean[username]}' and password='{$this-clean[password]}'); $this-retId = $this-retId[$retVal]; } return true; } } final public function secureLogout() { $_SESSION = array(); session_destroy(); $this-failSafe(); } public function __destruct(){} } Brian Seymour Zend Certified Engineer AeroCoreProductions http://www.aerocore.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HELP - I have tried to unsubscribe from this listmutipletimes but cannot.
Patrick, did you trying going to http://www.php.net/unsub.php yet? =D Brian Seymour AeroCoreProductions http://www.aerocore.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: php framework, large site
Depends, is time a factor. If not, why not write your own framework. Brian Seymour AeroCoreProductions http://www.aerocore.net/ -Original Message- From: Crayon Shin Chan [mailto:[EMAIL PROTECTED] Sent: Sunday, June 17, 2007 1:53 PM To: php-general@lists.php.net Subject: Re: [PHP] Re: php framework, large site On Monday 18 June 2007 00:12, Robert Cummings wrote: Good reasons to write your own: It's an extremely inefficient use of precious time. Inventing the wheel over and over. Surely out of the billions of half-baked to fully-baked frameworks out there must be something suitable for everyone. How far would you take it? Write your own PHP, why not write your own OS, heck build your own computer while you're at it :) -- Crayon -- 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] When and when not to use ' and
I noticed today when I was using mysql_fetch_array something weird happened. Database: | id | 1 Code: $colVal = id; $foo=mysql_fetch_array($someresult, MYSQL_ASSOC); Now all I wanted to do was get the value of 1 into the variable $bar. Please assume $someresult was the direct product of mysql_query(select * from thistable);. $bar = $foo['$colVal']; // didn't work $bar = $foo['{$colVal}']; // didn't work $bar = $foo[$colVal]; // worked $bar = $foo['id']; // obviously worked What I don't understand is why the first or second option didn't work. Can anybody shed some light on this? Brian Seymour AeroCoreProductions http://www.aerocore.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] OOB problem, super stumped.
Jim, I put the link identifier back and made your recommended changes and now everything works perfect. Can't thank you enough. Is the reason you have to call the parents __construct() method because the open mysql connection only exists within the scope of the object it was created in, unless specified otherwise(calling parents constructor)? Brian Seymour AeroCoreProductions http://www.aerocore.net/ -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 30, 2007 12:02 AM To: Brian Seymour Cc: 'php php' Subject: Re: [PHP] OOB problem, super stumped. You didn't call the __construct() method of your parent. The above code, should be like this public function __construct($host,$user,$pass,$dbname = null) { parent::__construct($host,$user,$pass,$dbname); echo Auth constructed; } You were forgetting to call to the parent and have it initialize the DB connection. In the second part, the $auth-verifyCreds() call, it didn't create a valid db connection to pass as the second arg to the mysql_query() call. And by not passing the $this-conx as the second arg, you are telling it to use the most recently opened mysql connection. Hope this clears up why it was failing on the latter mysql_query() calls. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OOB problem, super stumped.
I am super stumped. This works fine separately but when I put everything together it breaks. I has an authenticate class and a sql class. However I always get the same error. SQL class. ?php class SQL { public $host; public $user; public $pass; public $conx; public $db; public $dbname; public $query; public $result; public $fetchedArray; public $nRows; public function __construct($host,$user,$pass,$dbname = null){ $this-host=$host; $this-user=$user; $this-pass=$pass; $this-conx=$this-connection($host,$user,$pass); if (!is_null($dbname)){ $this-selectDb($dbname); } } final public function connection($host,$user,$pass){ $this-conx=mysql_connect($host,$user,$pass) or die(mysql_error()); } final public function selectDb($db){ $this-db=mysql_select_db($db); } final public function query($query){ $this-result=mysql_query($query, $this-conx); echo mysql_error(); echo $query; return $this-result; } final public function fetchArray($query){ $this-result=$this-query($query); $this-fetchedArray=mysql_fetch_array($this-result,MYSQL_ASSOC); return $this-fetchedArray; } final public function makeArray($query){ $this-curArray=mysql_fetch_array($query,MYSQL_ASSOC); return $this-curArray; } final public function numRows($result) { $this-nRows=mysql_num_rows($result); return $this-nRows; } public function __destruct(){ if (isset($this-connection)){ mysql_close($this-connection); } } } ? Authenticate class ?php class Authentication extends SQL { public $errorMsg; public function __construct(){echo Auth constructed;} final public function verifyCreds ($user, $pass, $table) { $result = $this-query(SELECT * FROM $table where $user='$pass'); if ($this-numRows($this-result) == 0) { $this-errorMsg = Incorrect Username/Password Combo; return false; } else { // debugging lines \/ echo login good!; // debugging lines /\ return true; } } public function __destruct(){} } ? Normal page. ?php / * common.php * * project: Renegades Revenge * programmer: Brian Seymour / // autoload classes function __autoload($class_name) { require_once 'includes/classes/class_' . strtolower($class_name) . '.php'; } // initialize Renegades Revenge database $database = new SQL($host,$user,$pass,aerocor_renegade); // login if (isset($_GET['login'])) { $auth = new Authentication($host,$user,$pass,aerocor_renegade); if ($auth-verifyCreds($_POST['username'],$_POST['password'],players)) { echo logged in good!; } } ? The form is just 2 fields. Username and password. I get this error. Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/aerocor/public_html/rr/includes/classes/class_sql.php on line 52 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/aerocor/public_html/rr/includes/classes/class_sql.php on line 71 I put some simple query and display code in the constructor for the SQL class and it outputted from the database with no problem, that's whats weird. Any help would be great, thanks. Brian
RE: [PHP] OOB problem, super stumped. (resolved)
Strangely enough the only thing that was wrong was: $this-result=mysql_query($query, $this-conx); I removed $this-conx so it looked like $this-result=mysql_query($query); And now everything works perfect. I also fixed the line you recommended I fix. I must have overlooked that =D. But anyhow, problem solved. Brian Seymour AeroCoreProductions http://www.aerocore.net/ -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 29, 2007 10:51 PM To: Brian Seymour Cc: 'php php' Subject: Re: [PHP] OOB problem, super stumped. On Tue, 2007-05-29 at 22:36 -0400, Brian Seymour wrote: I am super stumped. This works fine separately but when I put everything together it breaks. I has an authenticate class and a sql class. However I always get the same error. The following line: $this-conx=$this-connection($host,$user,$pass); Completely buggers things up. The connection() method doesn't return a value. So the next query has a null resource and so fails and generates the error you are seeing. You've already set the value of $this-conx in your connection() method so even if you did return the resource identifier it would be redundant. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- 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] Too many records to display in one web page
Jim, Your totally right, must have slipped my mind. Brian Seymour AeroCoreProductions http://www.aerocore.net/ -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: Sunday, May 27, 2007 1:07 AM To: Brian Seymour Cc: php-general@lists.php.net Subject: Re: [PHP] Too many records to display in one web page Brian Seymour wrote: Eduardo, The best way to do it is on both a php and sql level. Use sql's limit keyword in your query to return only the amount of records you want. For instance, page 1 will have LIMIT 0, 9 in the query. Page 2 will have LIMIT 10, 19. Then you can simply use *_fetch_array and a foreach(maybe) to iterate through all the values. If you want to have the the amount of records dynamically generate then either have a asdf.php?min=0max=9 or just do min = (page * 10) - 10 and max = (page * 10) - 1. Many different ways to do this. However I find this one to be the most efficient. problem with your example. Limit is not used that way Check out this page for further explanation http://dev.mysql.com/doc/refman/5.0/en/select.html#id3064319 Here is something I whipped together for this as an example ?php $page = 1; $rowsPerPage = 10; $start = 0; if ( isset($_GET['page']) is_numeric($_GET['page']) $_GET['page'] = $page ) { $start = ($rowsPerPage * floor($_GET['page']) ); } $SQL = select * from table LIMIT {$start}, {$rowsPerPage} display results... ? Let me know if I completely confused you. I am often confusing... Jim Lucas Hope this helped. Brian Seymour AeroCoreProductions http://www.aerocore.net/ -Original Message- From: Eduardo Vizcarra [mailto:[EMAIL PROTECTED] Sent: Saturday, May 26, 2007 7:18 PM To: php-general@lists.php.net Subject: [PHP] Too many records to display in one web page Hi All I am developing a web site that interacts with a MySQL database. When I run a query and display the records in a web page, this can become a problem because there might be too many records to be displayed in one single web page so I am trying to divide the total number of records and display them in multiple pages. Let's say, if the query returns 100 records then I would like to display the first 10 records and then put a navigation bar where I can go to the next 10 or return to the previous 10 records Is this done at a SQL or PHP level ? any experience on doing this ? Thanks a bunch Eduardo -- 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] Too many records to display in one web page
Eduardo, The best way to do it is on both a php and sql level. Use sql's limit keyword in your query to return only the amount of records you want. For instance, page 1 will have LIMIT 0, 9 in the query. Page 2 will have LIMIT 10, 19. Then you can simply use *_fetch_array and a foreach(maybe) to iterate through all the values. If you want to have the the amount of records dynamically generate then either have a asdf.php?min=0max=9 or just do min = (page * 10) - 10 and max = (page * 10) - 1. Many different ways to do this. However I find this one to be the most efficient. Hope this helped. Brian Seymour AeroCoreProductions http://www.aerocore.net/ -Original Message- From: Eduardo Vizcarra [mailto:[EMAIL PROTECTED] Sent: Saturday, May 26, 2007 7:18 PM To: php-general@lists.php.net Subject: [PHP] Too many records to display in one web page Hi All I am developing a web site that interacts with a MySQL database. When I run a query and display the records in a web page, this can become a problem because there might be too many records to be displayed in one single web page so I am trying to divide the total number of records and display them in multiple pages. Let's say, if the query returns 100 records then I would like to display the first 10 records and then put a navigation bar where I can go to the next 10 or return to the previous 10 records Is this done at a SQL or PHP level ? any experience on doing this ? Thanks a bunch Eduardo -- 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] What does mean?
Heredoc is truly a great thing. You'll learn to love heredoc whenever you have tons of stuff you need to print instead of escaping php. A great example is output that comes from classes, where you can't break the class into multiple code blocks. Just don't forget that heredoc end part has to be on the very next line with no whitespace to start. Confusing at times. Cheers! -BRIAN Ok, let's gather some stats to see how many people actually use the heredoc syntax. I created this quick little form to gather the data. It's takes 2 seconds (literally) - vote here: http://thril.uark.edu/heredoc/ I'm interested in knowing if this is used a lot. If it is, then I may consider tying it into my code (if it calls for it). ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Text Messaging
I know vtext.com sends email to phones. Perhaps using the mail function you could just send a message to [EMAIL PROTECTED] and they would get the message. To my knowledge this is a free service and works with all phone providers since they do the message for you. Just a thought. Hope this helps, Brian -Original Message- From: Philip Thompson [mailto:[EMAIL PROTECTED] Sent: Thursday, April 19, 2007 10:28 AM To: php General List Subject: [PHP] PHP Text Messaging Hi. I have attempted to look at the archives for this, but keep getting redirected back to the main PHP site when I click on the archive link. With that said, does anyone know of any good resources for sending text messages using PHP? I have Googled this topic and found a few, but find it hard to judge which ones are good. I have also looked at the SAM package, but wasn't sure how much that is being used by the community. Thanks in advance, ~Philip -- 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