RE: [PHP] Stricter Error Checking?

2009-09-23 Thread Samrat Kar
Better use mysqli rather mysql. It supports all new features of MySQL.

I solved the problem in following manner.

1. Detect the return value of mysqli->query function.
2. If it is FALSE get the error no, error msg etc and store in a Mysql table
for further review. You can also write it in a error log file.

Example...

/* Part of MYSQLI class */

public function Query($sql, $flag = 0) {
$my = new mysqli($this->host,$this->user,$this->pass,$this->db);
if(mysqli_connect_errno()) {
   $this->conn_err_no = mysqli_connect_errno();
   $this->conn_err_msg = mysqli_connect_error();
   return FALSE;
}
//$this->QueryLog(addslashes($sql));
$arr1 = explode(" ", $sql);
$queryType = $arr1[0];
$result = $my->query($sql);
if($result === FALSE) {
$this->query_err_no = $my->errno;
$this->query_err_msg = $my->error;
$this->sqlstate = $my->sqlstate;
$this->ErrorLog(addslashes($sql));
}
else {
$this->QueryLog(addslashes($sql));
}

if($queryType == "SELECT" || $queryType == "SHOW" || $queryType ==
"DESCRIBE" || $queryType == "EXPLAIN" || $queryType == "CALL") {
if($result) {
$num_row = $result->num_rows;
$num_col = $result->field_count;
if($num_row == 0)
$ret = NULL;
if($num_row == 1 && $num_col == 1) {
$record = $result->fetch_row();
if($flag == 1) 
 $ret = array($record[0]);
else
 $ret = $record[0];
}
if($num_row == 1 && $num_col > 1) {
if($flag == 1)
 $ret = array($result->fetch_array());
else
 $ret = $result->fetch_row();
}
if($num_row > 1 && $num_col == 1) {
$retarr = array();
while($record = $result->fetch_array()) {
array_push($retarr, $record[0]);
}
$ret = $retarr;
}
if($num_row > 1 && $num_col > 1) {
$retarr = array();
while($record = $result->fetch_array()) {
array_push($retarr, $record);
}
$ret = $retarr;
}
if($num_row > 0) {
$this->field_list = $result->fetch_fields();
}
}
else {
return FALSE;
}
}
else {
if($result === FALSE)
return FALSE;
if($queryType == "UPDATE" || $queryType == "INSERT" ||
$queryType == "REPLACE" || $queryType == "DELETE") {
$ret = $my->affected_rows;
if($queryType == "INSERT")
$this->last_insert_id = $my->insert_id;
}
}

return $ret;
}

private function QueryLog($query) {
$my = new mysqli($this->host,$this->user,$this->pass,$this->db);
if(mysqli_connect_errno()) {
   $this->conn_err_no = mysqli_connect_errno();
   $this->conn_err_msg = mysqli_connect_error();
   return FALSE;
}
$ts = time();
$sql = "INSERT INTO pi_global.tblquerylog
VALUES('','$ts','$query')";
$my->query($sql);
$my->close();
}

private function ErrorLog($query) {
$my = new mysqli($this->host,$this->user,$this->pass,$this->db);
if(mysqli_connect_errno()) {
   $this->conn_err_no = mysqli_connect_errno();
   $this->conn_err_msg = mysqli_connect_error();
   return FALSE;
}
$ts = time();
$errno = $this->query_err_no;
$errmsg = addslashes($this->query_err_msg);
$state = $this->sqlstate;
$sql = "INSERT INTO pi_global.tblerrorlog
VALUES('','$ts','$query','$errno','$errmsg','$state')";
$my->query($sql);
$my->close();
}

Regards,

Samrat Kar
FRD, BARC

Tel: 022-25597295
Alternate Email: esam...@yahoo.com

-Original Message-
From: Tim Legg [mailto:kc0...@yahoo.com] 
Sent: Wednesday, September 23, 2009 11:42 PM
To: php-general@lists.php.net
Subject: [PHP] Stricter Error Checking?

Hello,

I just spent way, way to much time trying to debug code due to a misnamed
element.  Here is a simplified example of the problem I dealt with.


$test = "SELECT * FROM `Materials` WHERE `Part_Number` = '125664'";
$result = mysql_query($test,$handle);
if(!$result)
{
die('Error: ' . mysql_error());
}
$row = mysql_fetch_array($result);
echo $row['Number'];

After retyping the code 3 or 4 times over the course of the morning, I
finally found where the problem w

Re: [PHP] User Account Management

2009-09-23 Thread Waynn Lue
Thanks so much for all the feedback!  Ben's comment was something that
prompted this discussion to begin with internally, in that we didn't want to
reinvent the wheel, nor make a mistake in the security implenetation of our
solution.  I've forwarded this thread back internally, and we'll take this
as a jumping off point for how to build our system.

Waynn


Re: [PHP] Re: session.gc_maxlifetime

2009-09-23 Thread Ralph Deffke
finaly we went with a custom cooky handling, however the customers
requirements where two days.

if u are shure that the server is still the same hardware like it has been 6
years ago then it might be some client stuff, however if there are other
applications, pages running (virtual servers) then it would still be to
consider. mamory and resource management is deep os. again I wouldn't trust
for that amount of session livetime.

I dont think, putting it down to three hours would help much.

and of course, it could be client side also. Can't you figure out the
clients?
and keep in mind that a lot of people connect to UMTS rigzt now, these
systems deconnect on idle lines and reconect without the users even know it.
Also a lot of lines change IP address at midnihgt.

cheers
ralph_def...@yahoo.de

