[PHP] When to call mysqli::close

2012-01-31 Thread Albert Kamau
Hi good people,

When should i call mysqli::close ? Should I call $stmt-close() at the end
of the method(below) . Or should I call it after every condition ensuring
that I close the database connection even if the process fails at some
stage e.g bind param

public function function_name($id,$new_id ){
$query = UPDATE TABLE SET name = ? WHERE field = ? ;
if($stmt=$this-prepare($query)){
if($stmt-bind_param(is, $id, $new_id)){
if($stmt-execute()){

}else{//Could not execute the prepared statement
$message = Could not execute the prepared statement;
}
}else{//Could not bind the parameters
$message = Could not bind the parameters;
}

}else{
$message = Could not prepare the statement;
}
return $message
}



Kind regards
Albert Kamau

 Saf : 0720550742


[PHP] Re: fopen() for http:// sometimes working, sometimes not

2007-12-29 Thread Albert Wiersch

Dan [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 You really need to filter your input more, have a list of what is 
 acceptable not what is unacceptable.  That being, make it a requirement 
 that the url input has a TDL(.com, .net, .org, etc.) or is a valid IP(ping 
 it), only allow alphanumerics for the name, etc.  When you don't validate 
 your site can get hacked, I know it's not really insecure but it's just an 
 example of input you may not expect, if you try to validate 
 http://localhost it goes ahead and validates your server's html.

I make sure it starts with http: or https: and change spaces to %20 so 
it will work. I also check for some possible recursion issues. I think I'm 
fairly secure just doing that. What could happen security wise? What else do 
you think I need to do? I don't want to check for a TLD as there are many 
and I don't think it is necessary... and pinging doesn't seem like a good 
idea either as some servers probably won't respond to pings.

The localhost issue is interesting, but I don't see it as a security issue.

I would like to know if there are any serious secirity issues I may be 
overlooking though.

Thanks,
Albert

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



[PHP] Re: fopen() for http:// sometimes working, sometimes not

2007-12-28 Thread Albert Wiersch
I'm now using PHP 5.2.5.

Well, it seems to still be happening. This describes the problem but I 
haven't found a solution that works for me yet:
http://bugs.php.net/bug.php?id=11058

Is it a PHP problem or DNS? It works sometimes but not other times.. 
something strange is going on.

Example messages:
[Fri Dec 28 11:59:04 2007] [error] [client 192.168.0.51] PHP Warning: 
fopen() [a href='function.fopen'function.fopen/a]: 
php_network_getaddresses: getaddrinfo failed: Name or service not known
[Fri Dec 28 11:59:04 2007] [error] [client 192.168.0.51] PHP Warning: 
fopen(http://www.lantanalinks.com) [a 
href='function.fopen'function.fopen/a]: failed to open stream: Success

I suppose I could adjust the script to try again if it fails the first time, 
but I shouldn't have to.

Some additional info, when it fails with this problem, it fails very quickly 
(in less than half a second)... its like it doesn't even try to look up the 
name.

-- 
Albert Wiersch
Fix your website: http://onlinewebcheck.com


Albert Wiersch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 I noticed my script at http://onlinewebcheck.com was sometimes (fairly 
 often) failing to open some URLs that users have entered. fopen() returns 
 false very quickly, but when tried again with the same URL, sometimes it 
 works. What would cause this behavior? Why does fopen() occasionally fail 
 to open valid http addresses but works at other times?

 -- 
 Albert Wiersch 

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



Re: [PHP] Re: fopen() for http:// sometimes working, sometimes not

2007-12-28 Thread Albert Wiersch

Wolf [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 DNS issues

I think I've solved this. I found a problem with resolv.conf that contained 
some outdated DNS servers. After changing that and rebooting the server it 
seems to be working. It didn't seem to work after just changing the file and 
restarting apache though, it seems like the reboot was necessary. I don't 
know why but so far do good.

The root.hints file was also updated. I'm not sure if that had anything to 
do with it but it was updated in the process of trying to fix the problem.

Albert 

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



[PHP] fopen() for http:// sometimes working, sometimes not

2007-12-27 Thread Albert Wiersch

I noticed my script at http://onlinewebcheck.com was sometimes (fairly 
often) failing to open some URLs that users have entered. fopen() returns 
false very quickly, but when tried again with the same URL, sometimes it 
works. What would cause this behavior? Why does fopen() occasionally fail to 
open valid http addresses but works at other times?

-- 
Albert Wiersch

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



Re: [PHP] fopen() for http:// sometimes working, sometimes not

2007-12-27 Thread Albert Wiersch

Daniel Brown [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Dec 27, 2007 11:31 AM, Albert Wiersch [EMAIL PROTECTED] 
 wrote:

Are the URLs being passed to fopen() properly escaped?  Are they
 valid, complete with http:// placed before the domain?  Try keeping a
 log of all URLs entered for a bit, and see which ones fail.

It's not the URL because the same URL will not work one time but will work 
another time.

What needs to be escaped for a URL anyway? I am just changing spaces to 
'%20' now.

I will try upgrading to 5.2.5. I'm using 5.2.3 now.

Thanks,
Albert

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



[PHP] Re: fopen() for http:// sometimes working, sometimes not

2007-12-27 Thread Albert Wiersch

Some additional info. It seems I am getting these warnings when it fails:

Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo 
failed: Name or service not known

Warning: fopen(http://wanganda2u.co.uk) [function.fopen]: failed to open 
stream:

Now I have to find out why that is failing some of the time but not other 
times.

-- 
Albert Wiersch
Fix your website: http://onlinewebcheck.com


Albert Wiersch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 I noticed my script at http://onlinewebcheck.com was sometimes (fairly 
 often) failing to open some URLs that users have entered. fopen() returns 
 false very quickly, but when tried again with the same URL, sometimes it 
 works. What would cause this behavior? Why does fopen() occasionally fail 
 to open valid http addresses but works at other times?

 -- 
 Albert Wiersch 

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



Re: [PHP] Re: fopen() for http:// sometimes working, sometimes not

2007-12-27 Thread Albert Wiersch

Daniel Brown [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

That sounds like a DNS resolution error.  If you have Telnet/SSH
 or local console access, try doing a dig, traceroute, and ping series
 on it.

Hi Daniel,

Yes, I have SSH access. I will keep that in mind. Upgrading to 5.2.5 may 
have addressed this issue though. If not, then I'll concentrate on a 
possible DNS resolution problem.

Albert

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



Re: [PHP] Re: fopen() for http:// sometimes working, sometimes not

2007-12-27 Thread Albert Wiersch

Albert Wiersch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Yes, I have SSH access. I will keep that in mind. Upgrading to 5.2.5 may 
 have addressed this issue though. If not, then I'll concentrate on a 
 possible DNS resolution problem.

Well, it seems to still be happening. This describes the problem but I 
haven't found a solution that works for me yet:
http://bugs.php.net/bug.php?id=11058

Is it a PHP problem or DNS? It works sometimes but not other times.. 
something strange is going on.

Albert

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



[PHP] trouble with function openssl_csr_new()

2007-03-21 Thread Albert Kopka

Hi ...

I want to generate certificate for smardcard login (MS Win-XP)
and for do that the subject of certificate should contain same key
(in key:value of $dn) multiple times for example ...

cert generated by ca suplied with W-2003 server for smartcard login
contains:
Subject: DC = local, DC = foo, CN = Users, CN = bar

but $dn is an array ... so if I define array as:

$dn = array ( DC = local, DC = foo );

I've got array with one key:value pair DC = foo ...

Is there any other way to pass the $dn to function ...
(using other structure ... or formated string ... )
or mayby I can use other function whitch supports repeated keys ?

-- 
Albert Kopka
[EMAIL PROTECTED]

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



[PHP] Stuffing code into variable

2007-02-03 Thread Albert Padley
It's late and I've been at this a long time today so I throw myself  
on the mercy of the list.


I have an echo statement that I use in conjunction with a MySQL query.

echo tr\ntd class=\tabletext\ . $row['time'] . /td\ntd  
class=\tabletext\ . $row['field'] . /td\ntd class=\tabletext 
\ . $row['division'] . /td\n;


This works perfectly fine. However, I will be using the same code  
numerous times on the page and wanted to stuff it all into a  
variable. At this point I can't remember the proper syntax and  
quoting to get this right. Any takers?


Thanks.

Al Padley

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



Re: [PHP] Stuffing code into variable

2007-02-03 Thread Albert Padley


On Feb 3, 2007, at 9:09 PM, Christopher Weldon wrote:



On Feb 3, 2007, at 9:09 PM, Albert Padley wrote:

It's late and I've been at this a long time today so I throw  
myself on the mercy of the list.


I have an echo statement that I use in conjunction with a MySQL  
query.


echo tr\ntd class=\tabletext\ . $row['time'] . /td\ntd  
class=\tabletext\ . $row['field'] . /td\ntd class= 
\tabletext\ . $row['division'] . /td\n;


This works perfectly fine. However, I will be using the same code  
numerous times on the page and wanted to stuff it all into a  
variable. At this point I can't remember the proper syntax and  
quoting to get this right. Any takers?


Thanks.

Al Padley

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




You could always make it a function...ie:

function drawTableRow($sqlRow) {
return tr\ntd class=\tabletext\. $sqlRow['time'] ./td 
\ntd class=\tabletext\.$row['field']./td; // Simplified  
for time purposes.

}

// Execute the query
foreach ($row = mysql_fetch_array($query)) {
echo drawTableRow($row);
}


That's perfect. I should of thought of using a function.

Thanks.

Al

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



Re: [PHP] Stuffing code into variable

2007-02-03 Thread Albert Padley


On Feb 3, 2007, at 10:04 PM, Paul Novitski wrote:




On Feb 3, 2007, at 9:09 PM, Albert Padley wrote:
I have an echo statement that I use in conjunction with a MySQL  
query.


echo tr\ntd class=\tabletext\ . $row['time'] . /td\ntd
class=\tabletext\ . $row['field'] . /td\ntd class=  
\tabletext\ . $row['division'] . /td\n;


This works perfectly fine. However, I will be using the same code
numerous times on the page and wanted to stuff it all into a
variable. At this point I can't remember the proper syntax and
quoting to get this right. Any takers?



At 2/3/2007 08:09 PM, Christopher Weldon wrote:

You could always make it a function...ie:

function drawTableRow($sqlRow) {
return tr\ntd class=\tabletext\. $sqlRow['time'] ./ 
td \ntd class=\tabletext\.$row['field']./td; //  
Simplified for

time purposes.
}


Good suggestion.  I like heredoc's clean presentation:
__

function drawTableRow($sqlrow)
{
return _
tr
td class=tabletext{$sqlrow['time']}/td
td class=tabletext{$sqlrow['field']}/td
td class=tabletext{$sqlrow['division']}/td
/tr

_;
}
__

By the way, if every cell in every row is class tabletext why  
have a class at all?  You could simply apply the desired styles to  
the td element.


Regards,

Paul

I'm using heredoc elsewhere on the page so that's a good idea.

As far as the CSS on the td, other cells in the table have  
different styling.


Al

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



[PHP] Uninitialized string offset: 0

2007-01-06 Thread Albert Padley
I have the following class that generates a Notice: Uninitialized  
string offset: 0 each time it is called. The lines generating the  
notice are marked. How do I fix this?


class InputFilter {
var $tagsArray;
var $attrArray;
var $tagsMethod;
var $attrMethod;
var $xssAuto;
	var $tagBlacklist = array('applet', 'body', 'bgsound', 'base',  
'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id',  
'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object',  
'script', 'style', 'title', 'xml');
	var $attrBlacklist = array('action', 'background', 'codebase',  
'dynsrc', 'lowsrc');
	function inputFilter($tagsArray = array(), $attrArray = array(),  
$tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) {		
		for ($i = 0; $i  count($tagsArray); $i++) $tagsArray[$i] =  
strtolower($tagsArray[$i]); // Notice Generated Here
		for ($i = 0; $i  count($attrArray); $i++) $attrArray[$i] =  
strtolower($attrArray[$i]); // Notice Generated Here also

$this-tagsArray = (array) $tagsArray;
$this-attrArray = (array) $attrArray;
$this-tagsMethod = $tagsMethod;
$this-attrMethod = $attrMethod;
$this-xssAuto = $xssAuto;
}
}

TIA.

Al Padley

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



Re: [PHP] Uninitialized string offset: 0

2007-01-06 Thread Albert Padley

Sure.

$myFilter = new InputFilter('','',0,0);
$_POST = $myFilter-process($_POST);

BTW - for what I'm trying to do at the moment, if I change the first  
line to:


$myFilter = new InputFilter();

it takes care of the Notice problem.

Thanks.

Al

On Jan 6, 2007, at 12:36 PM, Dave Goodchild wrote:


Can you show us what you're calling it with?



Al Padley

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




--
http://www.web-buddha.co.uk




Re: [PHP] Uninitialized string offset: 0

2007-01-06 Thread Albert Padley

Ah, of course.

Thanks.

Al


On Jan 6, 2007, at 12:57 PM, Robert Cummings wrote:


On Sat, 2007-01-06 at 12:43 -0700, Albert Padley wrote:

Sure.

$myFilter = new InputFilter('','',0,0);


The first two parameters should be arrays (not strings as you have
above).

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



[PHP] Dynamic Year Drop Down

2006-11-16 Thread Albert Padley
I want to build a select drop down that includes last year, the  
current year and 3 years into the future. Obviously, I could easily  
hard code this or use a combination of the date and mktime functions  
to populate the select. However, I'm looking for a more elegant way  
of doing this.


Thanks for pointing me in the right direction.

Al Padley

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



Re: [PHP] Dynamic Year Drop Down

2006-11-16 Thread Albert Padley


On Nov 16, 2006, at 11:04 PM, Tom Ray [Lists] wrote:




Albert Padley wrote:
I want to build a select drop down that includes last year, the  
current year and 3 years into the future. Obviously, I could  
easily hard code this or use a combination of the date and mktime  
functions to populate the select. However, I'm looking for a more  
elegant way of doing this.


Thanks for pointing me in the right direction.


This works for me, simple and easy.

// Grabs current Year
$year=date(Y);

// Number of years you want total
$yearEnd=$year+10;

// Generate Drop Down
for($year=$year; $year = $yearEnd; $year++) {
   print option value=\$year\$year/option;
}


Thanks. This was close, but it didn't account for the first option  
being last year. I edited and ended up with this which works.


// Grabs current Year
$year=date(Y);
$yearFirst = $year-1;
// Number of years you want total
$yearEnd=$year+2;

// Generate Drop Down
echo select\n;
for($year=$yearFirst; $year = $yearEnd; $year++) {
   print option value=\$year\$year/option;
}
echo /select\n;

Al Padley

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



Re: [PHP] Dynamic Year Drop Down

2006-11-16 Thread Albert Padley
Thanks, Larry. This was close, but didn't quite work. I played around  
with the syntax and the following worked great.


$this_year = date('Y');
echo select\n;
for ($i= $this_year-1; $i  $this_year+3; ++$i) {
echo option value='$i';
if($i == $this_year)
echo selected = 'selected';
echo  . $i . /option\n;
}   
echo /select\n;

Al Padley

On Nov 16, 2006, at 11:32 PM, Larry Garfield wrote:


Quite simple:

$this_year = date('Y');
for ($i= $this_year-1; $i  $this_year+3; ++$i) {
  print option value='$i' .
($i==$this_year ? selected='selected' : '') . $i/option\n;
}

Obviously modify for however you're doing output.  (Note that you  
DO want to
have the redundant value attribute in there, otherwise some  
Javascript things
don't work right in IE.  Good habit to get into.)  I don't think it  
can

really get more simple and elegant.

On Thursday 16 November 2006 23:26, Albert Padley wrote:

I want to build a select drop down that includes last year, the
current year and 3 years into the future. Obviously, I could easily
hard code this or use a combination of the date and mktime functions
to populate the select. However, I'm looking for a more elegant way
of doing this.

Thanks for pointing me in the right direction.

Al Padley


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



[PHP] For Loop

2006-06-20 Thread Albert Padley

I have a regular for loop - for($i=1; $i100; $i++)

Within the loop I need to create variables named:

$p1name;
$p2name;
$p3name;
etc.

The integer portion of each variable name needs to be the value of $i.

I can't seem to get my syntax correct?

Can someone point me in the right direction?

Thanks.

Albert Padley

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



Re: [PHP] For Loop

2006-06-20 Thread Albert Padley
Thanks everyone. Always nice to know there is more than one direction  
to go in.


Albert


On Jun 20, 2006, at 4:52 PM, Ray Hauge wrote:


On Tuesday 20 June 2006 15:28, Adam Zey wrote:

Ray Hauge wrote:

On Tuesday 20 June 2006 15:14, Albert Padley wrote:

I have a regular for loop - for($i=1; $i100; $i++)

Within the loop I need to create variables named:

$p1name;
$p2name;
$p3name;
etc.

The integer portion of each variable name needs to be the value  
of $i.


I can't seem to get my syntax correct?

Can someone point me in the right direction?

Thanks.

Albert Padley


If you really want to keep the p?name syntax, I would suggest  
throwing

them in an array with keys.

$arr[p1name]
$arr[p2name]

Then that way you can create the key dynamically:

$arr[p.$i.name]

Not pretty, but it works.

Thanks,


I haven't checked this, but couldn't you reference it as $arr[p 
$iname]

? Is there a reason why variable expansion wouldn't work in this
circumstance?

If it does, you could make it easier to read by doing $arr[p{$i} 
name]

even though the {} aren't required. It'd be a lot easier to read than
concatenations :)

Regards, Adam.


Both of those ways work.  I think there's a question on the PHP  
Certification

Exam about the different ways to work with strings.

--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

--
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] var_dump($POST)

