php-general Digest 1 Mar 2006 11:36:00 -0000 Issue 3991
Topics (messages 231235 through 231253):
Re: html area
231235 by: Grant Young
231251 by: juanito
Re: About date & time...
231236 by: Grant Young
231237 by: tedd
231238 by: Gustav Wiberg
231241 by: Gustav Wiberg
Basic PDO Questions
231239 by: Chris Drozdowski
231252 by: Curt Zirzow
Re: move_uploaded_file and CPU wait state (IO)
231240 by: Chris
fopen failing, permission denied
231242 by: Dan Baker
231247 by: Chris
Editing an existing pdf?
231243 by: Jay Contonio
231246 by: Max Schwanekamp
231248 by: Max Schwanekamp
Re: Array sort question
231244 by: tedd
Re: working with ini files
231245 by: Adam Ashley
Re: Different results in function on PHP 4 and PHP 5
231249 by: Chris
Dynamic Form List - how to change values
231250 by: Pat
PDO Changes from 5.0.x To 5.1.x
231253 by: Chris Drozdowski
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Tiny_MCE is another fairly simple editor - although I've experienced
some quirks that can be quite annoying/tricky.
http://tinymce.moxiecode.com/
Regards, Grant
--- End Message ---
--- Begin Message ---
2wsxdr5 wrote:
I am looking for a simple html area text area type editor, similar to to
what you find in the phpbbs and Joomla. I don't need a lot of features
it is just to edit small snipits of html and I really want it to be very
simple to implement. I have been looking for the past few hours and so
far everything seems way more complex than what I need and a pain to set
up. Any recommendations would be appreciated
this'd be how that's done...
http://www.massless.org/mozedit/
say thanx to chris wetherell for this (and Meg also)
--- End Message ---
--- Begin Message ---
Hi Gustav.
I'm a swede, and I we use hours 0 - 24.
8 pm = 20 for us.
9 pm = 21 for us
10 pm = 22...
and so on...
But with date()-function there is 10 pm that shows (and I want 22 to
show instead)
I'm using PHP 4.0.3...
Do I have to use getdate() then? (getdate()-function showed 22...)
The docs for date() (http://www.php.net/date) show that there are a
number of different options for the first parameter. If you check out
the table on that page, you'll find:
>> H | 24-hour format of an hour with leading zeros | 00 through 23
With this in mind, the following will work (if I understand your
question correctly):
$t = date('H\:\ i\:\ s');
HTH, Grant
--- End Message ---
--- Begin Message ---
Gustav:
I'm a swede, and I we use hours 0 - 24.
Well... I don't know what I am, but non sum qualis eram.
In any event, you want military time -- simple enough -- just change
the h to H, like so:
echo("Time: " . date('H\:\ i\:\ s') . "<br/>" );
You can find more code examples at:
http://www.weberdev.com/AdvancedSearch.php?searchtype=title&search=date&Submit1.x=0&Submit1.y=0
Also, you need to review the php manual regarding date() -- it's a
super function that has lot's of formatting symbols.
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "Grant Young" <[EMAIL PROTECTED]>
To: <php-general@lists.php.net>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, February 28, 2006 11:25 PM
Subject: Re: [PHP] About date & time...
Hi Gustav.
I'm a swede, and I we use hours 0 - 24.
8 pm = 20 for us.
9 pm = 21 for us
10 pm = 22...
and so on...
But with date()-function there is 10 pm that shows (and I want 22 to
show instead)
I'm using PHP 4.0.3...
Do I have to use getdate() then? (getdate()-function showed 22...)
The docs for date() (http://www.php.net/date) show that there are a
number of different options for the first parameter. If you check out
the table on that page, you'll find:
>> H | 24-hour format of an hour with leading zeros | 00 through 23
With this in mind, the following will work (if I understand your
question correctly):
$t = date('H\:\ i\:\ s');
HTH, Grant
AHA!!!
Sometimes I'm so stupid... hm...
Thanx! :-)
/G
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: "tedd" <[EMAIL PROTECTED]>
To: <php-general@lists.php.net>; "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Tuesday, February 28, 2006 11:34 PM
Subject: Re: [PHP] About date & time...
Gustav:
I'm a swede, and I we use hours 0 - 24.
Well... I don't know what I am, but non sum qualis eram.
In any event, you want military time -- simple enough -- just change the h
to H, like so:
echo("Time: " . date('H\:\ i\:\ s') . "<br/>" );
You can find more code examples at:
http://www.weberdev.com/AdvancedSearch.php?searchtype=title&search=date&Submit1.x=0&Submit1.y=0
Also, you need to review the php manual regarding date() -- it's a super
function that has lot's of formatting symbols.
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Yes, thanx! I've totally missed the part about 12/24-h setting... :-)
/G
--- End Message ---
--- Begin Message ---
I have a three quick PDO questions.
1) If a PDOStatement is created within a function or method, is it's
server result set connection is automatically freed up when the
function returns (I assume so, but want to make sure)?
2) Does setting a PDOStatement to null (PDOStatement = null)
terminate the server result set connection (I assume so, but want to
make sure)?
3) The documentation for PDO::quote encourages us to use prepared
statements over the PDO::query() or PDO::exec() methods citing the
economy and portability of prepared statements. For queries that will
run only once, is there significantly more overhead using prepared
statements rather than the PDO::query() or PDO::exec() methods? I
know that that's kind of an unclear/subjective question, but I just
don't know how to state it better.
Thanks,
Chris D
--- End Message ---
--- Begin Message ---
On Tue, Feb 28, 2006 at 05:48:36PM -0500, Chris Drozdowski wrote:
> I have a three quick PDO questions.
>
> 1) If a PDOStatement is created within a function or method, is it's
> server result set connection is automatically freed up when the
> function returns (I assume so, but want to make sure)?
Correct. Assuming you dont return it or assign a function input
variable that is being passed by reference.
>
> 2) Does setting a PDOStatement to null (PDOStatement = null)
> terminate the server result set connection (I assume so, but want to
> make sure)?
I assume you mean a variable that contains a PDOStatement:
$stmt = $dbh->prepare($sql);
$stmt = null;
Yes this is correct. The one thing to keep in mind though is the
above will be only true if you havn't assigned $stmt to another
variable:
$another_stmt = $stmt;
$stmt = null;
The result set connection will still exist, until all variables
referencing to the object are unset/null'd
>
> 3) The documentation for PDO::quote encourages us to use prepared
> statements over the PDO::query() or PDO::exec() methods citing the
> economy and portability of prepared statements. For queries that will
> run only once, is there significantly more overhead using prepared
> statements rather than the PDO::query() or PDO::exec() methods? I
> know that that's kind of an unclear/subjective question, but I just
> don't know how to state it better.
The key points addressed in the docs with using prepare instead:
* portable
* immune to sql injection
* speed
As far as portable, as noted in the next paragraph, the ODBC driver
doesn't support the quote() method, so if you are crafting a sql
by hand (within your app) you will have to know what driver you are
dealing with.
Also, using just a prepare/execute method, it makes your code much
easier to allow for abstract database servers. This is why i like
pdo so much, it isn't an abstract layer but allows you to build a
common interface that can be abstracted.
The Immune to sql injection. This is rather straight forward, you
just set up your query with input variables and assign the
variables to the input variables:
$sql = "select * from some_table where userid = ? and name = ?";
$stmt = $dbh->prepare($sql);
$stmt->bindValue(1, $_GET['userid'], PDO::PARAM_INT)
$stmt->bindValue(2, $_GET['name'], PDO::PARAM_STR);
With the above code you dont have to worry about escaping data nor
how it is needed to quote the variable, it is handled by the
driver.
With speed, benchmarks will only show a difference if you have code
like:
$sql = "select * from some_table where id = ?";
$stmt = $dbh->prepare($sql);
foreach(array(1,2,3) as $id) {
$stmt->bindValue(1, $id, PDO::PARAM_INT);
$stmt->execute();
}
vs.
foreach(array(1,2,3) as $id) {
$sql = "select * from some_table where id = " . (int) $id;
$stmt = $dbh->query($sql);
}
The speed difference is with query() and the server has to parse
the query to make sure it is valid and then execute within each
iteration of the loop. With the prepare/execute method, the server
just parses the query once. I would assume stored procedures or
views benefit more with this method since they are a bit more
complicated to parse.
HTH,
Curt.
--
cat .signature: No such file or directory
--- End Message ---
--- Begin Message ---
Aleksandar Skodric wrote:
Hi,
Yes, /tmp is on another disk then the final directory. I shall move it
to the same disk (tmp_upload_dir) right now.
Question: can I define tmp_upload_dir to be otherwise just for one host
in apache conf, like:
php_ini upload_tmp_dir /some/dir
<snip>
I'm guessing not, but the php docs will tell you for sure -
http://www.php.net
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I have the following code snippet:
$h = fopen("$path/file.txt", 'x+');
And it generates the following error:
Warning: fopen(/home/...../myarea/file.txt): failed to open stream:
Permission denied
The path is correct, but the php process doesn't seem to have file
permissions in the folder.
Is there some magic I can do to allow php to have file rights to the
"myarea" folder? (This is on a purchased ISP site)
Thanks
DanB
--- End Message ---
--- Begin Message ---
Dan Baker wrote:
I have the following code snippet:
$h = fopen("$path/file.txt", 'x+');
And it generates the following error:
Warning: fopen(/home/...../myarea/file.txt): failed to open stream:
Permission denied
The path is correct, but the php process doesn't seem to have file
permissions in the folder.
Is there some magic I can do to allow php to have file rights to the
"myarea" folder? (This is on a purchased ISP site)
Go in through ftp or ssh and fix the permissions.
If you only want to read the file, then it only needs to be 644.
If you need to write the file it will either need to be 646 or 664.
That's your only option apart from deleting the file (through ftp) and
recreating it through your php script ... or getting your host to change
to the CGI version of php which is most unlikely to happen.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I am just looking for someone to point me in the right direction. I
need to be able to *edit* an existing pdf, not create a new one. I
basically would be adding an image or text from a form to an existing
pdf. Does the PDFLib have an overlay function? These will not be 72
DPI pdf's either.
Thanks.
--
Jay Contonio
http://www.jcontonio.com/
--- End Message ---
--- Begin Message ---
Jay Contonio wrote:
I am just looking for someone to point me in the right direction. I
need to be able to *edit* an existing pdf, not create a new one. I
basically would be adding an image or text from a form to an existing
pdf. Does the PDFLib have an overlay function? These will not be 72
DPI pdf's either.
Never used it myself, but FPDF says it can do this using the FPDI
extension.
http://fpdf.org/en/FAQ.php (see item 17)
--
Max Schwanekamp
http://www.neptunewebworks.com/
--- End Message ---
--- Begin Message ---
Jay Contonio wrote:
With FPDF you have been able to add jpegs or pngs to existing high-res
pdfs? I understand adding data using the FDF file but what about an
image?
Yeah, I use FPDF on a fairly busy site to generate PDFs that have one of
various logos embedded. The PDF can be regular 72DPI - that's print
quality for text. But the image should be at print resolution, i.e.
300DPI or better, preferably a 24-bit PNG.
--
Max Schwanekamp
http://www.neptunewebworks.com/
--- End Message ---
--- Begin Message ---
<snip>
I would rather teach a man how to fish than give him
his supper on a silver platter.
</snip>
Write his code and you can reduce his frustration for a day, but
teach him to program and you'll frustrate him for life.
tedd
--
--------------------------------------------------------------------------------
http://sperling.com
--- End Message ---
--- Begin Message ---
On Tue, 2006-02-28 at 13:32 -0500, Benjamin Adams wrote:
> I have created my own ini file. I can read the values into an array
> fine. but What I want to do is change a value in the ini file. Example
>
> file.ini
> dog = 3
> cat = 4
> fish = 7
>
> altered file.ini
> dog = 3
> cat = 5
> fish = 7
>
> how can I do this, I tried using ini_set but its not working.
> help would be great, Thanks!!
> Ben
As has been mentioned ini_set is for php.ini values. You can do what you
want with fopen and all that manually or check out
http://pear.php.net/package/Config all the hard work has been done for
you.
Adam Ashley
signature.asc
Description: This is a digitally signed message part
--- End Message ---
--- Begin Message ---
Stephen Lake wrote:
Good Afternoon Folks,
After pounding my head into the ground for days over a problem I am having,
I decided to post here to see what you guys and girls think.
I have a user defined function that outputs categories from a database and
assosiated eShops. Now in PHP 4 this is working perfectly however my client
has PHP 5, and the function is only outputting the first eshop for each
category. How can I get this working properly in PHP 5?
Below is the function in question:
function getAllCategories($mysql,$region) {
$cat_list = "SELECT * FROM ilp_category_zone ORDER BY category";
$mysql->execute_query($cat_list);
if($mysql->numrows() <= 0) {
print "There are currently no categories";
} else {
while($r = $mysql->fetchrow()) {
$cid[] = $r['cid'];
}
foreach($cid as $value) {
<snip>
Try that as
foreach($cid as $cidpos => $value) {
Does $cid actually have all the values that it should?
echo sizeof($cid);
just before the foreach.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
I have a list from a MYSQL database that I am dumping to a screen. I'd
like the user to be able to change the quantity on the form for any
record on the screen, then post that information back so the user can
review it, and I can then update the database.
Simple checkout routine. Or so I thought.
I have these fields displayed on the screen before the user changes the
quantity:
$imageqty = $row["cialbum"]."-".$row["ciset"]."-".$row["ciimage"];
$qty = $row["ciqty"];
print "<td align='center' valign='top'><input type='text'
name='$imageqty' size='5' value='$qty'></td>";
I've set the $imageqty variable to hold the initial value from the
database. The initial screen works fine.
However, when I reprocess the file, how can I retrieve the original
value of the field that is named the same as $imageqty?
The form outputs something like this:
http://.../chkout.php?NATURE-1.jpg=6&continue=Continue+Checkout, which
does show the $imageqty of "NATURE-1.jpg" value with the new qty of "6".
How can I get the script to pull the value?
$imageqty = $row["cialbum"]."-".$row["ciset"]."-".$row["ciimage"];
$newqty = $_GET["$imageqty"];
Retrieves nothing.
Thanks for your help.
Pat
--- End Message ---
--- Begin Message ---
According to documentation, PDO globals constants in 5.0.3+ were
changed to class constants in 5.1.
Does anyone have a suggestion for portability of constants between
the 5.0.x branch and the 5.1 branch without having to rewrite code.
Besides the constants, what other differences exist in PDO for 5.0.x
and 5.1 that may effect portability/functionality?
Chris D.
--- End Message ---