"Tom Worster"  wrote in message
news:c6e00521.12d98%...@thefsb.org...
> there's a need for long timeouts in this app but could perhaps be reduced
> from 6 to 3 hours.
>
> the sessions are cookie based using php's 'file' handler and
> session.cookie_lifetime=0. the server appears to have plenty of free
memory
> and appears not to have swapped in nearly a year of uptime. load averages
> indicate a pretty quiet server. there are currently 170 kbyte total in 90
> serialized session files which is typical and not a memory load. the
> distribution of modification times doesn't indicate heavy activity: ~20
> files in the last 15 minutes and 35 in the last hour.
>
> so i think the os can handle this. plus the app ran for 6 years before
> anyone reported being prematurely logged off. i'm looking for other
> possibilities: odd browser behavior, network trouble, ...
>
>
> are there any browsers that have configurable cookie handling policy such
> that they time out a cookie?
>
> one web site i use displays this curious message: "For your protection,
> sessions are open for a limited period of time on our website. Please
> sign-on again. NOTE: Your browser may also limit secure connection time,
and
> automatically log you out independent of our timeout procedure."
>
> that could be referring to browsers timing out an ssl connection. or
perhaps
> the cookie?
>
>
> btw: when you said in your email you wouldn't trust a long gc_maxlifetime,
> and you would only use a cookie-based solution for long session. did you
> mean that you wouldn't trust php's cookie-based session handler? and you
> would use a custom handler instead?
>
>
> On 9/22/09 4:46 PM, "Ralph Deffke"  wrote:
>
> > Hi Tom,
> >
> > in sometimes 2001 I did have incidences with those things, and as I
remember
> > over the past years there where some trouble with operating systems and
> > stuff. This part is very deep inside the os. I would expect that this is
> > still to consider. I also would check, if this occurs on very busy/low
> > memory server.
> >
> > If I would programm the garbage collection clean up part, and if the
server
> > is about to run out of memory, I would kill sessions being longer time
idle
> > even when they are not yet as old as it is set in the gc_maxlifetime.
This
> > would be far better then shutting down the whole server just because
there a
> > 100 of idle sessions waiting to get used again.
> >
> > as u mention a maxlivetime of 6h I would bet, that this is the problem.
I
> > would not trust such a long lifetime at all.
> >
> > If sessions have to be active such a long time, I would see only cooky
based
> > solutions
> >
> > let me know, what u did investigate on this.
> >
> > ralph_def...@yahoo.de
> >
> >
> > "Tom Worster"  wrote in message
> > news:c6deae55.12cae%...@thefsb.org...
> >> thank you, Ralph!
> >>
> >> i'm going to be bold and assume that tom at punkave dot com is right
> > despite
> >> that the report was discarded.
> >>
> >> i got a complaint from a client about some users reporting being logged
> > out
> >> with rather short periods of inactivity. but session.gc_maxlifetime is
set
> >> to 6 hours so i don't think that's the source of the problem.
> >>
> >>
> >> On 9/22/09 4:17 PM, "Ralph Deffke"  wrote:
> >>
> >>> Hi Tom,
> >>>
> >>> i did find this in the bug reports, its pretty new and should be an
> > answer.
> >>>
> >>> http://news.php.net/php.doc.bugs/2653
> >>>
> >>> ralph_def...@yahoo.de
> >>>
> >>>
> >>> "Tom Worster"  wrote in message
> >>> news:c6de9eee.12c8d%...@thefsb.org...
>  i'm not 100% sure what the manual means when it says...
> 
>  session.gc_maxlifetime integer
>  session.gc_maxlifetime specifies the number of seconds after which
data
> >>> will
>  be seen as 'garbage' and cleaned up. Garbage collection occurs during
>  session start.
> 
>  what event exactly does the "after which" here refer to?
> 
>  i'd like to think that it means that a session is eligible for gc no
> >>> sooner
>  than session.gc_maxlifetime seconds after the most recent access
(read
> > or
>  write) to that session. but it seems dangerously presumptuous to
assume
> >>> that
>  this is

Re: [PHP] Re: session.gc_maxlifetime

2009-09-23 Thread Tom Worster
there's a need for long timeouts in this app but could perhaps be reduced
from 6 to 3 hours.

the sessions are cookie based using php's 'file' handler and
session.cookie_lifetime=0. the server appears to have plenty of free memory
and appears not to have swapped in nearly a year of uptime. load averages
indicate a pretty quiet server. there are currently 170 kbyte total in 90
serialized session files which is typical and not a memory load. the
distribution of modification times doesn't indicate heavy activity: ~20
files in the last 15 minutes and 35 in the last hour.

so i think the os can handle this. plus the app ran for 6 years before
anyone reported being prematurely logged off. i'm looking for other
possibilities: odd browser behavior, network trouble, ...


are there any browsers that have configurable cookie handling policy such
that they time out a cookie?

one web site i use displays this curious message: "For your protection,
sessions are open for a limited period of time on our website. Please
sign-on again. NOTE: Your browser may also limit secure connection time, and
automatically log you out independent of our timeout procedure."

that could be referring to browsers timing out an ssl connection. or perhaps
the cookie?


btw: when you said in your email you wouldn't trust a long gc_maxlifetime,
and you would only use a cookie-based solution for long session. did you
mean that you wouldn't trust php's cookie-based session handler? and you
would use a custom handler instead?


On 9/22/09 4:46 PM, "Ralph Deffke"  wrote:

> Hi Tom,
> 
> in sometimes 2001 I did have incidences with those things, and as I remember
> over the past years there where some trouble with operating systems and
> stuff. This part is very deep inside the os. I would expect that this is
> still to consider. I also would check, if this occurs on very busy/low
> memory server.
> 
> If I would programm the garbage collection clean up part, and if the server
> is about to run out of memory, I would kill sessions being longer time idle
> even when they are not yet as old as it is set in the gc_maxlifetime. This
> would be far better then shutting down the whole server just because there a
> 100 of idle sessions waiting to get used again.
> 
> as u mention a maxlivetime of 6h I would bet, that this is the problem. I
> would not trust such a long lifetime at all.
> 
> If sessions have to be active such a long time, I would see only cooky based
> solutions
> 
> let me know, what u did investigate on this.
> 
> ralph_def...@yahoo.de
> 
> 
> "Tom Worster"  wrote in message
> news:c6deae55.12cae%...@thefsb.org...
>> thank you, Ralph!
>> 
>> i'm going to be bold and assume that tom at punkave dot com is right
> despite
>> that the report was discarded.
>> 
>> i got a complaint from a client about some users reporting being logged
> out
>> with rather short periods of inactivity. but session.gc_maxlifetime is set
>> to 6 hours so i don't think that's the source of the problem.
>> 
>> 
>> On 9/22/09 4:17 PM, "Ralph Deffke"  wrote:
>> 
>>> Hi Tom,
>>> 
>>> i did find this in the bug reports, its pretty new and should be an
> answer.
>>> 
>>> http://news.php.net/php.doc.bugs/2653
>>> 
>>> ralph_def...@yahoo.de
>>> 
>>> 
>>> "Tom Worster"  wrote in message
>>> news:c6de9eee.12c8d%...@thefsb.org...
 i'm not 100% sure what the manual means when it says...
 
 session.gc_maxlifetime integer
 session.gc_maxlifetime specifies the number of seconds after which data
>>> will
 be seen as 'garbage' and cleaned up. Garbage collection occurs during
 session start.
 
 what event exactly does the "after which" here refer to?
 
 i'd like to think that it means that a session is eligible for gc no
>>> sooner
 than session.gc_maxlifetime seconds after the most recent access (read
> or
 write) to that session. but it seems dangerously presumptuous to assume
>>> that
 this is the case.
 
 what do you take it to mean?
 
 
>>> 
>>> 
>> 
>> 
> 
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stricter Error Checking?

2009-09-23 Thread Jim Lucas
Tim Legg wrote:
> Hello,
> 
> I just spent way, way to much time trying to debug code due to a misnamed 
> element.  Here is a simplified example of the problem I dealt with.
> 
> 
>   $test = "SELECT * FROM `Materials` WHERE `Part_Number` = '125664'";
>   $result = mysql_query($test,$handle);
>   if(!$result)
>   {
>   die('Error: ' . mysql_error());
>   }
>   $row = mysql_fetch_array($result);
>   echo $row['Number'];
> 
> After retyping the code 3 or 4 times over the course of the morning, I 
> finally found where the problem was.  The problem is that the database field 
> is called 'Part_Number', not 'Number'.  The field 'Number' does not exist in 
> the database.  I am very surprised that I didn't even get a warning that 
> there might be a problem with the statement.  All I saw is that nothing was 
> being returned via the echo command.
> 
> There really must be a stricter error checking that is turned on somewhere, 
> isn't there?
> 
> 
> Thanks for your help.
> 
> Tim
> 
> 
>   
> 