2006-04-13 Thread Albert Padley


On Apr 13, 2006, at 12:16 AM, William Stokes wrote:


Hello,
var_dump($POST) returns now always NULL.


Try var_dump($_POST);

Note the underline between $ and P.

Al Padley

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



[PHP] Proper OOP Syntax

2006-02-20 Thread Albert Padley

Given the following code:

$password = (strlen($this-user_pw)  32) ? md5($this-user_pw) :  
$this-user_pw;
			$sql = sprintf(SELECT COUNT(*) AS test, TeamID FROM %s WHERE  
BINARY login = '%s' AND pw = '%s' AND active = 'y', $this- 
table_name, $this-user, $password);

}
$result = mysql_query($sql) or die(mysql_error());
if (mysql_result($result, 0, test) == 1) {
return true;
} else {
return false;
}

How would I set a session variable for the value of TeamID?

Thanks.

Albert Padley

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



Re: [PHP] Proper OOP Syntax

2006-02-20 Thread Albert Padley

Thank you Chris.

Albert


On Feb 20, 2006, at 5:00 PM, Chris wrote:


Albert Padley wrote:

Given the following code:
$password = (strlen($this-user_pw)  32) ? md5($this-user_pw) :   
$this-user_pw;
$sql = sprintf(SELECT COUNT(*) AS test, TeamID FROM % 
s WHERE  BINARY login = '%s' AND pw = '%s' AND active = 'y',  
$this-  table_name, $this-user, $password);

}
$result = mysql_query($sql) or die(mysql_error());
if (mysql_result($result, 0, test) == 1) {
return true;
} else {
return false;
}
How would I set a session variable for the value of TeamID?


You'll need to change it so you actually fetch the teamid:


$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_assoc($result);
if (empty($row)) {
  return false;
}

$_SESSION['TeamID'] = (int)$row['TeamID'];
return true;


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



RE: [PHP] How to output multiple tables nicely(!) from PHP in Excelformat?

2006-02-08 Thread Albert
Olaf Greve wrote:
 I would still be very interested in a way to get the 3 tables sent to 
 different tabs though, but I'm not certain the way I do it can take care 
 of that.

Last time I needed (3 years ago) to output something to MS Excel format, I
used Excel Writer (http://phpclasses.fonant.com/browse/package/2037.html).
Not sure if it support tabs though but you can change the column sizes, row
sizes and formatting of cells.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/253 - Release Date: 2006/02/07
 

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



RE: [PHP] LIMIT?

2006-02-06 Thread Albert
William Stokes wrote:
 One page one there's headline and short summary and the second page should

 be archive with only the headline so all remaining rows can be printed 
 to one page.

 Something like: SELECT *  FROM `x_news` LIMIT 0 , 15 but how to do the 
 archive page SELECT * FROM `x_news` LIMIT 16 , xx?

I've scanned the MySQL Reference Manual (for up to Version 5.0.4-beta) and:


To retrieve all rows from a certain offset up to the end of the result set,
you can use some large number for the second parameter. This statement
retrieves all rows from the 96th row to the last: 

mysql SELECT * FROM table LIMIT 95,18446744073709551615;


HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 2006/02/04
 

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



RE: [PHP] Till Drawers

2006-02-03 Thread Albert
Oli Howson wrote:
 I'm interested in the possibility of connecting a computer running A 
 PHP server to a till drawer and have the server able to open the 
 drawer. Anyone know how this would work?

That all depends on how your till drawer opens.

The easiest would be to write a command line utility in C which opens your
cash drawer. When you need to open the drawer you run the application from
the PHP script using exec().

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.0/249 - Release Date: 2006/02/02
 

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



[PHP] Unique Names for Variable in Loop

2006-02-02 Thread Albert Padley

I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each  
last name returned needs to be assigned to a unique variable like  
name1, name2, name3, etc.


Somebody just kick me in the right direction.

Thanks.

Al Padley

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



Re: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Albert Padley

Yes, that's it. Thanks for the swift kick.

AP


On Feb 2, 2006, at 12:37 PM, Jim Moseby wrote:



I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each
last name returned needs to be assigned to a unique variable like
name1, name2, name3, etc.


How about $names[1], $names[2], $names[3]?

JM

--
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] Passing Credentials

2006-02-01 Thread Albert
News1 wrote:
 Thanks for all of the input!  I have tried a new tactic, using CURL.  I've
 had some success with grabbing a web page, but when I try to pass
 credentials, I get an error.  I tried following examples from various 
 sites (which all had different implementations), but I was unsuccessful.

Here is the file I came up with:

1 ?php
2 $ch = curl_init();
3 curl_setopt($ch, CURLOPT_URL, http://www.example.com;);
4 curl_setopt($ch, CURLOPT_HEADER, 1);
5 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
6 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
7 curl_setopt($ch, CURLOPT_USERPWD, 'user:password')
8 curl_exec($ch);
9 curl_close($ch);
10 ?

 I get the following error:

 Parse error: parse error in /var/www/html/sess6.php on line 8

 If anyone has a suggestion, I would greatly appreciate it.

I've added line numbers to your code. Now look at the end of line 7. You
will see a missing ;. This is probably your parse error.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.25/247 - Release Date: 2006/01/31
 

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



RE: [PHP] image uploads

2006-01-31 Thread Albert
William Stokes wrote:
 I somehow got it back working with Opera. Don't know how :) One question 
 still remains. How to make 100% sure that the image isn't re-loaded to 
 server if user hits refresh? And he will cause it can take long time to 
 upload 2.5Mb pics over a slow link.

When you hit refresh/reload in the browser then the browser send the data to
the server again. No way around this. You can make sure that you do nothing
with the data received by follow the uniqid() method described earlier.

Do you really want people uploading 2.5MB a shot to your server? Why not
limit it to 512KB?

Albert



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.25/247 - Release Date: 2006/01/31
 

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



RE: [PHP] this line throws up an undefined index.

2006-01-30 Thread Albert
Ross wrote:
 ? $filename = basename($_SERVER['SCRIPT_FILENAME']);
 $link= ../text_only/$filename;
 ?


 any ideas how to prevent this error?

From the PHP Documentation:
$_SERVER is an array containing information such as headers, paths, and
script locations. The entries in this array are created by the webserver.
There is no guarantee that every webserver will provide any of these;
servers may omit some, or provide others not listed here. That said, a large
number of these variables are accounted for in the » CGI 1.1 specification,
so you should be able to expect those. 

If you are executing a script on the command line it will not exist.

Try using argc and argv for that. The filename is typically argv[0].

isset($_SERVER['SCRIPT_FILENAME']) will return true if the index exist.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 2006/01/27
 

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



RE: [PHP] writing multidimensional arrays to file ?

2006-01-30 Thread Albert
Gregory Machin [mailto:[EMAIL PROTECTED] 
 Hi
 I'm looking for a good example of writing multidimensional arrays, and
 reading them back .

http://za2.php.net/manual/en/function.serialize.php
and
http://za2.php.net/manual/en/function.unserialize.php

Call serialize() when saving the array to the file and unserialize() to read
it back

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 2006/01/27
 


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



[PHP] Vbulletin question

2006-01-30 Thread Albert Peschar
Hi. I have a small question ;-). I have a PHP script. I want that script to 
check if a visitor is logged in, in Vbulletin. I know somebody who did this but 
he says he doesn't has time to explain. So if a visitor is logged in, in the 
vbulletin forum and he visits my PHP script, that script has to check if the 
user is logged in or not.

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



RE: [PHP] Retrieve output from HTML or PHP file

2006-01-29 Thread Albert
Peter Lauri wrote:
 As I read in the documentation it only takes the content of the file. If
 there is a script in the file I want that to be fun first. A file like 
 this:

 --
 HTLM content
 ?php echo 'Hello World';  ?
 HTML content
 --

 I want the result from my function to be

 --
 HTLM content
 Hello World
 HTML content
 --

 The file_get_contents('file.html') will give me

 --
 HTLM content
 ?php echo 'Hello World';  ?
 HTML content
 --

 Or am I not correct?

Yes you are correct.

Why don't you include the file? PHP will parse the PHP inside it and output
the HTML...

If you want to get the contents into a variable then do something like:
?
ob_start();
include(file.html);
$fileContent = ob_get_contents();
ob_clean();
?

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 2006/01/27
 

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



RE: [PHP] PHP / Apache + Error 500

2006-01-25 Thread Albert
Thomas wrote:
 I had a look at the Apache log file I got from the SP ... no clue. All I
 know is that they use Apache 1.x/PHP5/Linux/MySQL(v4?).

Did you look at the access_log or error_log?

The error_log should give you an indication of why it is happening.

Do you try to access system files or use a lot of memory? Are you sure that
the production server has all the modules installed that your testing server
has? Quite important, is the same version installed on your testing server
as on the production server?

 They say that it is not their server but my scripts, however, if that was
 the case I would get these errors on my machine too. Also, the randomness
 of this also indicates that it can't really be my php scripts, otherwise 
 it would happen all the time.

Yes and no. You can only say that with certainty if your test and production
environments are the same. 

If you are absolutely 100% certain that it is not your scripts, start
looking at the differences between what you have and what your ISP provides.

Alternatively test it on another server as well. 

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.22/239 - Release Date: 2006/01/24
 

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



RE: [PHP] forwarding from virtual email account to real email account

2006-01-25 Thread Albert
Binay wrote:
 Is it possible that we create a virtual email account(no physical 
 existence) e.g [EMAIL PROTECTED] which will be associated with a real email
 account e.g. [EMAIL PROTECTED] so that if any body sends the email to virtual
 email account [EMAIL PROTECTED] will be automatically forwarded to the real
 email account [EMAIL PROTECTED] Is it achievable using PHP ? Please throw 
 some light as this becoming a major requirement of my client.

What you described here is called MAIL FORWARDING or often MAIL ALIASSING.

It is a functionality of your mail server.

Contact your ISP for assistance on setting this up. If you run your own mail
server look at the docs.

If you want to use PHP for this (not recommended because the mail server can
do it already) you need to write a script which check email on one account
and then email it to the other accounts.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.22/239 - Release Date: 2006/01/24
 

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



RE: [PHP] Re: query problem.

2006-01-24 Thread Albert
Angelo Zanetti wrote:
 Why does the   cause that not to be displayed? or is it retrieving it 
 correctly but not showing it because of the   (which might be 
 conflicting with HTML tags?

Whenever you have something between   for example 

this will not show

The browser will interpret it as an HTML tag and not display it.

Have a look at htmlentities() or replace the  and  with lt; and gt;

HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.22/238 - Release Date: 2006/01/23
 

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



RE: [PHP] Help with getting PHP to see Pear.

2006-01-23 Thread Albert
Payne wrote:
 How can I get php to see pear, it is installed.  I have install modules 
 with pear for maia and horde but neither seem to see pear.

I'm running SuSE 9.3 and had to add /usr/share/php to the include path in
/etc/php.ini to be able to use the installed PEAR extensions.

To enable bcmath I had to uncomment the extension=bcmath.so line in
/etc/php.ini 

Check that phpinfo() outputs bcmath.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.22/238 - Release Date: 2006/01/23
 

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



RE: [PHP] New identification after an error...

2006-01-20 Thread Albert
David BERCOT wrote:
 I use this program to force a user to authenticate :
 if (!isset($_SERVER[PHP_AUTH_USER])) {
 header(WWW-Authenticate: Basic realm=\Intranet SDSED\);
 header(HTTP/1.1 401 Unauthorized);
 }
 Everything is ok except a detail : if the user makes a mistake (for
 example, a bad password), the variable $_SERVER[PHP_AUTH_USER] is
 initialised.
 So, if he wants to do again the above test, another identification won't
 happen (because $_SERVER[PHP_AUTH_USER] is already set).
 I've tried :
 $_SERVER[PHP_AUTH_USER] = NULL;
 without succes...
 
 Do you have a clue ?

?
  if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm='._PRODNAME.'');
header('HTTP/1.0 401 Unauthorized');
echo You are not authorized to enter this page;
  } else {
$inUser = $_SERVER['PHP_AUTH_USER'];
$inPWD = $_SERVER['PHP_AUTH_PW'];

if (strcmp($inUser, 'me') == 0  strcmp($inPWD, 'me') == 0) {
  echo logged in;
} else {
  header('WWW-Authenticate: Basic realm='._PRODNAME.'');
  header('HTTP/1.0 401 Unauthorized');
  echo You are not authorized to enter this page;
}
  }
?

HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date: 2006/01/19
 

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



RE: [PHP] PHP Cache (was PHP load to high on server)

2006-01-19 Thread Albert
Jochem Maas wrote:
 take note that APC does 2 things:

 1. op code caching
 2. manage some shared memory (a central place where you can stick stuff
 that needs to be read again and again and again; but doesn't need updating
 very often)

pear install apc failed without reason. I ended up downloading the package
and building it manually.

I opened my login page (worked fine) and then logged in only to get a
Cannot find server. I had to restart Apache to get any other page out.

On inspection of the Apache error log I saw:
[Thu Jan 19 06:47:49 2006] [notice] child pid 16429 exit signal Segmentation
fault (11)

I have Zend Optimizer installed as well. When disabled Zend Optimizer my
server works correctly. When Zend Optimizer is enabled then I get the
segfaults.

It seems that APC and Zend Optimizer does not work together so I cannot use
APC as some of the modules we use from third party suppliers have been
encoded with Zend Safeguard.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.20/234 - Release Date: 2006/01/18
 

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



RE: [PHP] PHP load to high on server

2006-01-19 Thread Albert
Richard Lynch wrote:
 On Tue, January 17, 2006 11:18 pm, Albert wrote:
  The page having the heaviest load uses 5 simultaneous sessions - they
  refresh every 5 seconds. Even with just one connection there are 16
  Apache
  threads running all occupying between 5 and 20% of CPU.

 Are you saying that you have a page that chews up 5 HTTP connections,
 and each uses PHP heavily, and you reload that page every 5 seconds?

I have a page that loads which never refreshes. 

It displays three images generated with PHP. The three images updates at
least once every 5 seconds because the content actually changes. 

It also has an information page displaying information about the three
images which also updates every time the image changes.

 Maybe you shouldn't do that...

 Stretch it out to 10 seconds and see where your load goes.

At 10 seconds all the problems disappear. Unfortunately the customer
requires this to update at least every 5 seconds.

 Find out which of the 5 sessions is most expensive (slowest).  Can you
 cache the results of that one?  How about the second slowest?  Can you
 cache ANYTHING to make the application faster?

I am now busy converting the three images and info page to use a cached copy
if they have not changed.

  Does anyone have an idea of what I can do (short of recoding)?
 #1. Buy more hardware, and build a server farm.
On the lowest end of the spectrum (up to 5 simultaneous users) I have to
make it work on a Celeron 400 with 512MB RAM.

At the highest end (up to 100 simultaneous users) I have a Dual Xeon 3.4GHZ
with 2GB RAM and SCSI drives.

 #2. Buy the Zend Cache
Will probably to that for the top end machines. The Zend Cache costs more
than my lowest end machine after assembly.

 #3. Install some other Cache product (most of which aren't as
 good/fast/solid as Zend Cache, imho)
I tend to trust Zend a bit more than the other developers (maybe because PHP
is based on the Zend engine).

If I didn't have budget constraints then I would have had the Zend Cache on
each and every machine leaving my office.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.20/234 - Release Date: 2006/01/18
 

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



RE: [PHP] PHP Cache (was PHP load to high on server)

2006-01-18 Thread Albert
I wrote:
 I am running SuSE 9.2 (Kernel 2.6.8-24-default) with Apache 2.0.50 and PHP
 4.3.8 (as an Apache module) on a Celeron 900 with 304MB RAM. This machine 
 is used for testing. We have made some changes to our PHP application and 
 now the machine is having trouble serving the pages. Apache is occupying 
 almost 90% CPU usage.

I have resolved this issue by removing a piece of code which reads a set of
parameters from a database. It seems that the hard disk on the machine is
quite slow, slowing down all database access with it...