This would generate a E_NOTICE level "warning"

to see the errors of you ways you would need the following at the top of your
script, or set in your php.ini file or in a .htaccess file.


In script example:


.htaccess & php.ini example:

error_reporting = E_ALL
display_errors = On



The default setting in PHP

error_reporting  =  E_ALL & ~E_NOTICE
display_errors = On



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Stricter Error Checking?

2009-09-23 Thread Shawn McKenzie
Tim Legg wrote:
> Hello,
> 
> I just spent way, way to much time trying to debug code due to a misnamed 
> element.  Here is a simplified example of the problem I dealt with.
> 
> 
>   $test = "SELECT * FROM `Materials` WHERE `Part_Number` = '125664'";
>   $result = mysql_query($test,$handle);
>   if(!$result)
>   {
>   die('Error: ' . mysql_error());
>   }
>   $row = mysql_fetch_array($result);
>   echo $row['Number'];
> 
> After retyping the code 3 or 4 times over the course of the morning, I 
> finally found where the problem was.  The problem is that the database field 
> is called 'Part_Number', not 'Number'.  The field 'Number' does not exist in 
> the database.  I am very surprised that I didn't even get a warning that 
> there might be a problem with the statement.  All I saw is that nothing was 
> being returned via the echo command.
> 
> There really must be a stricter error checking that is turned on somewhere, 
> isn't there?
> 
> 
> Thanks for your help.
> 
> Tim
> 
> 
>   

When developing you should always use something like this:

ini_set('display_errors', 'On');
error_reporting(E_ALL);

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stricter Error Checking?

2009-09-23 Thread Shawn McKenzie
Bob McConnell wrote:
> From: Tommy Pham
>>> From: Tim Legg
>>>
>>> I just spent way, way to much time trying to debug code due to a
> misnamed 
>>> element.  Here is a simplified example of the problem I dealt with.
>>>
>>>
>>> $test = "SELECT * FROM `Materials` WHERE `Part_Number` =
> '125664'";
>>> $result = mysql_query($test,$handle);
>>> if(!$result)
>>> {
>>> die('Error: ' . mysql_error());
>>> }
>>> $row = mysql_fetch_array($result);
>>> echo $row['Number'];
>>>
>>> After retyping the code 3 or 4 times over the course of the morning,
> I finally 
>>> found where the problem was.  The problem is that the database field
> is called 
>>> 'Part_Number', not 'Number'.  The field 'Number' does not exist in
> the 
>>> database.  I am very surprised that I didn't even get a warning that
> there might 
>>> be a problem with the statement.  All I saw is that nothing was being
> returned 
>>> via the echo command.
>> if(!$result)
>> {
>> die('Error: ' . mysql_error());
>> }
>>
>> This didn't work when you used 'Number' instead of 'Part_Number'?
> Strange...
> 
> I think the problem is that he didn't check that the key he used
> actually existed before using the value it pointed to. So he got an
> empty string for $row['Number']; because the key should have been
> 'Part_Number'. I don't know that even E_STRICT would catch that one.
> 
> Bob McConnell

What?  With E_ALL or E_STRICT:

Notice: Undefined index:  Number in file.php on line X

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stricter Error Checking?

2009-09-23 Thread Shawn McKenzie
>> I think the problem is that he didn't check that the key he used
>> actually existed before using the value it pointed to. So he got an
>> empty string for $row['Number']; because the key should have been
>> 'Part_Number'. I don't know that even E_STRICT would catch that one.
>>
>> Bob McConnell
> 
> What?  With E_ALL or E_STRICT:
> 
> Notice: Undefined index:  Number in file.php on line X
> 

My bad, E_ALL only.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stricter Error Checking?

2009-09-23 Thread Tommy Pham
- Original Message 
> From: Bob McConnell 
> To: Tommy Pham ; php-general@lists.php.net
> Sent: Wednesday, September 23, 2009 11:37:00 AM
> Subject: RE: [PHP] Stricter Error Checking?
> 
> From: Tommy Pham
> >> From: Tim Legg
> >> 
> >> I just spent way, way to much time trying to debug code due to a
> misnamed 
> >> element.  Here is a simplified example of the problem I dealt with.
> >> 
> >> 
> >> $test = "SELECT * FROM `Materials` WHERE `Part_Number` =
> '125664'";
> >> $result = mysql_query($test,$handle);
> >> if(!$result)
> >> {
> >> die('Error: ' . mysql_error());
> >> }
> >> $row = mysql_fetch_array($result);
> >> echo $row['Number'];
> >> 
> >> After retyping the code 3 or 4 times over the course of the morning,
> I finally 
> >> found where the problem was.  The problem is that the database field
> is called 
> >> 'Part_Number', not 'Number'.  The field 'Number' does not exist in
> the 
> >> database.  I am very surprised that I didn't even get a warning that
> there might 
> >> be a problem with the statement.  All I saw is that nothing was being
> returned 
> >> via the echo command.
> > 
> > if(!$result)
> > {
> > die('Error: ' . mysql_error());
> > }
> > 
> > This didn't work when you used 'Number' instead of 'Part_Number'?
> Strange...
> > 
> 
> I think the problem is that he didn't check that the key he used
> actually existed before using the value it pointed to. So he got an
> empty string for $row['Number']; because the key should have been
> 'Part_Number'. I don't know that even E_STRICT would catch that one.
> 
> Bob McConnell
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

My mistake, didn't have enough caffeine for the day :)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Stricter Error Checking?

2009-09-23 Thread Bob McConnell
From: Tommy Pham
>> From: Tim Legg
>> 
>> I just spent way, way to much time trying to debug code due to a
misnamed 
>> element.  Here is a simplified example of the problem I dealt with.
>> 
>> 
>> $test = "SELECT * FROM `Materials` WHERE `Part_Number` =
'125664'";
>> $result = mysql_query($test,$handle);
>> if(!$result)
>> {
>> die('Error: ' . mysql_error());
>> }
>> $row = mysql_fetch_array($result);
>> echo $row['Number'];
>> 
>> After retyping the code 3 or 4 times over the course of the morning,
I finally 
>> found where the problem was.  The problem is that the database field
is called 
>> 'Part_Number', not 'Number'.  The field 'Number' does not exist in
the 
>> database.  I am very surprised that I didn't even get a warning that
there might 
>> be a problem with the statement.  All I saw is that nothing was being
returned 
>> via the echo command.
> 
> if(!$result)
> {
> die('Error: ' . mysql_error());
> }
> 
> This didn't work when you used 'Number' instead of 'Part_Number'?
Strange...
> 

I think the problem is that he didn't check that the key he used
actually existed before using the value it pointed to. So he got an
empty string for $row['Number']; because the key should have been
'Part_Number'. I don't know that even E_STRICT would catch that one.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stricter Error Checking?

2009-09-23 Thread Jonathan Tapicer
I think he meant that he is using 'Number' instead of 'Part_Number'
when accessing the array and not in the SQL, his SQL was correct, this
was wrong:

> echo $row['Number'];

E_STRICT catches that kind of error.

Jonathan

On Wed, Sep 23, 2009 at 3:28 PM, Tommy Pham  wrote:
>
>
> - Original Message 
>> From: Tim Legg 
>> To: php-general@lists.php.net
>> Sent: Wednesday, September 23, 2009 11:11:46 AM
>> Subject: [PHP] Stricter Error Checking?
>>
>> Hello,
>>
>> I just spent way, way to much time trying to debug code due to a misnamed
>> element.  Here is a simplified example of the problem I dealt with.
>>
>>
>>     $test = "SELECT * FROM `Materials` WHERE `Part_Number` = '125664'";
>>     $result = mysql_query($test,$handle);
>>     if(!$result)
>>     {
>>         die('Error: ' . mysql_error());
>>     }
>>     $row = mysql_fetch_array($result);
>>     echo $row['Number'];
>>
>> After retyping the code 3 or 4 times over the course of the morning, I 
>> finally
>> found where the problem was.  The problem is that the database field is 
>> called
>> 'Part_Number', not 'Number'.  The field 'Number' does not exist in the
>> database.  I am very surprised that I didn't even get a warning that there 
>> might
>> be a problem with the statement.  All I saw is that nothing was being 
>> returned
>> via the echo command.
>
> if(!$result)
> {
>        die('Error: ' . mysql_error());
> }
>
> This didn't work when you used 'Number' instead of 'Part_Number'? Strange...
>
>>
>> There really must be a stricter error checking that is turned on somewhere,
>> isn't there?
>>
>>
>> Thanks for your help.
>>
>> Tim
>>
>>
>>
>>
>> --
>> 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Stricter Error Checking?

2009-09-23 Thread Tommy Pham


- Original Message 
> From: Tim Legg 
> To: php-general@lists.php.net
> Sent: Wednesday, September 23, 2009 11:11:46 AM
> Subject: [PHP] Stricter Error Checking?
> 
> Hello,
> 
> I just spent way, way to much time trying to debug code due to a misnamed 
> element.  Here is a simplified example of the problem I dealt with.
> 
> 
> $test = "SELECT * FROM `Materials` WHERE `Part_Number` = '125664'";
> $result = mysql_query($test,$handle);
> if(!$result)
> {
> die('Error: ' . mysql_error());
> }
> $row = mysql_fetch_array($result);
> echo $row['Number'];
> 
> After retyping the code 3 or 4 times over the course of the morning, I 
> finally 
> found where the problem was.  The problem is that the database field is 
> called 
> 'Part_Number', not 'Number'.  The field 'Number' does not exist in the 
> database.  I am very surprised that I didn't even get a warning that there 
> might 
> be a problem with the statement.  All I saw is that nothing was being 
> returned 
> via the echo command.

if(!$result)
{
die('Error: ' . mysql_error());
}

This didn't work when you used 'Number' instead of 'Part_Number'? Strange...

> 
> There really must be a stricter error checking that is turned on somewhere, 
> isn't there?
> 
> 
> Thanks for your help.
> 
> Tim
> 
> 
>   
> 
> -- 
> 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] Stricter Error Checking?

2009-09-23 Thread Jonathan Tapicer
Hi,

There is, see here (or it can also be set through php.ini):

http://www.php.net/manual/en/function.error-reporting.php

You are looking for E_STRICT.

Regards,

Jonathan

On Wed, Sep 23, 2009 at 3:11 PM, Tim Legg  wrote:
> Hello,
>
> I just spent way, way to much time trying to debug code due to a misnamed 
> element.  Here is a simplified example of the problem I dealt with.
>
>
>        $test = "SELECT * FROM `Materials` WHERE `Part_Number` = '125664'";
>        $result = mysql_query($test,$handle);
>        if(!$result)
>        {
>                die('Error: ' . mysql_error());
>        }
>        $row = mysql_fetch_array($result);
>        echo $row['Number'];
>
> After retyping the code 3 or 4 times over the course of the morning, I 
> finally found where the problem was.  The problem is that the database field 
> is called 'Part_Number', not 'Number'.  The field 'Number' does not exist in 
> the database.  I am very surprised that I didn't even get a warning that 
> there might be a problem with the statement.  All I saw is that nothing was 
> being returned via the echo command.
>
> There really must be a stricter error checking that is turned on somewhere, 
> isn't there?
>
>
> Thanks for your help.
>
> Tim
>
>
>
>
> --
> 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] Stricter Error Checking?

2009-09-23 Thread Tim Legg
Hello,

I just spent way, way to much time trying to debug code due to a misnamed 
element.  Here is a simplified example of the problem I dealt with.


$test = "SELECT * FROM `Materials` WHERE `Part_Number` = '125664'";
$result = mysql_query($test,$handle);
if(!$result)
{
die('Error: ' . mysql_error());
}
$row = mysql_fetch_array($result);
echo $row['Number'];

After retyping the code 3 or 4 times over the course of the morning, I finally 
found where the problem was.  The problem is that the database field is called 
'Part_Number', not 'Number'.  The field 'Number' does not exist in the 
database.  I am very surprised that I didn't even get a warning that there 
might be a problem with the statement.  All I saw is that nothing was being 
returned via the echo command.

There really must be a stricter error checking that is turned on somewhere, 
isn't there?


Thanks for your help.

Tim


  

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: How to take output from an include, and embed it into a variable?

2009-09-23 Thread Jim Lucas
Ashley Sheridan wrote:
> On Wed, 2009-09-23 at 07:36 -0700, Jim Lucas wrote:
>> Mert Oztekin wrote:
>>> Output buffering will do it.
>>>
>>> Also I am not sure but did you try retrieving content with fopen() ?
>>>
>>> Something like
>>>
>>> $file = 'invoicetable_bottom.php';
>>> fopen("http://yoursite.com/folder/$file","r";);
>>>
>>> http://tr.php.net/function.fopen
>>>
>>> worth trying. Easier than output buffering
>>>
>> This would not work.  fopen would open the file for read.  What you would be
>> reading is the actual source of the document.  Not the data the script would
>> output when ran.
>>
>> The ob_* functions are the only way that I know of to do what you are asking
>>
>>> -Original Message-
>>> From: Puiu Hrenciuc [mailto:hp...@xentra.ro]
>>> Sent: Wednesday, September 23, 2009 1:36 PM
>>> To: php-general@lists.php.net
>>> Subject: [PHP] Re: How to take output from an include, and embed it into a 
>>> variable?
>>>
>>> Hi,
>>>
>>> The simplest way (actually the single way I know :) ) would be to
>>> capture the output using output buffering functions, something like this:
>>>
>>> // start output buffering
>>> ob_start();
>>>
>>> // include the file that generates the HTML (or whatever content)
>>> include "";
>>>
>>> // get output buffer content
>>> $output=ob_get_contents();
>>>
>>> // clean output buffer and stop buffering
>>> ob_end_clean();
>>>
>>> // the content generated in the included file is now in $output variable
>>> // use it as you consider fit
>>> .
>>>
>>>
>>> Regards,
>>> Puiu
>>>
>>>
>>> Rob Gould wrote:
 I have an invoice table that is drawn on a number of pages, so I have
 all the logic in an include-file like this:

 include "invoicetable_bottom.php";


 However, now I'm needing to take the output from that include file and
 pass it as an email.  To do that, I need to somehow take the output from
 this include file and get it into a variable somehow.  Is there a simple
 way to do this?

 Something like:  $emailtcontent = include "invoicetable_bottom.php"?
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 
> That's just crazy talk. If you use fopen on a web URL, then it will
> always return the output the script generates. That's how http works!
> 