I now check if the parameters are set in the session, if it is I use them
otherwise I read them from the database and save it as session variables.
When it changes I simply remove it from the session so it forces an update.
So far it is working quite well.

I now want to go and take all the static stuff that the user will configure
once in a life time and put it in the session and only update it when it
changes instead of reading it from the database every five seconds or so.

For this I don't want to use a disk based session handler. I want the
session variables to remain in memory (about 20KB per user) as to speed up
the whole process. 

I also want an opcode cache to cache the compiled pages on the server in an
attempt to speed up the HTTP server.

For this I wanted to use mmCache (actually I want to use Zend Performance
Suite but first I need to prove that it is worth $ 1000 per CPU and from the
stats on the mmCache site mmCache is faster...) but it seems that the
mmCache project has been abandoned as there have been no work done on it
since 2003.

Can someone confirm this or recommend an alternate cache (doesn't have to be
free but should break the bank) which will do what I want? 

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.20/233 - Release Date: 2006/01/18
 

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



[PHP] PHP load to high on server

2006-01-17 Thread Albert
 Hi

 

I am running SuSE 9.2 (Kernel 2.6.8-24-default) with Apache 2.0.50 and PHP
4.3.8 (as an Apache module) on a Celeron 900 with 304MB RAM. This machine is
used for testing. We have made some changes to our PHP application and now
the machine is having trouble serving the pages. Apache is occupying almost
90% CPU usage.

 

My Apache log configuration is: 

%a %b %H %r %s %t %T %X 

%a : Remote IP 

%b : Size of response 

%H : Protocol 

%r : Request 

%s : Last status of request 

%t : Time of request 

%T : Time to serve 

%X : Connection status after serving request

 

In the log below the last character after the timestamp indicates the
following:

X : Connection terminated before end serving request

+ : Connection might not be terminated

- : Connection terminated

 

As you will notice almost all the statuses is connection might not have been
terminated.

 

The page having the heaviest load uses 5 simultaneous sessions - they
refresh every 5 seconds. Even with just one connection there are 16 Apache
threads running all occupying between 5 and 20% of CPU.

 

Does anyone have an idea of what I can do (short of recoding)?

 

TIA

 

Albert

 

From our Apache log:

192.168.x.x 216 HTTP/1.1 GET /selObject.php HTTP/1.1 200

[17/Jan/2006:16:16:29 +] 1 X

192.168.x.x 1845 HTTP/1.1 GET /msgMon.php?h=3D1024w=3D1280 HTTP/1.1 200

[17/Jan/2006:16:16:28 +] 2 +

192.168.x.x 3711 HTTP/1.1 GET /display_menu.php HTTP/1.1 200

[17/Jan/2006:16:16:29 +] 1 +

192.168.x.x 2839 HTTP/1.1 GET /gd.php HTTP/1.1 200 [17/Jan/2006:16:16:29

+] 2 +

192.168.x.x 3279 HTTP/1.1 GET /display_target_information.php HTTP/1.1 200

[17/Jan/2006:16:16:31 +] 1 +

192.168.x.x 216 HTTP/1.1 GET /selObject.php HTTP/1.1 200

[17/Jan/2006:16:16:31 +] 1 +

192.168.x.x 13353 HTTP/1.1 GET /validation.php HTTP/1.1 200

[17/Jan/2006:16:16:33 +] 0 +

192.168.x.x 429 HTTP/1.1 GET /display_background.php HTTP/1.1 200

[17/Jan/2006:16:16:32 +] 2 +

192.168.x.x 178 HTTP/1.1 GET /selObject.php HTTP/1.1 200

[17/Jan/2006:16:16:33 +] 3 +

192.168.x.x 3325 HTTP/1.1 GET /display_target_information.php HTTP/1.1 200

[17/Jan/2006:16:16:33 +] 3 +

192.168.x.x 3711 HTTP/1.1 GET /display_menu.php HTTP/1.1 200

[17/Jan/2006:16:16:33 +] 3 X

192.168.x.x 1249 HTTP/1.1 GET /gd.php HTTP/1.1 200 [17/Jan/2006:16:16:33

+] 4 +

192.168.x.x 3279 HTTP/1.1 GET /display_target_information.php HTTP/1.1 200

[17/Jan/2006:16:16:34 +] 3 +

192.168.x.x 13353 HTTP/1.1 GET /validation.php HTTP/1.1 200

[17/Jan/2006:16:16:37 +] 1 +

192.168.x.x 431 HTTP/1.1 GET /display_background.php HTTP/1.1 200

[17/Jan/2006:16:16:35 +] 3 +

192.168.x.x 2823 HTTP/1.1 GET /gd.php HTTP/1.1 200 [17/Jan/2006:16:16:35

+] 4 +

192.168.x.x 13353 HTTP/1.1 GET /validation.php HTTP/1.1 200

[17/Jan/2006:16:16:39 +] 0 +

192.168.x.x 1845 HTTP/1.1 GET /msgMon.php?h=3D768w=3D1024 HTTP/1.1 200

[17/Jan/2006:16:16:37 +] 3 +

192.168.x.x 216 HTTP/1.1 GET /selObject.php HTTP/1.1 200

[17/Jan/2006:16:16:38 +] 3 X

192.168.x.x 3711 HTTP/1.1 GET /display_menu.php HTTP/1.1 200

[17/Jan/2006:16:16:39 +] 2 X

192.168.x.x 3711 HTTP/1.1 GET /display_menu.php HTTP/1.1 200

[17/Jan/2006:16:16:39 +] 2 +

192.168.x.x 3279 HTTP/1.1 GET /display_target_information.php HTTP/1.1 200

[17/Jan/2006:16:16:39 +] 3 +

192.168.x.x 2828 HTTP/1.1 GET /gd.php HTTP/1.1 200 [17/Jan/2006:16:16:39

+] 3 +

192.168.x.x 429 HTTP/1.1 GET /display_background.php HTTP/1.1 200

[17/Jan/2006:16:16:42 +] 2 +

192.168.x.x 178 HTTP/1.1 GET /selObject.php HTTP/1.1 200

[17/Jan/2006:16:16:43 +] 2 +

192.168.x.x 3325 HTTP/1.1 GET /display_target_information.php HTTP/1.1 200

[17/Jan/2006:16:16:43 +] 3 +

192.168.x.x 1260 HTTP/1.1 GET /gd.php HTTP/1.1 200 [17/Jan/2006:16:16:43

+] 3 +

192.168.x.x 1845 HTTP/1.1 GET /msgMon.php?h=3D1024w=3D1280 HTTP/1.1 200

[17/Jan/2006:16:16:43 +] 3 +

192.168.x.x 13353 HTTP/1.1 GET /validation.php HTTP/1.1 200

[17/Jan/2006:16:16:46 +] 0 +

192.168.x.x 3279 HTTP/1.1 GET /display_target_information.php HTTP/1.1 200

[17/Jan/2006:16:16:44 +] 1 +

192.168.x.x 216 HTTP/1.1 GET /selObject.php HTTP/1.1 200

[17/Jan/2006:16:16:46 +] 1 +

192.168.x.x 2807 HTTP/1.1 GET /gd.php HTTP/1.1 200 [17/Jan/2006:16:16:46

+] 1 +

192.168.x.x 13353 HTTP/1.1 GET /validation.php HTTP/1.1 200

[17/Jan/2006:16:16:48 +] 0 +

192.168.x.x 3711 HTTP/1.1 GET /display_menu.php HTTP/1.1 200

[17/Jan/2006:16:16:48 +] 0 +

192.168.x.x 3711 HTTP/1.1 GET /display_menu.php HTTP/1.1 200

[17/Jan/2006:16:16:48 +] 0 +

192.168.x.x 431 HTTP/1.1 GET /display_background.php HTTP/1.1 200

[17/Jan/2006:16:16:49 +] 1 +

192.168.x.x 216 HTTP/1.1 GET /selObject.php HTTP/1.1 200

[17/Jan/2006:16:16:49 +] 1 +

192.168.x.x 2808 HTTP/1.1 GET /gd.php HTTP/1.1 200 [17/Jan/2006:16:16:49

+] 2 +

192.168.x.x 3279 HTTP/1.1 GET /display_target_information.php HTTP/1.1 200

[17/Jan/2006:16:16:51 +] 1 +

192.168

RE: [PHP] mail not sent to certain mail accounts

2006-01-16 Thread Albert
Angelo Zanetti wrote:
 I'm using the PHP mail function to send a confirmation email to a person 
 once they register on the site. A few thing that happens with 2 of the 
 mail accounts that we're testing to receive the mail is that the mail 
 never is received. One of the mail accounts is a Yahoo account, the 
 other a local email from a service provider.

It is most probably a SPAM filter.

Make sure that you are using a valid email address to send from and that the
relay you use is not blacklisted somewhere.

I tend to rather use PHPMailer
(http://www.phpclasses.org/browse/package/264.html) when sending email as it
does most of the hard work for you.

Albert
PS List replies only please!

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



RE: [PHP] Regex help

2006-01-13 Thread Albert
Mike Smith wrote:
 I'm trying to save myself some time by extracting certain variables
 from a string:

 102-90 E 42 X 42 X 70 3/8

If this string is always in this format 

xxx E panel X width X height

then you could try something like:

// Very much untested
$unit = '102-90 E 42 X 42 X 70 3/8';
$split1 = explode('E', $unit);
list($panel, $width, $height) = explode('X', $split1[1]);

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.17/228 - Release Date: 2006/01/12
 

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



RE: [PHP] Parsing a large file

2006-01-13 Thread Albert
Wolf wrote:
 I have large log files from a web server (about a gig in size) and need
 to parse each line looking for a string, and when encountered push that
 line to a new file.  I was thinking I could have PHP read in the whole
 file, but thinking it could be a major pain since I have about 20 log
 files to read through.

 Anyone have some suggestions?

Is this on a Linux server?

Why don’t you use grep?

cat filename | grep string  newfile

see man grep for detail on grep. (It uses regular expressions)

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.17/228 - Release Date: 2006/01/12
 

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



RE: [PHP] transferring db info

2006-01-12 Thread Albert
David Grant wrote:
 Ross wrote:
  Can you just export the mysql? Will the pdfs be exported as binary data?

  Will I have to re-upload them? (there are hundereds).

 Try using mysqldump to pull the data into a flat file full of SQL
 statements.  You can then use the mysql command to reinsert the data.

An alternate method, which I found to be more reliable, would be to put the
database files in a tarball, transfer it to the new server and then extract
the tarball into the database directory.

I am running MySQL on a Linux server. The databases are in /var/lib/mysql.

If your database is called db then there will be a db directory in
/var/lib/mysql.

Before making the backup you either need to stop MySQL (preferred) or flush
all data to tables and make sure nothing is writing/reading to/from the
database.

To put it in a tarball:
origin# cd /var/lib/mysql
origin# tar cvf db_backup_20060112.tar db

You then copy that db_backup_20060112.tar file to the MySQL data directory
of your destination server and once it's there extract it again:
origin# scp db_backup_20060112.tar [EMAIL PROTECTED]
destination# cd /var/lib/mysql
destination# tar xvf db_backup_20060112.tar

You then might need to set permissions if the UID of your origin server
MySQL user and destination server MySQL user is not the same.

After starting MySQL server on your destination server you should have the
database exactly like it was on the original.

BTW you can transfer MySQL data files from a Windows machine to a Linux
machine and vice versa without any issues. There is a note in the MySQL
documentation of the formatting your Windows server should use (to do with
case sensitivity)

HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.17/227 - Release Date: 2006/01/11
 

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



RE: [PHP] Image size?

2006-01-11 Thread Albert
William Stokes wrote:
 Can I get pixel sizes from a uploaded web applicable image with PHP? I
 mean width and height as pixels. If  so How?

http://www.php.net/manual/en/function.getimagesize.php

HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.17/226 - Release Date: 2006/01/10
 

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



RE: [PHP] Browser on server doesn't refresh

2006-01-10 Thread Albert
Mike Tuller wrote:
 locally, everything works. When I put the script on my OS X Server  
 and run the script, and click on the link to go back, the information  
 is not updated. I have to refresh the page.

 PHP 5.04 on my laptop and 4.3.11 on the server. Is there some setting  
 in Apache that would cause the page not to refresh?

It sounds to me that there is a caching problem somewhere.

Try adding the following to the top of the page:
?
  header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
  header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);
  header(Cache-Control: no-store, no-cache, must-revalidate);
  header(Cache-Control: post-check=0, pre-check=0, false);
  header(Cache-Control: private);
  header(Pragma: no-cache);