Sorry, my bad.  Ash is correct, the method that is suggested will work.  But you
will need to enable options in your php.ini that are not on by default for
security reasons, plus as Ben points out, you will need to filter out the scruff
that is generated to capture just the data output from your include.

Mind you that all of this also requires that the file that you are including is
accessible via the web.  It could be in a folder that is not web accessible.

Sorry for the initial confusion!

> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Extract links from strings

2009-09-23 Thread Jim Lucas
Philip Thompson wrote:
> On Sep 21, 2009, at 6:20 PM, Jim Lucas wrote:
> 
>> Jim Lucas wrote:
>>> Jônatas Zechim wrote:
 Hi there, i've the following strings:

 $string1 = 'Lorem ipsum dolor http://site.com sit amet';
 $string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
 $string3 = 'Lorem ipsum dolor http://www.site.net sit amet';

 How can I extract the URL from these strings?
 They can be [http:// + url] or [www. + url].

 Zechim


>>>
>>> Something like this should work for you.
>>>
>>> >>
>>> $urls[] = 'Lorem ipsum dolor http://site.com sit amet';
>>> $urls[] = 'Lorem ipsum dolor https://www.site.com/ sit amet';
>>> $urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
>>> $urls[] = 'Lorem ipsum dolor www site2.net sit amet';
>>>
>>> foreach ( $urls AS $url ) {
>>> if ( preg_match('%((https?://|www\.)[^\s]+)%', $url, $m) ) {
>>> print_r($m);
>>> }
>>> }
>>>
>>> ?>
>>>
>>
>> Actually, try this.  It seems to work a little better.
>>
>> >
>> $urls[] = 'Lorem ipsum dolor http://site.com sit amet';
>> $urls[] = 'Lorem ipsum dolor https://www.site.com/ or
>> http://www.site2.com/';
>> $urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
>> $urls[] = 'Lorem ipsum dolor www site2.net sit amet';
>>
>> foreach ( $urls AS $url ) {
>> if ( preg_match_all('%(https?://[^\s]+|www\.[^\s]+)%',
>> $url,
>> $m,
>> (PREG_SET_ORDER ^ PREG_OFFSET_CAPTURE)
>> ) ) {
>> print_r($m);
>> }
>> }
>>
>> ?>
> 
> What if the sub domain was not 'www'?
> 
> http://no-www.org/
> 

Well, if it had the http:// at the beginning, then it would be found.

but, somedomain.no-www.org would not work.

But, if they only had no-www.org, it would only find www.org

So, I guess it would need to be looking at the characters before the www\. part
to include them in the url also

This should work. Note: the [^\s]+ placed before the www\. portion.

if ( preg_match_all('%(https?://[^\s]+|[^\/\s]+www\.[^\s]+)%',

This should catch example.www.org and no-www.org now.

You could get into the business of trying to match the TLD, but that would be a
PITA to keep updated.


> Cheers,
> ~Philip
> 
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: How to take output from an include, and embed it into a variable?

2009-09-23 Thread Ben Dunlap
> $file = 'invoicetable_bottom.php';
> fopen("http://yoursite.com/folder/$file","r";);
>
> http://tr.php.net/function.fopen
>
> worth trying. Easier than output buffering

Easier in what sense? It would end up requiring more code than
output-buffering because you'd have to read from the file after
calling fopen(), check for end-of-file, etc., and it seems needlessly
inefficient because it:

- uses a function, fopen(), instead of a language construct, include()
- generates a superfluous HTTP request

I think it's also counter-intuitive. I ran across a similar technique
in some code I was reviewing and I had to really scratch my head and
wonder why the original author of the code did that, instead of just
getting at the file via the local file system.

Finally, it would require the OP to store an include()-ed file inside
of DocumentRoot -- which I personally prefer not to do when I can
avoid it (although that approach is debatable).

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] NULLS vs Empty result in PHP

2009-09-23 Thread Bastien Koert
On Wed, Sep 23, 2009 at 11:35 AM, Philip Thompson
 wrote:
> On Sep 23, 2009, at 9:48 AM, Dan Shirah wrote:
>
>>>
>>> From reading the other responses to this thread, it seems that you want
>>> to
>>> "skip" or "exclude" rows in the results where my_column === null.
>>>
>>> If this is correct, why not do it in the SELECT statement to begin with?
>>>
>>> $my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT
>>> NULL";
>>>
>>> That should do it.
>>>
>>
>> I want to exclude the rows that might be NULL, "" (empty), or "        "
>> (empty series of spaces)
>>
>> From all of the input so far, it seems that using trim() on the variable
>> and
>> then use empty() is the best way to pick all three types up.
>
> I don't think you're using mysql, but your selected db may have a similar
> option. I would do the work in the sql.
>
>  $sql = "SELECT * FROM `table` WHERE TRIM(`column`) <> '' AND `column` IS NOT
> NULL";
> $result = query($sql);
> while ($row = fetch_row ($result)) {
>    echo "Not empty, multiple spaces or NULL!";
> }
> ?>
>
> So, if you have any extraneous spaces, they will be removed. It also
> accounts for nulls. No work is required by PHP to determine the values you
> need. Just use what it returns. This should work.
>
> Hope this helps.
> ~Philip
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Another thought might be to convert the nulls into another value

select field1, field2, ISNULL(field3,'-') from table where ...

would convert the nulls into hyphens

-- 

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] NULLS vs Empty result in PHP

2009-09-23 Thread Philip Thompson

On Sep 23, 2009, at 9:48 AM, Dan Shirah wrote:



From reading the other responses to this thread, it seems that you  
want

to
"skip" or "exclude" rows in the results where my_column === null.

If this is correct, why not do it in the SELECT statement to begin  
with?


$my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT
NULL";

That should do it.



I want to exclude the rows that might be NULL, "" (empty), or  
""

(empty series of spaces)

From all of the input so far, it seems that using trim() on the  
variable and

then use empty() is the best way to pick all three types up.


I don't think you're using mysql, but your selected db may have a  
similar option. I would do the work in the sql.


$sql = "SELECT * FROM `table` WHERE TRIM(`column`) <> '' AND `column`  
IS NOT NULL";

$result = query($sql);
while ($row = fetch_row ($result)) {
echo "Not empty, multiple spaces or NULL!";
}
?>

So, if you have any extraneous spaces, they will be removed. It also  
accounts for nulls. No work is required by PHP to determine the values  
you need. Just use what it returns. This should work.


Hope this helps.
~Philip


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Extract links from strings

2009-09-23 Thread Philip Thompson

On Sep 21, 2009, at 6:20 PM, Jim Lucas wrote:


Jim Lucas wrote:

Jônatas Zechim wrote:

Hi there, i've the following strings:

$string1 = 'Lorem ipsum dolor http://site.com sit amet';
$string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
$string3 = 'Lorem ipsum dolor http://www.site.net sit amet';

How can I extract the URL from these strings?
They can be [http:// + url] or [www. + url].

Zechim




Something like this should work for you.

http://site.com sit amet';
$urls[] = 'Lorem ipsum dolor https://www.site.com/ sit amet';
$urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
$urls[] = 'Lorem ipsum dolor www site2.net sit amet';

foreach ( $urls AS $url ) {
if ( preg_match('%((https?://|www\.)[^\s]+)%', $url, $m) ) {
print_r($m);
}
}

?>



Actually, try this.  It seems to work a little better.

http://site.com sit amet';
$urls[] = 'Lorem ipsum dolor https://www.site.com/ or http://www.site2.com/' 
;

$urls[] = 'Lorem ipsum dolor www.site1.net sit amet';
$urls[] = 'Lorem ipsum dolor www site2.net sit amet';

foreach ( $urls AS $url ) {
if ( preg_match_all('%(https?://[^\s]+|www\.[^\s]+)%',
$url,
$m,
(PREG_SET_ORDER ^ PREG_OFFSET_CAPTURE)
) ) {
print_r($m);
}
}

?>


What if the sub domain was not 'www'?

http://no-www.org/

Cheers,
~Philip


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: NULLS vs Empty result in PHP

2009-09-23 Thread Dan Shirah
>
> if it can take only numeric values u can use is_numeric()
>
> also i suggest that you not to use nulls in dbs. instead, use "not null"
> and "default value" property. Its more simple and more effective for both
> managing your database and coding your program.
>
>

It's a CHAR (60) field.

This database has been around for close to a decade and I'm not the DBA for
it.  And with several billion records and 1000's of tables I don't see them
getting updated/changed. (The gov't doesn't like change)


Re: [PHP] Re: How to take output from an include, and embed it into a variable?

2009-09-23 Thread Ashley Sheridan
On Wed, 2009-09-23 at 07:36 -0700, Jim Lucas wrote:
> Mert Oztekin wrote:
> > Output buffering will do it.
> > 
> > Also I am not sure but did you try retrieving content with fopen() ?
> > 
> > Something like
> > 
> > $file = 'invoicetable_bottom.php';
> > fopen("http://yoursite.com/folder/$file","r";);
> > 
> > http://tr.php.net/function.fopen
> > 
> > worth trying. Easier than output buffering
> > 
> 
> This would not work.  fopen would open the file for read.  What you would be
> reading is the actual source of the document.  Not the data the script would
> output when ran.
> 
> The ob_* functions are the only way that I know of to do what you are asking
> 
> > -Original Message-
> > From: Puiu Hrenciuc [mailto:hp...@xentra.ro]
> > Sent: Wednesday, September 23, 2009 1:36 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] Re: How to take output from an include, and embed it into a 
> > variable?
> > 
> > Hi,
> > 
> > The simplest way (actually the single way I know :) ) would be to
> > capture the output using output buffering functions, something like this:
> > 
> > // start output buffering
> > ob_start();
> > 
> > // include the file that generates the HTML (or whatever content)
> > include "";
> > 
> > // get output buffer content
> > $output=ob_get_contents();
> > 
> > // clean output buffer and stop buffering
> > ob_end_clean();
> > 
> > // the content generated in the included file is now in $output variable
> > // use it as you consider fit
> > .
> > 
> > 
> > Regards,
> > Puiu
> > 
> > 
> > Rob Gould wrote:
> >> I have an invoice table that is drawn on a number of pages, so I have
> >> all the logic in an include-file like this:
> >>
> >> include "invoicetable_bottom.php";
> >>
> >>
> >> However, now I'm needing to take the output from that include file and
> >> pass it as an email.  To do that, I need to somehow take the output from
> >> this include file and get it into a variable somehow.  Is there a simple
> >> way to do this?
> >>
> >> Something like:  $emailtcontent = include "invoicetable_bottom.php"?
> > 
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

That's just crazy talk. If you use fopen on a web URL, then it will
always return the output the script generates. That's how http works!

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] NULLS vs Empty result in PHP

2009-09-23 Thread Dan Shirah
>
>  From reading the other responses to this thread, it seems that you want
> to
> "skip" or "exclude" rows in the results where my_column === null.
>
> If this is correct, why not do it in the SELECT statement to begin with?
>
> $my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT
> NULL";
>
> That should do it.
>

I want to exclude the rows that might be NULL, "" (empty), or ""
(empty series of spaces)

>From all of the input so far, it seems that using trim() on the variable and
then use empty() is the best way to pick all three types up.


Re: [PHP] NULLS vs Empty result in PHP

2009-09-23 Thread Jim Lucas
Dan Shirah wrote:
> Morning!
> 
> Just a quick question.
> 
> Say I have a column in my database that could contain NULLS, empty spaces,
> or an actual value.
> 
> If I do:
> 
> $my_query = "SELECT my_column FROM my_database WHERE 1 = 1";
> $my_result = ifx_query($my_query, $connect_id);
> 
> while($row = ifx_fetch_row($my_result)) {
>   $my_column = trim($row['my_column']);
> 
>   if ($my_column != "") {
>echo "Test";
>   }
> }
> 
> The way PHP assigns the query results to the $my_column variable, wouldn't;
> if ($my_column != "")  not do anything for the rows that contained NULLS or
> empty spaces?
> 

>From reading the other responses to this thread, it seems that you want to
"skip" or "exclude" rows in the results where my_column === null.

If this is correct, why not do it in the SELECT statement to begin with?

$my_query = "SELECT my_column FROM my_database WHERE my_column IS NOT NULL";

That should do it.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: How to take output from an include, and embed it into a variable?

2009-09-23 Thread Jim Lucas
Mert Oztekin wrote:
> Output buffering will do it.
> 
> Also I am not sure but did you try retrieving content with fopen() ?
> 
> Something like
> 
> $file = 'invoicetable_bottom.php';
> fopen("http://yoursite.com/folder/$file","r";);
> 
> http://tr.php.net/function.fopen
> 
> worth trying. Easier than output buffering
> 

This would not work.  fopen would open the file for read.  What you would be
reading is the actual source of the document.  Not the data the script would
output when ran.

The ob_* functions are the only way that I know of to do what you are asking