?

It will tell any caching server and/or browser not to cache the page

Albert
PS List replies only please!

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.16/225 - Release Date: 2006/01/09
 

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



RE: [PHP] Sending mail with php-

2006-01-10 Thread Albert
Dotan Cohen wrote:
 But I still get the error! I did restart apache and even went so far as to
 reboot the machine. If I cannot modify the parameter within apache,
 then where should I modify it? Within php? Within sendmail?

Look for the sendmail_from parameter in the mail function section of
php.ini.

Or define the additional parameters:

[quote from PHP documentation]
bool mail ( string to, string subject, string message [, string
additional_headers [, string additional_parameters]] )
[/quote]

[quote from Example 486. Sending mail with extra headers and setting an
additional command line parameter. In PHP documentation]
?php 
mail([EMAIL PROTECTED], the subject, $message, 
From: [EMAIL PROTECTED]'SERVER_NAME']},
[EMAIL PROTECTED]'SERVER_NAME']}); 
?
[/quote]

HTH

Albert
PS List replies only please!

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.16/225 - Release Date: 2006/01/09
 

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



RE: [PHP] php + mysql - timstamp - calculate hours remaining

2006-01-10 Thread Albert
Gregory Machin wrote:
 I have a table with a timestamp column and would like to use his to
 calculate the age of the record . how would i go about this...

Convert your timestamp to a unix timestamp (see mktime() function).

Use the value returned by time() to calculate the difference in seconds.

$age = time() - $tableTimestamp;

Divide by 3600 to get hours

 I would also like to exicute a mysql stament that pasess the tables and
 removes fields older than say 72 hours. how would i go about this . ?

Get a timestamp of 72 hours ago:

$olderThan72Hours = time() - (72 * 3600);

Convert to the same format as your timestamp column:

$timestamp = date('Y-m-d H:i:s', $olderThan72Hours);

Delete the records from the table:
mysql_query(DELETE FROM table WHERE timestamp = '$timestamp') or
die('Could not delete from table');

HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.16/225 - Release Date: 2006/01/09
 

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



RE: [PHP] php + mysql - timstamp - calculate hours remaining

2006-01-10 Thread Albert
I wrote:
 Delete the records from the table:
 mysql_query(DELETE FROM table WHERE timestamp = '$timestamp') or
 die('Could not delete from table');

That query should be

DELETE FROM table WHERE timestamp = '$timestamp'

Sorry about that.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.16/225 - Release Date: 2006/01/09
 

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




RE: [PHP] Sending mail with php-

2006-01-10 Thread Albert
Dotan Cohen wrote: 
 That most certainly is how I do it- just like TFM says! Actually, the
 last field is a variable that is defined earlier, but I have outputed
 it's contents to the screen to verify that it contains what it should.