> -Original Message-
> From: Puiu Hrenciuc [mailto:hp...@xentra.ro]
> Sent: Wednesday, September 23, 2009 1:36 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: How to take output from an include, and embed it into a 
> variable?
> 
> Hi,
> 
> The simplest way (actually the single way I know :) ) would be to
> capture the output using output buffering functions, something like this:
> 
> // start output buffering
> ob_start();
> 
> // include the file that generates the HTML (or whatever content)
> include "";
> 
> // get output buffer content
> $output=ob_get_contents();
> 
> // clean output buffer and stop buffering
> ob_end_clean();
> 
> // the content generated in the included file is now in $output variable
> // use it as you consider fit
> .
> 
> 
> Regards,
> Puiu
> 
> 
> Rob Gould wrote:
>> I have an invoice table that is drawn on a number of pages, so I have
>> all the logic in an include-file like this:
>>
>> include "invoicetable_bottom.php";
>>
>>
>> However, now I'm needing to take the output from that include file and
>> pass it as an email.  To do that, I need to somehow take the output from
>> this include file and get it into a variable somehow.  Is there a simple
>> way to do this?
>>
>> Something like:  $emailtcontent = include "invoicetable_bottom.php"?
> 
> --
> 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] Parse error: syntax error, unexpected '>'

2009-09-23 Thread Fernando Castillo Aparicio
Reading again, it's not just one miss. You have to close some strings, escape 
some quotes, etc

I think this can be right:

$sql = "SELECT * FROM melstatus WHERE custID=$custID ORDER BY
aircraftRegistration";

$q = mysql_query($q)
or die ("could not execute query.");

echo " 
\n";

while($row = mysql_fetch_array($q))
{
echo " ".$row['melID']." ";

echo "\n";
}
echo "";


I'd recomend you to get a good text editor with sintax highlighting if you 
haven't one. It would warn you from most of these mistakes.

And an xhtml issue: to use an empty tag, you use  and not 






De: Fernando Castillo Aparicio 
Para: Haig Davis ; php-general@lists.php.net
Enviado: miércoles, 23 de septiembre, 2009 16:23:07
Asunto: Re: [PHP] Parse error: syntax error, unexpected '>'

You missed a double quote here:

echo " 
\n";





De: Haig Davis 
Para: php-general@lists.php.net
Enviado: miércoles, 23 de septiembre, 2009 16:18:17
Asunto: [PHP] Parse error: syntax error, unexpected '>'

Good morning Everyone,

I'm have trouble with a simple HTML Checkbox list. I keep getting *Parse
error*: syntax error, unexpected '>'. I'm sure I'm doing something really
simple and basic wrong I just cannot seem to see what it is, any assistance
is appreciated.

Script:

http://bw.org/misc/cgi-test/test.cgi";>


\n;

while($row = mysql_fetch_array($q))
{
echo " ".$row['melID']." ";

\n";
}
echo "

?>


Many Thanks

Haig


  

Re: [PHP] Parse error: syntax error, unexpected '>'

2009-09-23 Thread Ashley Sheridan
On Wed, 2009-09-23 at 07:18 -0700, Haig Davis wrote:
> echo " ".$row['melID']." name="\".$row['melID].\""/input> ";

You're escaping in the wrong places. The \ escapes the character
following it, so what you are doing here, in line 2, is breaking out of
the string with a regular " and then printing a " (escaped \") Also, I
think you need to brush up on your HTML a bit, as 



is not valid HTML.


Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parse error: syntax error, unexpected '>'

2009-09-23 Thread Fernando Castillo Aparicio
You missed a double quote here:

echo " 
\n";





De: Haig Davis 
Para: php-general@lists.php.net
Enviado: miércoles, 23 de septiembre, 2009 16:18:17
Asunto: [PHP] Parse error: syntax error, unexpected '>'

Good morning Everyone,

I'm have trouble with a simple HTML Checkbox list. I keep getting *Parse
error*: syntax error, unexpected '>'. I'm sure I'm doing something really
simple and basic wrong I just cannot seem to see what it is, any assistance
is appreciated.

Script:

http://bw.org/misc/cgi-test/test.cgi";>


\n;

while($row = mysql_fetch_array($q))
{
echo " ".$row['melID']." ";

\n";
}
echo "

?>


Many Thanks

Haig



  

[PHP] Parse error: syntax error, unexpected '>'

2009-09-23 Thread Haig Davis
Good morning Everyone,

I'm have trouble with a simple HTML Checkbox list. I keep getting *Parse
error*: syntax error, unexpected '>'. I'm sure I'm doing something really
simple and basic wrong I just cannot seem to see what it is, any assistance
is appreciated.

Script:

http://bw.org/misc/cgi-test/test.cgi";>


\n;

while($row = mysql_fetch_array($q))
{
echo " ".$row['melID']." ";

\n";
}
echo "

?>


Many Thanks

Haig


[PHP] Re: Dom PDF Problem

2009-09-23 Thread Chris Wilson
This  might help some people struggling with memory leak problems in
DOMPDF. I haven't fixed it but it seems to have reduced the memory leak
considerably.

I have done 2 things:

1.
Added a detruct function to the DOMPDF file in dompdf.cls.php where I
unset everything. I call this each time in my loop when I'm using DOMPDF
mulitple times:

function __destruct()
{
  unset($this->_messages);
  unset($this->_xml);
  unset($this->_tree);
  unset($this->_css);
  unset($this->_pdf);
  unset($this->_paper_size);
  unset($this->_paper_orientation);
  unset($this->_base_host);
  unset($this->_base_path);
  unset($this->_cache_id);
}

2.
I now added within the render function of DOMPDF a call to the function
dispose to clean up anything left from before:

// This is where the magic happens:
$root->reflow();

// Memory leak fix
$root->dispose(true);

// Clean up cached images
Image_Cache::clear();


Also worth mentioning that I increased my memory allocation in my
php.ini to about 256MB, and the max execution time to about 120 seconds.

As mentioned this won't fix the problem but it does reduce the memory
used.


Chris
No virus found in this outgoing message.
Checked by AVG - www.avg.com 
Version: 8.5.416 / Virus Database: 270.13.112/2388 - Release Date:
09/23/09 05:52:00
No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 8.5.416 / Virus Database: 270.13.112/2390 - Release Date: 09/23/09 
05:52:00
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Re: NULLS vs Empty result in PHP

2009-09-23 Thread Ashley Sheridan
On Wed, 2009-09-23 at 16:34 +0300, Mert Oztekin wrote:
> if it can take only numeric values u can use is_numeric()
> 
> also i suggest that you not to use nulls in dbs. instead, use "not null" and 
> "default value" property. Its more simple and more effective for both 
> managing your database and coding your program.
> 
> 
> -Original Message-
> From: Robert Cummings [mailto:rob...@interjinn.com]
> Sent: Wednesday, September 23, 2009 4:28 PM
> To: Ralph Deffke
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Re: NULLS vs Empty result in PHP
> 
> Ralph Deffke wrote:
> > using empty() is ´the right way to check a var for NULL or ""
> 
> Empty will also match a string containing 0. And, to me, that doesn't at
> all seem empty :)
> 
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
>   
> Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve 
> gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz 
> ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak 
> şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz 
> mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, 
> bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve 
> bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.
> 
> This message and attachments are confidential and intended for the 
> individual(s) stated in this message. If you received this message in error, 
> please immediately notify the sender and delete it from your system. Our 
> company has no legal responsibility for the contents of the message and its 
> attachments. Our company shall have no liability for any changes or late 
> receiving, loss of integrity and confidentiality, viruses and any damages 
> caused in anyway to your computer system.