Have a look at PHPMailer (http://www.phpclasses.org/browse/package/264.html)

It has made my life a lot easier.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.16/225 - Release Date: 2006/01/09
 

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



RE: [PHP] Case-Insensitive include on linux.

2006-01-10 Thread Albert
Mathijs wrote:
 Is there a way to have include() be case-insensitive?
Linux file systems are case sensitive. The include() and require() functions
try to open the file specified. If you enter the wrong case the file system
will return that the file does not exist.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.17/226 - Release Date: 2006/01/10
 

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



RE: [PHP] Setting cookie for two domains.

2006-01-05 Thread Albert
Shafiq Rehman wrote:
 How can I register a session or cookie for two domains. I want to maintain
 logged user's state when he goes from one domain to other domain.

My Sat TV provider uses something like what you want to allow me to navigate
through their website and the websites of different channels without having
to login on each website.

Basically how I think they do it:
- They have a database with the subscriber information which is shared by
all the sites.

- When you login, a popup window open (if popups are disabled it happens in
your main window) which jumps from domain to domain and set the cookie with
your session id.

- When you logout the database does no longer contain the session id. The
cookie is still set but the site checks the validity of the session id and
if it is not valid anymore then you have to login again.

So basically:

After login you set the session cookie then open a page on the other domain
passing the session id to it with GET / POST. That page sets the cookie for
that domain and sends the user on in the process.

When you logout you can then unset the cookie on the domain and open a page
on the other domain to unset the cookie or simply invalidate the session id
in a database. If you do this you need to check if the session id is still
valid when you open a page.

The actual session data should then be in a database (or similar) accessible
by both domains.

Hope it helps

Albert

List replies only please!!

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.13/221 - Release Date: 2006/01/04
 

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



RE: [PHP] download not working

2005-12-28 Thread Albert
Ross wrote:
 The pdf is fine, there are no errors . All I get is a small (130byte) pdf 
 file which is corrupt when I try and open it.

From the code I gather you are saving the uploaded file in the database. 
1 - What field type are you using for this? 
2 - Are you using some form of encoding (eg base64_encode()) before writing
it database and decoding when reading it from the database?
3 - Why not save the file to disk with a reference to the correct filename
in the database? It will most probably solve your issue.

I have tried this saving the file into the database before and could only
get it to work reliably by:
- base64_encode() on the content of the file
- keeping the files below 100kbyte (It was way back with MySQL 3.x and it
seemed that MySQL couldn’t save such large amounts of data in a blob or text
field

I ended up uploading it to disk into a directory not accessible to someone
from the outside but accessible by the user Apache was running as. Then by
reading the content from the file with PHP and outputting in a similar
method as you are using.

Hope it helps

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.8/215 - Release Date: 2005/12/27
 

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



RE: [PHP] download not working

2005-12-28 Thread Albert
 Ross wrote:
 $query= SELECT * FROM publications WHERE alphabet='a';

  $result= mysql_query($query);
while  ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){

 $row['pdf_size'] = $row['pdf_size']/ 1024;
  $row['pdf_size']= number_format($row['pdf_size'], 0);
  $size= $row['pdf_size'];
 $name = str_replace(_,  , $row['pdf_name']);
 $name = str_replace(.pdf, , $name);
 $link= $row['content'];

 echo span class=\pdflinks\$name/span;
 echo nbsp;nbsp;;
 echo span class=\sizes\($size kb)/span;
 //a href=#ross/a
 ?
 download is here..
 a href=a-z.php?id=?=$row['id'];?link/a br

You need to make sure that the code above doesn't output anything when
isset($_GET['id']).

 ?

 if(isset($_GET['id']))
 {
  echo id is this;

You should not have any output before you send your headers and file
content.

 $id= $_GET['id'];
 $query = SELECT * FROM publications WHERE id = '$id';

 $result = mysql_query($query) or die('Error, query failed');

 $pdf_size=$row['pdf_size'];
 $pdf_type=$row['pdf_type'];
 $pdf_name=$row['pdf_name'];

Where does $row come from?

 ob_clean();
 header(Content-length: $pdf_size);
 header(Content-type: $pdf_type);
 header(Content-Disposition: attachment; filename=$pdf_name);
 echo $content;

Where does $content come from?



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.8/215 - Release Date: 2005/12/27
 

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



RE: [PHP] PHP interference in frames

2005-12-23 Thread Albert
 On 12/22/05, Ron Rudman [EMAIL PROTECTED] wrote:
 
I've got this down to a bare bones test but am still stumped.  Can anyone
explain why I get the behavior I do?

I have a frameset with 3 frames:
html
headtitletesting/title/head
frameset rows='100,100,*'
frame src='test1.php'/frame
frame src='test2.php'/frame
frame src='test3.php'/frame
/frameset
/html

test1.php and test2.php are both simply:? sleep(5); ?
test3.php is simply:   ? echo This is some content; ?

I tested this in both IE6 (6.0.2900.2180.xpsp.0503101-1521 to be exact) and
Mozilla Firefox 1.0.6 on Windows XP SP2 running Apache 1.33 with PHP 4.3.9
on the same machine.

In IE the content of test3.php is displayed immediately and 5 seconds later
the content of test1.php and test2.php (I've added an echo after the
sleep(5); to see what happens.

In Mozilla it takes 5 seconds to display test3.php. When I put that frame at
the top it displays immediately. If I put it in the middle it displays
immediately. 

What I do remember is that when I download multiple files (using IE or
Mozilla on WinXP) from the same server I can only do two downloads at a
time. I don't know if this is an OS setting. I did found a setting for IE
and changed that value to 5 so now I can download up to 5 files from the
same server at the same time. Don't know where to change it in Mozilla.

It therefore seems that the browser makes a connection to the server for the
first page and starts downloading it. At the same time it makes a connection
to the server for the second page and starts downloading it. After one of
these two have downloaded it start downloading the third page.

If you change the setting in the browser (like I did with IE) you can
download up to that number of pages at the same time.

It is therefore not an issue with PHP but with the browser. 

HTH

Albert 

(PS List replies only please!)

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.5/212 - Release Date: 2005/12/23
 

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



RE: [PHP] PHP interference in frames

2005-12-23 Thread Albert
Ron Rudman wrote:
 The log makes it look like *all* the frames are held back.  Seems like the
 request is logged when it completes, so the logging process can't show us
 whether the client held back frame 3 or frame 3 was put on hold by the
 server.

I checked my logs and it seems the same. But when I move test3.php to the
top or middle then it is loaded immediately after the frameset.

Using Mozilla:
Test3.php as the last frame:
127.0.0.1 - - [23/Dec/2005:14:23:40 +0200] GET /test/ HTTP/1.1 200 219
127.0.0.1 - - [23/Dec/2005:14:23:45 +0200] GET /test/page1.php HTTP/1.1
200 19
127.0.0.1 - - [23/Dec/2005:14:23:45 +0200] GET /test/page3.php HTTP/1.1
200 32
127.0.0.1 - - [23/Dec/2005:14:23:45 +0200] GET /test/page2.php HTTP/1.1
200 19

Test3.php as the middle frame:
127.0.0.1 - - [23/Dec/2005:14:24:47 +0200] GET /test/ HTTP/1.1 200 219
127.0.0.1 - - [23/Dec/2005:14:24:47 +0200] GET /test/page3.php HTTP/1.1
200 32
127.0.0.1 - - [23/Dec/2005:14:24:52 +0200] GET /test/page1.php HTTP/1.1
200 19
127.0.0.1 - - [23/Dec/2005:14:24:52 +0200] GET /test/page2.php HTTP/1.1
200 19

Test3.php as the top frame:
127.0.0.1 - - [23/Dec/2005:14:25:43 +0200] GET /test/ HTTP/1.1 200 219
127.0.0.1 - - [23/Dec/2005:14:25:43 +0200] GET /test/page3.php HTTP/1.1
200 32
127.0.0.1 - - [23/Dec/2005:14:25:48 +0200] GET /test/page2.php HTTP/1.1
200 19
127.0.0.1 - - [23/Dec/2005:14:25:48 +0200] GET /test/page1.php HTTP/1.1
200 19

This is either a Browser or an OS issue. Not a PHP/Apache issue.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.5/212 - Release Date: 2005/12/23
 

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



RE: [PHP] PHP interference in frames

2005-12-23 Thread Albert
David Hall wrote:
 Albert wrote:

  same server at the same time. Don't know where to change it in Mozilla.
  
  

 type about:config in browser window
 network.http.max-persistent-connections-per-server in the line
 the default value is 2, so I think that's our answer

Yes it resolved the issue.

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.5/212 - Release Date: 2005/12/23
 

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



RE: [PHP] a quick one, self submitting jump menu

2005-12-22 Thread Albert
Ross wrote:
 How can I self submit a page whne registered globals are off. Is there a 
 way to use $_SERVER?

Try $_REQUEST.

If the values are send using POST then $_POST

If the values are send using GET then $_GET

Albert


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.3/209 - Release Date: 2005/12/21
 

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



RE: [PHP] FW: Merging two images (GD PNG)

2005-12-01 Thread Albert
Jochem Maas wrote:
 the output image resource you create should be created with $xxx = 
 imagecreatetruecolor(1000,1000), you should call imagealphablending($xxx,
 true) on the output image resource after you create and before copying 
 [which you are as far as I can tell], and you should use 
 imagecopyresampled() to actually copy the image data into the final image 
 (instead of imagecopy()).

It seems that I have three problems:

1. It seems that true color images do not support transparency (even though
I'm outputting to a PNG). It does not matter which colour I set to be
transparent it always is displayed as black which hides my satellite image.

2a. Because I am now forced to use a paletted image instead of a true color
image it seems that the colours in the second image is not added to the
palette of the first image.

or

2b. The alpha blending on the image causes the actual colours in the top
image to be blended with the satellite image. Because of this the top image
are blended in with the satellite image. If I do not set imagealphablending
($im, true) then the transparency in the top image is ignored and I do not
see the satellite image.

This brings me back to the original problem:
I have a true colour satellite image in PNG format. On top of this I want to
add the data collected from data collected by my company. This is always
shapes drawn which should not be alpha blended with the satellite image.
These shapes are drawn on a transparent background. The transparent
background allows for the satellite image to show through.


Any suggestions are welcome.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/189 - Release Date: 2005/11/30
 

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



RE: [PHP] $_POST returns Array when getting data from multiple dropdown

2005-12-01 Thread Albert
Erfan Shirazi wrote:
 I want to get all data passed on to a certain page, I use this to make 
 it happen:
 
 foreach($_POST as $key = $tempvalue)
 {
   $cVariable .= $key.=.$tempvalue.;
 }

Try:

?
function getValues($arrayWithValues, $pre='') {
  $tmpVal = '';

  foreach($arrayWithValues as $key = $tempvalue) {
if (is_array($arrayWithValues[$key])) {
  $tmpVal .= getValues($arrayWithValues[$key], $key);
} else {
  $tmpVal .= $pre.$key.=.$tempvalue.;
}
  }

  return $tmpVal;
}

$cVariable = getValues($_POST);

print $cVariable;
?

Hope it helps

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/189 - Release Date: 2005/11/30
 

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



RE: [PHP] FW: Merging two images (GD PNG)

2005-12-01 Thread Albert
Jochem Maas wrote:
 try this site:
 http://php.amnuts.com/

I had a look at the way Andy does the masking and changed my code to do a
pixel compare and only transfer the pixels to the satellite image I needed. 

This now takes quite a bit longer but at least everything is working as it
should.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/189 - Release Date: 2005/11/30
 

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



RE: [PHP] Howto search in SQL for a specific character?

2005-11-30 Thread Albert
Gustav Wiberg wrote:
  $v1 = chr(39); //39 is apostrofe
 
 
  $sql = SELECT nameOfPedigree FROM tbpedigrees WHERE
  SUBSTR(nameOfPedigree,0,1) = $v1;
 
  Why doesn't this work?
 
  I want the sql to select all nameOfPedigree - fields where the first
  character is apostrofe (')

Here is what I have done using MySQL:

** Create a table:
mysql CREATE TABLE `tablename` (
- `id` tinyint(3) unsigned NOT NULL auto_increment,
- `name` char(20) default '0',
- PRIMARY KEY  (`id`)
- );
Query OK, 0 rows affected (0.06 sec)

** Then insert some data into the table:
mysql INSERT INTO tablename (id, name) VALUES (NULL, '\'Albert');
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO tablename (id, name) VALUES (NULL, '\'Piet');
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO tablename (id, name) VALUES (NULL, '\'Koos');
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO tablename (id, name) VALUES (NULL, 'Jan');
Query OK, 1 row affected (0.00 sec)

mysql INSERT INTO tablename (id, name) VALUES (NULL, 'Gert');
Query OK, 1 row affected (0.00 sec)

** Then retrieve all the record starting with an apostrophe ('):
mysql SELECT * FROM tablename WHERE name LIKE '\'%';
++-+
| id | name|
++-+
|  1 | 'Albert |
|  2 | 'Piet   |
|  3 | 'Koos   |
++-+
3 rows in set (0.00 sec)

Hope it helps

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/188 - Release Date: 2005/11/29
 

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



[PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Albert
I have two images which I want to overlay on each other.

Image1 is a satellite image.
Image2 is contains the statistical data we collected. It has a transparent
background and should be overlaid on top of the satellite image.

Both are in PNG format.

My current code:

?
$dataImage = imagecreate(1000, 1000);
$dIBack = imagecolorallocate($dataImage, 199, 199, 199);
imagecolortransparent($dataImage, $dIBack);
  $darkGreen= imagecolorallocate($tileImage, 2,   123, 48 );
  $grey = imagecolorallocate($tileImage, 118, 131, 120);
  $fuchsia  = imagecolorallocate($tileImage, 255, 0,   255);
  $aqua = imagecolorallocate($tileImage, 113, 168, 194);
  $brown= imagecolorallocate($tileImage, 177, 170, 107);
  $offwhite = imagecolorallocate($tileImage, 187, 210, 193);
  $black= imagecolorallocate($tileImage, 0,   0,   0  );
  $blue = imagecolorallocate($tileImage, 0,   0,   255);
  $red  = imagecolorallocate($tileImage, 255, 0,   0  );
  $yellow   = imagecolorallocate($tileImage, 255, 255, 0  );

/* Code to draw data on image comes here */

$satImage = imagecreatefrompng(‘sat_image.png’);

$mergedImage = imagecreate(1000, 1000);
  imagealphablending($mergedImage, true);
imagecopy($mergedImage, $satImage, 0, 0, 0, 0, 1000, 1000);
imagecopy($mergedImage, $dataImage, 0, 0, 0, 0, 1000, 1000);

imagepng($mergedImage, ‘merged_image.png’);

imagedestroy($mergedImage);
imagedestroy($satImage);
imagedestroy($dataImage);
?
 
Notes:
1. When using imagecreatetruecolor the images turn black
2. When using imagealphablending = true or imagealphablending = false 
   with imagecopy the result is the same. The top image is shown but it is 
   almost transparent. Some images are also discoloured.
3. When using imagecopymerge to copy with a pct value of 99, and commenting 
   out the imagealphablending line the top image does not appear at all
4. When using imagecopymerge to copy with a pct value of 99, and 
   imagealphablending=true, it has the same result as 2. above.
5. When using imagecopymerge to copy with a pct value of 50, and 
   Imagealphablending=true, it has the same result as 2. above.

What is the effect of the pct value of imagecopymerge?

Should I be using different values for the pct value of imagecopymerge or is
there an alternative method which will do what I want to be done?

It seems to me that the palette used in the top image is not merged with the
palette used in the satellite image.

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/188 - Release Date: 2005/11/29
 

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



RE: [PHP] FW: Merging two images (GD PNG)

2005-11-30 Thread Albert
Jochem Maas wrote:
 imagecreatetruecolor() is probably what your after:
 
 http://php.net/imagecreatetruecolor

 Albert wrote:
  Notes:
  1. When using imagecreatetruecolor the images turn black

I did try imagecreatetruecolor() but then the images turn black.

Albert

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



RE: [PHP] Database Class Help

2005-11-30 Thread Albert
Ian Barnes wrote:
 We have a database class that we want to use to connect to multiple
 databases at the same time using different variables.


  function db($db_host, $db_user, $db_pass, $db_name) {
$this-dbh = @mysql_pconnect($db_host, $db_user, $db_pass);
$this-select_db($db_name);
  }

 Now that happens is when I try and do the query for db1, I get told that
 db2.table1 doesn't exist. I can swop anything around and it doesn't seem 
 to work for one of the classes.

 Does anyone have any idea as to why this is happening?

You didn't specify but I guess all your databases are on the same server.

When accessing multiple databases on the same server using multiple
instances of a class, you need to make multiple connections to the server.

By default PHP creates only ONE connection to a server and the database you
select is linked to the connection. So instantiating another instance will
use the previous established connection and change the database.

To force a new connection, you need to use mysql_connect() instead of
mysql_pconnect(). When using mysql_connect() you can specify:

$this-dbh = @mysql_connect($db_host, $db_user, $db_pass, true);

[quote from=PHP manual]
resource mysql_connect ( [string server [, string username [, string
password [, bool new_link [, int client_flags ] )
[/quote]

Which will force a new connection. By default PHP will use a connection
which have already been established.

Take care when doing this as each time you instantiate a class a new
connection to the database will be created adding additional load on your
database which can cause a denial of service.

I normally store a list of connections to servers and databases in a
variable which can be accessed by the script. Every time I instantiate a new
instance of my database class I first make sure that a connection to that
server and database does not already exist. If it does exist then I call
mysql_connect() without the true for new_link otherwise I call
mysql_connect() with the true for new_link.

The downside of this is that you do not have persistent connections which
last beyond the end of the script.

Hope it helps

Albert



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/189 - Release Date: 2005/11/30
 

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



[PHP] Nested IFs Problem

2005-08-31 Thread Albert Padley

I have the following nested ifs:

if ($row['date']  '2005-10-02') {
if ($row['time']  '12:00') {
if ($row['field'] == 'P5' ) {

echo td class=\tabletextbluebg\Success;

}
}
}

else {

echo td class=\tabletextred\Failed;
}
/td

Whenever the 3 if statements are true, I always get the correct  
Success to echo. However, if any or all of the if statements are  
false, I never get Failed to echo.


I know it's something simple, but I just can't see it at the moment.

TIA

Albert Padley

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



[PHP] Re: [SPAM] - [PHP] Nested IFs Problem - Bayesian Filter detected spam

2005-08-31 Thread Albert Padley

Justin  Jordan,

Thanks. The  was what I needed.

Albert Padley


On Aug 31, 2005, at 2:27 PM, Justin Francis wrote:


Albert Padley wrote:



I have the following nested ifs:

if ($row['date']  '2005-10-02') {
if ($row['time']  '12:00') {
if ($row['field'] == 'P5' ) {

echo td class=\tabletextbluebg\Success;

}
}
}

else {

echo td class=\tabletextred\Failed;
}
/td

Whenever the 3 if statements are true, I always get the correct   
Success to echo. However, if any or all of the if statements  
are  false, I never get Failed to echo.



Once the first if statement is evaluated as true, the else  
statement will never be executed -- regardless of the outcome of  
the two nested ifs. I am not sure what you are trying to accomplish  
here, but perhaps all three of your if conditions should be  
combined into one if condition ANDed () together? Or maybe the  
if...elseif...else structure is what you need.


Hope this helps.

Justin





I know it's something simple, but I just can't see it at the moment.

TIA

Albert Padley









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



Re: [PHP] Validating Dynamic Checkboxes

2004-08-07 Thread Albert Padley
Jason,
You lost me on this go around. I don't understand how we got from the 
following function to your new verson:

//loop through records
$id = $row['id'];
$counter++;
if ($counter  1) {
$jscondition .=  || document.getElementById('ed . $id . 
').checked;
 } else {
   $jscondition .= document.getElementById('ed . $id . 
').checked;
}
}
?

SCRIPT language=JavaScript
 function validate() {
if (!(?php print $jscondition; ?)) {
 alert('Please check at least one edit checkbox before submitting this 
form.');
 return false;
 }
 }
 /SCRIPT

Remember that the above works insofar as it throws up the javascript 
alert, but then submits the form anyway. I don't see how your new 
function incorporates the loop to build $jscondition.

Thanks for any further input. I think I need to get some sleep.
Albert Padley
On Aug 6, 2004, at 11:39 PM, Jason Paschal wrote:
make ur submit button a regular button with an onClick event trigger:
input name=button type=button id=button onClick='validate()' 
value=Submit

then make ur javascript submit the form if conditions are true. 
otherwise it gives an alert:

script language=JavaScript
function validate() {
if (document.getElementById('ed2').checked) {
document.getElementById('myform').submit();
} else {
alert(check something.);
}
}
/script

---
http://www.dailymedication.com  -  Everything you didn't know you 
needed until you went there and said to yourself, What did I do 
before I visited DailyMedication.com? and another part of you 
answered, It does not matter.  You are here now.



From: Albert Padley [EMAIL PROTECTED]
To: Jason Paschal [EMAIL PROTECTED]
Subject: Re: [PHP] Validating Dynamic Checkboxes
Date: Fri, 6 Aug 2004 23:27:29 -0600
We are very close. I now get the javascript alert when I don't check 
any of the checkboxes. However, as soon as I click the OK button in 
the alert, the results page is returned.

Albert Padley
On Aug 6, 2004, at 10:55 PM, Jason Paschal wrote:
i read the other guy's bit.  he may be referring to how you identify 
the elements.  and that could be related to the same validation 
trouble you're still having.

i've had to do similar stuff, but it wasn't exactly the same.  
however, i had to give a an id different from the name of the 
element.

input type='checkbox' name='ed[2]' id='ed2'
and in ur javascript:

 if ($counter  1) {
$jscondition .=  || document.getElementById('ed . $id . 
').checked;
 } else {
   $jscondition .= document.getElementById('ed . $id . 
').checked;


---
http://www.dailymedication.com  -  Everything you didn't know you 
needed until you went there and said to yourself, What did I do 
before I visited DailyMedication.com? and another part of you 
answered, It does not matter.  You are here now.



From: Albert Padley [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Validating Dynamic Checkboxes
Date: Fri, 6 Aug 2004 22:36:10 -0600
Jason,
Thanks. That seems to build the javascript string, but 
unfortunately the form doesn't validate. In other words, if I leave 
all the checkboxes unchecked the results page still is returned.

Perhaps there is a problem with the javascript? Any ideas?
Albert Padley
On Aug 6, 2004, at 10:02 PM, Jason Paschal wrote:
here's an idea:
above the HTML, you could put something like this [i'm going to 
use pseudo-code since i don't know how you set it up, but you may 
have to do the same query twice]:

$counter = 0;
loop through records {
$id = $row['id'];
$counter++;
if ($counter  1) {
 $jscondition .=  || mainform.ed[ . $id . ].checked;
} else {
 $jscondition .= mainform.ed[ . $id . ].checked;
}
}
then in ur javascript:
SCRIPT
function validate() {
if (!(?php print $jscondition; ?)) {
---
http://www.dailymedication.com  -  Everything you didn't know you 
needed until you went there and said to yourself, What did I do 
before I visited DailyMedication.com? and another part of you 
answered, It does not matter.  You are here now.



From: Albert Padley [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP] Validating Dynamic Checkboxes
Date: Fri, 6 Aug 2004 21:49:40 -0600
I have a php/mysql script that returns a series of records to 
populate a form. The number of records returned varies from 1 to 
as many as 100. On the display page, each record has a checkbox 
to indicate that the record is being edited. This is checked on 
the results page to know which records to update. The checkbox 
code is:

input type=\checkbox\ name=\ed[{$row['id']}]\ value=\Y\
This part of the system has been working perfectly for weeks.
Now I've been asked to add client side validation to make sure at 
least one of the records (checkboxes) has been checked before 
sending the data to the results page. (The results page already 
has working validation code in it.)

I've have

[PHP] Validating Dynamic Checkboxes

2004-08-06 Thread Albert Padley
I have a php/mysql script that returns a series of records to populate 
a form. The number of records returned varies from 1 to as many as 100. 
On the display page, each record has a checkbox to indicate that the 
record is being edited. This is checked on the results page to know 
which records to update. The checkbox code is:

input type=\checkbox\ name=\ed[{$row['id']}]\ value=\Y\
This part of the system has been working perfectly for weeks.
Now I've been asked to add client side validation to make sure at least 
one of the records (checkboxes) has been checked before sending the 
data to the results page. (The results page already has working 
validation code in it.)

I've have the following javascript code that should work for my 
purposes if I can figure out how to dynamically build the javascript 
code.

SCRIPT
 function validate() {
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
 alert('Please check at least one record before submitting this form.');
 event.returnValue=false;
 }
 }
 /SCRIPT
This is the line I need to build dynamically:
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
Any help, pointers, suggestions, etc. will be greatly appreciated.
Thanks.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Validating Dynamic Checkboxes

2004-08-06 Thread Albert Padley
Jason,
Thanks. That seems to build the javascript string, but unfortunately 
the form doesn't validate. In other words, if I leave all the 
checkboxes unchecked the results page still is returned.

Perhaps there is a problem with the javascript? Any ideas?
Albert Padley
On Aug 6, 2004, at 10:02 PM, Jason Paschal wrote:
here's an idea:
above the HTML, you could put something like this [i'm going to use 
pseudo-code since i don't know how you set it up, but you may have to 
do the same query twice]:

$counter = 0;
loop through records {
$id = $row['id'];
$counter++;
if ($counter  1) {
 $jscondition .=  || mainform.ed[ . $id . ].checked;
} else {
 $jscondition .= mainform.ed[ . $id . ].checked;
}
}
then in ur javascript:
SCRIPT
function validate() {
if (!(?php print $jscondition; ?)) {
---
http://www.dailymedication.com  -  Everything you didn't know you 
needed until you went there and said to yourself, What did I do 
before I visited DailyMedication.com? and another part of you 
answered, It does not matter.  You are here now.



From: Albert Padley [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP] Validating Dynamic Checkboxes
Date: Fri, 6 Aug 2004 21:49:40 -0600
I have a php/mysql script that returns a series of records to 
populate a form. The number of records returned varies from 1 to as 
many as 100. On the display page, each record has a checkbox to 
indicate that the record is being edited. This is checked on the 
results page to know which records to update. The checkbox code is:

input type=\checkbox\ name=\ed[{$row['id']}]\ value=\Y\
This part of the system has been working perfectly for weeks.
Now I've been asked to add client side validation to make sure at 
least one of the records (checkboxes) has been checked before sending 
the data to the results page. (The results page already has working 
validation code in it.)

I've have the following javascript code that should work for my 
purposes if I can figure out how to dynamically build the javascript 
code.

SCRIPT
 function validate() {
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
 alert('Please check at least one record before submitting this 
form.');
 event.returnValue=false;
 }
 }
 /SCRIPT

This is the line I need to build dynamically:
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
Any help, pointers, suggestions, etc. will be greatly appreciated.
Thanks.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


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


Re: [PHP] Re: Validating Dynamic Checkboxes

2004-08-06 Thread Albert Padley
On Aug 6, 2004, at 10:39 PM, Manuel Lemos wrote:
Hello,
On 08/07/2004 12:49 AM, Albert Padley wrote:
I have a php/mysql script that returns a series of records to 
populate a form. The number of records returned varies from 1 to as 
many as 100. On the display page, each record has a checkbox to 
indicate that the record is being edited. This is checked on the 
results page to know which records to update. The checkbox code is:
input type=\checkbox\ name=\ed[{$row['id']}]\ value=\Y\
This part of the system has been working perfectly for weeks.
Now I've been asked to add client side validation to make sure at 
least one of the records (checkboxes) has been checked before sending 
the data to the results page. (The results page already has working 
validation code in it.)
I've have the following javascript code that should work for my 
purposes if I can figure out how to dynamically build the javascript 
code.
SCRIPT
 function validate() {
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
 alert('Please check at least one record before submitting this 
form.');
 event.returnValue=false;
 }
 }
 /SCRIPT
This is the line I need to build dynamically:
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
It can't be done that way because the brackets have a different 
meaning in Javascript syntax. You need to quote the whole name.

You may want to take a look at the example that comes with this forms 
generation and validation class that supports the exact same type of 
validation that you want:

http://www.phpclasses.org/formsgeneration
Hi Manuel,
I'm not certain I understand what you mean by quote the whole name. 
Also, there are a lot of files in the formsgeneration class. Which one 
has the example you are referring to?

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


[PHP] Regex (Phone Number)

2004-07-25 Thread Albert Padley
I have been struggling with a javascript regex validation for U.S. 
phone numbers all afternoon. This is part of Manuel Lemos' Formsgen 
class. This is limited to the 7 digit number sans 3 digit area code. To 
be complete, the regex should disallow a phone number that begins with 
0 or 1, 555 or any digit followed by 11. Here is the regex I'm using:

^(?!\d[1]{2}|[5]{3})([2-9]\d{2})([-])\d{4}$
Manual Lemos indicated to me in an offline post that this should throw 
a javascript runtime error because of the (? at the beginning of the 
regex. I have tested it in over a dozen different browsers (Windows and 
Mac) and the only one that throws the runtime error is IE on the Mac. 
All others catch the errors I am trying to trap for with no runtime 
errors. Can this regex be improved on or do I have to live with the 
idiosyncratic behavior of Mac IE?

Thanks.
Albert Padley

Re: [PHP] Update Multiple Records From Form

2004-05-28 Thread Albert Padley
On May 28, 2004, at 3:50 AM, Ford, Mike [LSS] wrote:
On 28 May 2004 04:47, Albert Padley wrote:
I feel I'm so close.
I have a form with multiple database records with a checkbox to
indicate which records to update set up like so:
$name = ed[ . $row['id'] . ];
input type=\checkbox\ name=\ . $name . \ value=\Y\
Each text input is set up like so:
input type=\text\ name=\fname[]\ value=\ . $row['fname'] . \
On the processing page I am doing this:
foreach($ed as $id=$val){
  $query = UPDATE ref_events_reg
 SETfname = '$fname'
WHERE id = '{$id}';
I am looping through the correct records, but every field is being
updated to Array.
What tweak do I need to make?
I'd make two tweaks, actually.  First and most obviously, you're not 
selecting *which* fname field to pass to your update query, so this 
needs to be:

$query = UPDATE ref_events_reg
 SET fname = '{$fname[$id]}'
 WHERE id = '{$id}';
(By putting just $fname there, you are telling PHP to insert the 
string representation of the whole array -- and the string 
representation of any array is, er, exactly Array! ;)

This change may give you a clue to my other tweak -- I'd explicitly 
set the indexes of all the fname[] fields to be sure they sync 
correctly to the related check box, thus:

input type=\checkbox\ name=\ed[{$row['id']}]\ value=\Y\
input type=\text\ name=\fname[{$row['id']}]\ 
value=\{$row['fname']}\

Cheers!
Mike
Mike,
Thanks for the tweaks. That solved the problem.
I had actually tried something like that, but obviously didn't have all 
the parts working together at the same time.

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


[PHP] Update Multiple Records From Form

2004-05-27 Thread Albert Padley
I feel I'm so close.
I have a form with multiple database records with a checkbox to 
indicate which records to update set up like so:

$name = ed[ . $row['id'] . ];

input type=\checkbox\ name=\ . $name . \ value=\Y\
Each text input is set up like so:
input type=\text\ name=\fname[]\ value=\ . $row['fname'] . \
On the processing page I am doing this:
foreach($ed as $id=$val){
 $query = UPDATE ref_events_reg
 SETfname = '$fname'
WHERE id = '{$id}';
I am looping through the correct records, but every field is being 
updated to Array.

What tweak do I need to make?
Thanks.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
I've checked the archives and several other sources, but still can't 
seem to make this work.

I have a form with checkboxes to designate records to be deleted from 
the mysql database. The pertinent form code is:

input type=\checkbox\ name=\del[]\ value=\ . $row['id'] . \
The processing code is:
if (count($del)  0){
for ($i=0;$icount($del);$i++){

$query = DELETE FROM ref_events_reg WHERE id = '$del[$i]';
}
}
Echoing the query produces:
DELETE FROM ref_events_reg WHERE id = A
I've also tried the following:
$query = DELETE FROM ref_events_reg WHERE id IN (' . implode(',', 
addslashes($del)) . ');

This one produces a warning:
Warning: implode(): Bad arguments.
and the following query:
DELETE FROM ref_events_reg WHERE id IN ('')
Both attempts fail to delete any records even though several records 
are checked.

Where have I gone wrong?
Thanks.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
On May 26, 2004, at 8:01 PM, John W. Holmes wrote:
Albert Padley wrote:
I've checked the archives and several other sources, but still can't 
seem to make this work.
I have a form with checkboxes to designate records to be deleted from 
the mysql database. The pertinent form code is:
input type=\checkbox\ name=\del[]\ value=\ . $row['id'] . \
The processing code is:
if (count($del)  0){
for ($i=0;$icount($del);$i++){
$query = DELETE FROM ref_events_reg WHERE id = 
'$del[$i]';
}
}
Echoing the query produces:
DELETE FROM ref_events_reg WHERE id = A
Should be:
$query = DELETE FROM ref_events_reg WHERE id = '{$del[$i]}';
or
$query = DELETE FROM ref_events_reg WHERE id = '.$del[$i].';
--
---John Holmes...
John,
Sorry, same result. No records deleted. Echoing the query returns:
DELETE FROM ref_events_reg WHERE id = 'A'
However, the id should be an integer. A var_dump() returns:
array(2) {  [del]=  array(2) {  [0]=  string(2) 15  [1]=  
string(2) 16  }  [submit]=  string(6) Delete }

Further, when I echo $del[0], it returns -- 'A' while $del[1] returns 
'r'. Just $del returns 'Array'.

Still working on it.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
On May 26, 2004, at 7:55 PM, Tom Rogers wrote:
Hi,
Thursday, May 27, 2004, 11:34:03 AM, you wrote:
AP I've checked the archives and several other sources, but still 
can't
AP seem to make this work.

AP I have a form with checkboxes to designate records to be deleted 
from
AP the mysql database. The pertinent form code is:

AP input type=\checkbox\ name=\del[]\ value=\ . $row['id'] . 
\

AP The processing code is:
if (count($del)  0){
AP  for ($i=0;$icount($del);$i++){

AP  $query = DELETE FROM ref_events_reg WHERE id = '$del[$i]';
AP }
AP }
AP Echoing the query produces:
AP DELETE FROM ref_events_reg WHERE id = A
AP I've also tried the following:
AP $query = DELETE FROM ref_events_reg WHERE id IN (' . 
implode(',',
AP addslashes($del)) . ');

AP This one produces a warning:
AP Warning: implode(): Bad arguments.
AP and the following query:
AP DELETE FROM ref_events_reg WHERE id IN ('')
AP Both attempts fail to delete any records even though several 
records
AP are checked.

AP Where have I gone wrong?
AP Thanks.
AP Albert Padley
change it to
   input type=\checkbox\ name=\del[$row['id']]\ value=\Y\
   Then you can do something like
   foreach($del as $id=$val){
 $query = DELETE FROM ref_events_reg WHERE id = '$id';
 //do query
   }
--
regards,
Tom
Tom,
When I tried this I received a warning - Warning: Invalid argument 
supplied for foreach()
and, of course, no records were deleted.

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


Re: [PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
On May 26, 2004, at 11:16 PM, Curt Zirzow wrote:
* Thus wrote Albert Padley ([EMAIL PROTECTED]):
input type=\checkbox\ name=\del[]\ value=\ . $row['id'] . \
The processing code is:
if (count($del)  0){
for ($i=0;$icount($del);$i++){

$query = DELETE FROM ref_events_reg WHERE id = '$del[$i]';
}
}
I think you need to take a step back and figure out where the $del
variable is comming from.
Both solutions that have been provided should have worked if $del
was really an array.
Curt
--
I used to think I was indecisive, but now I'm not so sure.
Curt,
I agree. I did a var_dump() with the following result:
array(2) {  [del]=  array(2) {  [0]=  string(2) 15  [1]=  
string(2) 16  }  [submit]=  string(6) Delete }

15 and 16 are the correct id's for the records I'm trying to 
delete. However, when I echo $del[0] it returns A and when I echo 
$del[1] it returns r which happen to be the first 2 character in 
Array. So what gives?

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


Re: [PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
On May 26, 2004, at 11:17 PM, Albert Padley wrote:
On May 26, 2004, at 11:16 PM, Curt Zirzow wrote:
* Thus wrote Albert Padley ([EMAIL PROTECTED]):
input type=\checkbox\ name=\del[]\ value=\ . $row['id'] . \
The processing code is:
if (count($del)  0){
for ($i=0;$icount($del);$i++){

$query = DELETE FROM ref_events_reg WHERE id = '$del[$i]';
}
}
I think you need to take a step back and figure out where the $del
variable is comming from.
Both solutions that have been provided should have worked if $del
was really an array.
Curt
--
I used to think I was indecisive, but now I'm not so sure.
Curt,
I agree. I did a var_dump() with the following result:
array(2) {  [del]=  array(2) {  [0]=  string(2) 15  [1]=  
string(2) 16  }  [submit]=  string(6) Delete }

15 and 16 are the correct id's for the records I'm trying to 
delete. However, when I echo $del[0] it returns A and when I echo 
$del[1] it returns r which happen to be the first 2 character in 
Array. So what gives?

Albert Padley
John, Tom and Curt,
I found that I had an include of functions that was somehow mucking 
things up. When I removed the functions page, all 3 of your solutions 
worked.

Thank you all for taking the time to assist.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] textarea form input converting lt; and gt; to

2002-02-20 Thread Byron Albert

Hello,

 I have a few forms that  are used to input html.  We have run into a
problem of lt; and gt;  getting turned into  and  when you hit
submit, Or if you hit submit more than once. I have attached a sample
form.  The major problem here is that some times we want lt; and some
times we want to input html tags. Has any one else run into this problem
maybe even found a solution.

Any help would be appreciated.
Thanks
Byron



html
head
 titletest form/title
/head
body
form method=post
TEXTAREA NAME=test rows=10 cols=50? echo $test; ?/textarea
br
INPUT TYPE=submit NAME=submitaction VALUE=Submit
/form
br
what you typed
br
? echo $test; ?
/body
/html


--

Byron Albert[EMAIL PROTECTED]
System Engineer Internet.com a Division of INT Media Group
203-662-2848

Engineering does not require science. Science helps a lot but
people built perfectly good brick walls long before they knew
why cement works.  -Alan Cox




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




[PHP] mail() extra headers not working

2001-11-01 Thread Byron Albert

 Hello,

 I am trying to ad extra headers to email's I am sending through php. I
want to ad Reply-To: and Bounse-To: addresses.  But when add them useing
the  forth feild of the mail() funtion.
mail($recipient,$msubject,$message,Reply-To:  $sender);
but for some reason when I send this e-mail it puts a newline befor this
header so it becomes part of the message not the headers.  Any ideas on
what to do??
Byron


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Problems with POST form. Page Not Found

2001-07-25 Thread Antonio Mármol Albert

Hello,

I have some problems sending a form via POST. When I submit the form, I get
the error of 'Page Not Found'.

This happens in some Internet Explorer (all are v5.5, I think). The action
form is ok (FORM action=http://www.domain.com/formprocess.html;
method=post). It happens randomly.

I've the type .html associated with the php engine. And I need to use
the url of action in long format (http://.)

Anybody with the same problem??

Best regards

-- 
Antonio Mármol Albert ( [EMAIL PROTECTED] )
http://www.infurma.es

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Problem with gettext support - Solaris 2.7

2001-01-18 Thread Albert Novak

Hi!

When I try to compile PHP 4.0.4 as Apache module with gettext support, the
gettext support doesn't function. But when I compile PHP as CGI, the gettext
support works fine. Where is the the problem (other functions works fine in
both case)?

I use Apache 1.3.14 with DSO support, GNU gettext 0.10.35, Solaris 5.7 and I
have compiled PHP 4.0.4 with gcc 2.95.2 and these options:

./configure --with-apxs=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/apache/config \
--with-low-memory --with-gettext=/usr/local

Does anyone have faced with similar problem or have solution for it?

Albert





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-I18N] Problem with gettext suporrt - Solaris 2.7

2001-01-18 Thread Albert Novak

Hi!

When I try to compile PHP 4.0.4 as Apache module with gettext support, the
gettext support doesn't function. But when I compile PHP as CGI, the gettext
support works fine. Where is the the problem (other functions works fine in
both case)?

I use Apache 1.3.14 with DSO support, GNU gettext 0.10.35, Solaris 5.7 and I
have compiled PHP 4.0.4 with gcc 2.95.2 and these options:

./configure --with-apxs=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/apache/config \
--with-low-memory --with-gettext=/usr/local

Does anyone have faced with similar problem or have solution for it?

Albert





-- 
PHP Internationalization Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]