Or you could leave the database with the nulls in, and cast the value
explicitly as an integer with intval() or floatval() which will always
give you a numeric value.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: NULLS vs Empty result in PHP

2009-09-23 Thread Mert Oztekin
if it can take only numeric values u can use is_numeric()

also i suggest that you not to use nulls in dbs. instead, use "not null" and 
"default value" property. Its more simple and more effective for both managing 
your database and coding your program.


-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com]
Sent: Wednesday, September 23, 2009 4:28 PM
To: Ralph Deffke
Cc: php-general@lists.php.net
Subject: Re: [PHP] Re: NULLS vs Empty result in PHP

Ralph Deffke wrote:
> using empty() is ´the right way to check a var for NULL or ""

Empty will also match a string containing 0. And, to me, that doesn't at
all seem empty :)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  
Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve 
gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve 
mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak 
şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz 
mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, 
bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar 
sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.


Re: [PHP] Re: NULLS vs Empty result in PHP

2009-09-23 Thread Robert Cummings

Ralph Deffke wrote:

using empty() is ´the right way to check a var for NULL or ""


Empty will also match a string containing 0. And, to me, that doesn't at 
all seem empty :)


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: NULLS vs Empty result in PHP

2009-09-23 Thread Dan Shirah
>
> using empty() is ´the right way to check a var for NULL or ""
>
> however, it also depends what MySQL has got as setuo definition for empty
> fields. on textfields u can define an epmty string as default.
>
> So say these are the first three results of my query:

"some text" //The column actually has data
"  " //The column contains a series of spaces
"NULL"   //The column contains a NULL value

As long as I trim() the result, if (!empty()) would skip any results where
the column contains "  " OR "NULL", correct?


[PHP] Re: NULLS vs Empty result in PHP

2009-09-23 Thread Ralph Deffke
using empty() is ´the right way to check a var for NULL or ""

however, it also depends what MySQL has got as setuo definition for empty
fields. on textfields u can define an epmty string as default.

ralph_def...@yahoo.de

"Dan Shirah"  wrote in message
news:a16da1ff0909230458o30d66186m75fc4fd0d1972...@mail.gmail.com...
> Morning!
>
> Just a quick question.
>
> Say I have a column in my database that could contain NULLS, empty spaces,
> or an actual value.
>
> If I do:
>
> $my_query = "SELECT my_column FROM my_database WHERE 1 = 1";
> $my_result = ifx_query($my_query, $connect_id);
>
> while($row = ifx_fetch_row($my_result)) {
>   $my_column = trim($row['my_column']);
>
>   if ($my_column != "") {
>echo "Test";
>   }
> }
>
> The way PHP assigns the query results to the $my_column variable,
wouldn't;
> if ($my_column != "")  not do anything for the rows that contained NULLS
or
> empty spaces?
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] NULLS vs Empty result in PHP

2009-09-23 Thread Samrat Kar
Use var_dump before processing your result.

Regards,

Samrat Kar
FRD, BARC

Tel: 022-25597295
Alternate Email: esam...@yahoo.com


-Original Message-
From: Dan Shirah [mailto:mrsqua...@gmail.com] 
Sent: Wednesday, September 23, 2009 5:28 PM
To: PHP General
Subject: [PHP] NULLS vs Empty result in PHP

Morning!

Just a quick question.

Say I have a column in my database that could contain NULLS, empty spaces,
or an actual value.

If I do:

$my_query = "SELECT my_column FROM my_database WHERE 1 = 1";
$my_result = ifx_query($my_query, $connect_id);

while($row = ifx_fetch_row($my_result)) {
  $my_column = trim($row['my_column']);

  if ($my_column != "") {
   echo "Test";
  }
}

The way PHP assigns the query results to the $my_column variable, wouldn't;
if ($my_column != "")  not do anything for the rows that contained NULLS or
empty spaces?

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.409 / Virus Database: 270.13.112/2388 - Release Date: 09/22/09
17:54:00



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] NULLS vs Empty result in PHP

2009-09-23 Thread Dan Shirah
Morning!

Just a quick question.

Say I have a column in my database that could contain NULLS, empty spaces,
or an actual value.

If I do:

$my_query = "SELECT my_column FROM my_database WHERE 1 = 1";
$my_result = ifx_query($my_query, $connect_id);

while($row = ifx_fetch_row($my_result)) {
  $my_column = trim($row['my_column']);

  if ($my_column != "") {
   echo "Test";
  }
}

The way PHP assigns the query results to the $my_column variable, wouldn't;
if ($my_column != "")  not do anything for the rows that contained NULLS or
empty spaces?


RE: [PHP] Re: How to take output from an include, and embed it into a variable?

2009-09-23 Thread Mert Oztekin
Output buffering will do it.

Also I am not sure but did you try retrieving content with fopen() ?

Something like

$file = 'invoicetable_bottom.php';
fopen("http://yoursite.com/folder/$file","r";);

http://tr.php.net/function.fopen

worth trying. Easier than output buffering

-Original Message-
From: Puiu Hrenciuc [mailto:hp...@xentra.ro]
Sent: Wednesday, September 23, 2009 1:36 PM
To: php-general@lists.php.net
Subject: [PHP] Re: How to take output from an include, and embed it into a 
variable?

Hi,

The simplest way (actually the single way I know :) ) would be to
capture the output using output buffering functions, something like this:

// start output buffering
ob_start();

// include the file that generates the HTML (or whatever content)
include "";

// get output buffer content
$output=ob_get_contents();

// clean output buffer and stop buffering
ob_end_clean();

// the content generated in the included file is now in $output variable
// use it as you consider fit
.


Regards,
Puiu


Rob Gould wrote:
> I have an invoice table that is drawn on a number of pages, so I have
> all the logic in an include-file like this:
>
> include "invoicetable_bottom.php";
>
>
> However, now I'm needing to take the output from that include file and
> pass it as an email.  To do that, I need to somehow take the output from
> this include file and get it into a variable somehow.  Is there a simple
> way to do this?
>
> Something like:  $emailtcontent = include "invoicetable_bottom.php"?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve 
gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve 
mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak 
?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz 
mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, 
b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar 
sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.


[PHP] Re: How to take output from an include, and embed it into a variable?

2009-09-23 Thread Puiu Hrenciuc

Hi,

The simplest way (actually the single way I know :) ) would be to
capture the output using output buffering functions, something like this:

// start output buffering
ob_start();

// include the file that generates the HTML (or whatever content)
include "";

// get output buffer content
$output=ob_get_contents();

// clean output buffer and stop buffering
ob_end_clean();

// the content generated in the included file is now in $output variable
// use it as you consider fit
.


Regards,
Puiu


Rob Gould wrote:
I have an invoice table that is drawn on a number of pages, so I have 
all the logic in an include-file like this:


include "invoicetable_bottom.php";


However, now I'm needing to take the output from that include file and 
pass it as an email.  To do that, I need to somehow take the output from 
this include file and get it into a variable somehow.  Is there a simple 
way to do this?


Something like:  $emailtcontent = include "invoicetable_bottom.php"?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php