php-general Digest 29 Dec 2004 03:14:20 -0000 Issue 3196
Topics (messages 205247 through 205281):
Re: not gettingg desired results... is my programming logic run amuck...
205247 by: Jason Wong
205249 by: GH
205261 by: Jason Wong
205274 by: GH
Re: Strange results from file_get_contents using an url as filename
205248 by: Jason Wong
205250 by: John Hicks
[SOLVED] Re: [PHP] Strange results from file_get_contents using an url as
filename
205251 by: Ewout de Boer
Test, please ignore
205252 by: Steven Spierenburg
205255 by: Robby Russell
205257 by: Jason Wong
Environment and Modules
205253 by: Steven Spierenburg
$_FILE[user][error] = 6 ?
205254 by: Al
205258 by: Jason Wong
205266 by: Al
205268 by: Sebastian
205269 by: Matt M.
205271 by: Al
Function Default Values
205256 by: The Disguised Jedi
205259 by: Jason Wong
gallery (4 in a row) // carefull newbie
205260 by: user.domain.invalid
205262 by: Robby Russell
205263 by: Mike Johnson
205264 by: John Nichel
205267 by: Chris
205273 by: Matthew Weier O'Phinney
help with PEAR and SOAP
205265 by: Jones, Douglas 1
cURL and line breaks
205270 by: Mike Johnson
205277 by: Andrew Kreps
PHP5 and File Locking
205272 by: Gerard Samuel
MySQL Database type
205275 by: The Disguised Jedi
Re: A serious bug? "or" operator gives out diffferent results depending on
order of operands
205276 by: Rory Browne
PEAR DB vs ADODB
205278 by: daniel.electroteque.org
205279 by: Rory Browne
205280 by: daniel.electroteque.org
How to enable TTF extension
205281 by: Viet Hung
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Tuesday 28 December 2004 22:29, GH wrote:
Please do not top post.
> The isAttendanceReport() fails... so in the displayMenu() function I get
>
> Print Attendance Sheet
> No Attendance Report Available1
OK, so why does isAttendanceReport() return 0?
When debugging it's always a good idea to plugin absolute values where
possible, ie instead of using isAttendanceReport($SID), use
isAttendanceReport(1).
Isolate the problem, just run isAttendanceReport() on its own and plugin
various values to see what comes back.
> > Note that it is good practice to use { } around your statement(s).
>
> I am under the opression that it is only for when you have
> multistatement groups and not just a one statement after a condition?
> Please correct me if I am wrong.
You're not wrong, like I said it's _good practice_. Say you revise your code
to add more statements, it is all too easy to forget to put in the braces as
well thus resulting in faulty logic in your code and you pulling your hair
out trying to figure what the problem is. PHP's flexibility also means that
there is more than one way to shoot yourself in the foot (TIMTOWTSYITF (TM)).
BTW PHP is not an oppressive language at all :)
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
The wind doth taste so bitter sweet,
Like Jaspar wine and sugar,
It must have blown through someone's feet,
Like those of Caspar Weinberger.
-- P. Opus
*/
--- End Message ---
--- Begin Message ---
Ok here is what I get...
> >The isAttendanceReport() fails... so in the displayMenu() function I get
> >
> > Print Attendance Sheet
> > No Attendance Report Available1
>
> OK, so why does isAttendanceReport() return 0?
>
> When debugging it's always a good idea to plugin absolute values where
> possible, ie instead of using isAttendanceReport($SID), use
> isAttendanceReport(1).
When using 1 in the fuction... no change....
During the code... it gets to the following point...
[snip]
#############################################
# Check if report report is present or not #
#############################################
if(!mysql_num_rows($dba['results']['attendance_report'])){
#report is not present
return 0;
}
else {
#report is present
return 1;
#gets here
}
[/snip]
it gets to the return 1 section....
however the calling statement just does not seem to work....
using SID = 1, mysql_num_rows($dba['results']['attendance_report'])
evaluates to 8
Dunno if that helps....
> Isolate the problem, just run isAttendanceReport() on its own and plugin
> various values to see what comes back.
How can I do that... I have tried but how do you see what the output
is? I have tried just echo ing it, print_r, var_dump ...
>
> > > Note that it is good practice to use { } around your statement(s).
> >
> > I am under the opression that it is only for when you have
> > multistatement groups and not just a one statement after a condition?
> > Please correct me if I am wrong.
>
> You're not wrong, like I said it's _good practice_. Say you revise your code
> to add more statements, it is all too easy to forget to put in the braces as
> well thus resulting in faulty logic in your code and you pulling your hair
> out trying to figure what the problem is. PHP's flexibility also means that
> there is more than one way to shoot yourself in the foot (TIMTOWTSYITF (TM)).
>
> BTW PHP is not an oppressive language at all :)
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> The wind doth taste so bitter sweet,
> Like Jaspar wine and sugar,
> It must have blown through someone's feet,
> Like those of Caspar Weinberger.
> -- P. Opus
> */
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Tuesday 28 December 2004 23:43, GH wrote:
> During the code... it gets to the following point...
>
> [snip]
> #############################################
> # Check if report report is present or not #
> #############################################
> if(!mysql_num_rows($dba['results']['attendance_report'])){
> #report is not present
> return 0;
> }
> else {
> #report is present
> return 1;
> #gets here
> }
> [/snip]
>
> it gets to the return 1 section....
Just to be sure, how are you determining that your code does indeed goes to
the 'else' branch and return 1? Because if it does indeed return 1 then:
echo isAttendanceReport(1); // should display 1
For debugging something like this I would put in echo statements (or
trigger_error()) all over the place to indicate which part of the code is
being executed.
> however the calling statement just does not seem to work....
If isAttendanceReport() did indeed return 1 then the if-clause in
displayMenu() would be obviously be true and would obviously execute (unless
you have uncovered a bug in PHP). So the most likely explanation is that
isAttendanceReport() is NOT returning 1.
> using SID = 1, mysql_num_rows($dba['results']['attendance_report'])
> evaluates to 8
>
> Dunno if that helps....
How does $dba['results']['attendance_report'] get assigned? What variables
does it rely on? What variables are present/not present in the case that
succeeds/fails?
> > Isolate the problem, just run isAttendanceReport() on its own and plugin
> > various values to see what comes back.
>
> How can I do that... I have tried but how do you see what the output
> is? I have tried just echo ing it, print_r, var_dump ...
By not running unnecessary code. In this case you seemed to have determined
that isAttendanceReport() is not returning what you think it should be
returning. Hence running displayMenu() to test for the return value of
isAttendanceReport() is unnecessary, particularly when the execution of
displayMenu() is itself subject to a switch construct. So cut through the
crap and just run isAttendanceReport() direct as in:
echo isAttendanceReport(SOME_VALUE_FOR_SID);
If you still don't get any joy then dig deeper. What isAttendanceReport()
returns is solely dependent on:
mysql_num_rows($dba['results']['attendance_report'])
As I have hinted above you have to find out what code is setting
$dba['results']['attendance_report'], what factors (variables) will affect
that code, and even try running that bit of code direct instead of going
through isAttendanceReport() (which itself is adding another layer of
unnecessary complexity).
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
You are wise, witty, and wonderful, but you spend too much time reading
this sort of trash.
*/
--- End Message ---
--- Begin Message ---
Ok... Here we go....
> On Tuesday 28 December 2004 23:43, GH wrote:
>
>
> > During the code... it gets to the following point...
> >
> > [snip]
> > #############################################
> > # Check if report report is present or not #
> > #############################################
> > if(!mysql_num_rows($dba['results']['attendance_report'])){
> > #report is not present
> > return 0;
> > }
> > else {
> > #report is present
> > return 1;
> > #gets here
> > }
> > [/snip]
> >
> > it gets to the return 1 section....
>
> Just to be sure, how are you determining that your code does indeed goes to
> the 'else' branch and return 1? Because if it does indeed return 1 then:
>
> echo isAttendanceReport(1); // should display 1
>
> For debugging something like this I would put in echo statements (or
> trigger_error()) all over the place to indicate which part of the code is
> being executed.
>
> > however the calling statement just does not seem to work....
>
> If isAttendanceReport() did indeed return 1 then the if-clause in
> displayMenu() would be obviously be true and would obviously execute (unless
> you have uncovered a bug in PHP). So the most likely explanation is that
> isAttendanceReport() is NOT returning 1.
>
> > using SID = 1, mysql_num_rows($dba['results']['attendance_report'])
> > evaluates to 8
> >
> > Dunno if that helps....
>
> How does $dba['results']['attendance_report'] get assigned? What variables
> does it rely on? What variables are present/not present in the case that
> succeeds/fails?
$dba['query']['attendance_report'] = "Select A.AttID, P.Part_ID,
P.LastName, P.FirstName, A.Present FROM Attendance A, Participants P,
Sessions S Where P.Part_ID = A.Participant AND S.SessionID =
A.Session AND A.Session = ".$sd . ' ORDER BY P.LastName ASC';
# attendance_report --> Query is written above.
$dba['results']['attendance_report'] =
mysql_query($dba['query']['attendance_report']) or
die('$dba[\'query\'][\'attendance_report\']: '.mysql_error());
>
> > > Isolate the problem, just run isAttendanceReport() on its own and plugin
> > > various values to see what comes back.
> >
> > How can I do that... I have tried but how do you see what the output
> > is? I have tried just echo ing it, print_r, var_dump ...
>
> By not running unnecessary code. In this case you seemed to have determined
> that isAttendanceReport() is not returning what you think it should be
> returning. Hence running displayMenu() to test for the return value of
> isAttendanceReport() is unnecessary, particularly when the execution of
> displayMenu() is itself subject to a switch construct. So cut through the
> crap and just run isAttendanceReport() direct as in:
>
> echo isAttendanceReport(SOME_VALUE_FOR_SID);
>
> If you still don't get any joy then dig deeper. What isAttendanceReport()
> returns is solely dependent on:
>
> mysql_num_rows($dba['results']['attendance_report'])
This return 8 for some the SID value of 1
>
> As I have hinted above you have to find out what code is setting
> $dba['results']['attendance_report'], what factors (variables) will affect
> that code, and even try running that bit of code direct instead of going
> through isAttendanceReport() (which itself is adding another layer of
> unnecessary complexity).
Most of isAttendanceReport() comes directly from the code of
AttendanceReport() --> the function that fulls the report... the only
thing that it does does diffrently is is check to see if the data is
there instead of displaying the data.
When I was doing the DEBUGGING I had put " echo 'got here(line
number)'; " statements during the code and it displayed going through
out the isAttendanceReport().
--- End Message ---
--- Begin Message ---
On Tuesday 28 December 2004 20:03, Ewout de Boer wrote:
> $data =
> file_get_contents("http://somehost.com/xmlonl.asp?custid=000000&prodid=0000
>0 ");
>
> if ($data)
> {
> ...
>
>
> the string this function returns is the webpage from the default website of
> the server where this php code is running at and not the data from the
> remote site (which is not on the same server).
Have you tried other URLs? With and without a query string? Could you give a
_real life_ example of a URL that doesn't work?
> i tried the url from my shell on the server using telnet and it gets the
> data i expected.
>
> I can't figure out why php is getting the wrong results while telnet on the
> same host gets the correct data. Is this a (known) error with php or is it
> a apache/php/server configuration problem ?
One possible explanation as to why it doesn't work within PHP but works with
something else is that the target site looks at the user-agent in the request
header and if it finds something it doesn't like (eg PHP) then it redirects
the request to http://localhost/ or something. That way the target site hopes
to prevent bots from harvesting its data.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
I didn't want a hokey second wedding like those ones on TV! This one's
for real!
-- Homer Simpson
A Milhouse Divided
*/
--- End Message ---
--- Begin Message ---
Ewout de Boer wrote:
I'm getting unexpected data from my file_get_contents function using an url
as filename.
The function does not return false, i do get data from it. Problem is that
is is not the data is requested.
$data =
file_get_contents("http://somehost.com/xmlonl.asp?custid=000000&prodid=00000
");
if ($data)
{
...
the string this function returns is the webpage from the default website of
the server where this php code is running at and not the data from the
remote site (which is not on the same server).
i tried the url from my shell on the server using telnet and it gets the
data i expected.
I can't figure out why php is getting the wrong results while telnet on the
same host gets the correct data. Is this a (known) error with php or is it a
apache/php/server configuration problem ?
regards,
Ewout
*Check your PHP runtime config to see if 'allow_url_fopen' is enabled.
(You can view your configuration using 'phpinfo'. You can change it in
your php.ini file.)
(See the first tip in the fine manual:
http://us4.php.net/manual/en/function.file-get-contents.php )
**
-John
*
--- End Message ---
--- Begin Message ---
> I'm getting unexpected data from my file_get_contents function using an
url
> as filename.
>
> The function does not return false, i do get data from it. Problem is that
> is is not the data is requested.
The ISP made a mistake in the server config :-( ... it works again
regards,
Ewout
--- End Message ---
--- Begin Message ---
to see if i can post...
--- End Message ---
--- Begin Message ---
On Tue, 2004-12-28 at 18:09 +0100, Steven Spierenburg wrote:
> to see if i can post...
>
no, you can't.
--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | [EMAIL PROTECTED]
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now supporting PHP5 ---
****************************************/
--- End Message ---
--- Begin Message ---
On Wednesday 29 December 2004 01:09, Steven Spierenburg wrote:
> to see if i can post...
If you have something to post why not just post it.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Fifty flippant frogs
Walked by on flippered feet
And with their slime they made the time
Unnaturally fleet.
*/
--- End Message ---
--- Begin Message ---
Hi There,
I recently installed PHP and have two things going on that I can't seem to
rectify or solve.
If I may use the collective knowledge of PHP users/developers on these
groups I would be grateful.
First some info on my setup:
OS : Windows 2000 Server
Webserver :IIS6
PHP : 4.3.10 (extracted zip version from php.net into folder "c:\php4")
phpinfo() page : www.jikade.com/test.php
The problems:
1) I want PHP to look for my php.ini file in the php folder (c:\php4) but it
refuses to do so. Setting PHPRC doesn't help and this setting actualy won't
show in the summary of phpinfo() in the environment section. I changed the
PATH environment variable to include "c:\php4" but that doesn't help either.
Putting the php.ini in the "c:\winnt" folder does work and then I configure
PHP through this file. Otherwise it won't load *any* php.ini file and use
defaults, or so it seems.
What I want to accomplish is that PHP finds and uses the php.ini file that
resides in the "c:\php4" folder
2) Some modules won't load, php_mcrypt.dll for one. I tried setting the
"extension_dir" (extension_dir = "c:\php4\extensions") but that doesn't
help. Copying the dll to the "c:\winnt\system32" folder doesn't work either.
Some modules do load however (php_df.dll loads fine from the same location),
it's just some modules that don't/won't. Examples are: php_mcrypt.dll,
php_mhash.dll and php_xmlrpc.dll.
What I want to accomplish here is that modules can load (obviously) :-)
Any help on these matters will be appreciated immensly!
ps: I used a MailExpire temporary email address to be able to post on this
newsgroup. Don't know if that's a faux-pas around here but I tend to be
realy carefull with my real email addresses on newsgroups due to spam
problems. If people say it's ok to use my real email address then I'll use
that one in future posts. Sorry for any inconvenience caused.
--
Greetings,
Steven Spierenburg
--- End Message ---
--- Begin Message ---
What is a $_FILE[user][error]=> 6
I can't find Error level 6 in the manual or on Google.
Here is my files array:
[userfile] => Array
(
[name] => Readme.txt
[type] =>
[tmp_name] =>
[error] => 6
[size] => 0
)
Doesn't make sense. Readme.txt is simply a small text file on my local HD.
Note, type doesn't register either.
Weird.....
--- End Message ---
--- Begin Message ---
On Wednesday 29 December 2004 01:40, Al wrote:
> What is a $_FILE[user][error]=> 6
>
> I can't find Error level 6 in the manual or on Google.
>
> Here is my files array:
>
> [userfile] => Array
> (
> [name] => Readme.txt
> [type] =>
> [tmp_name] =>
> [error] => 6
> [size] => 0
> )
>
> Doesn't make sense. Readme.txt is simply a small text file on my local HD.
>
> Note, type doesn't register either.
Does upload work at all, or does it only fail for that particular file?
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Sometime in 1993 NANCY SINATRA will lead a BLOODLESS COUP on GUAM!!
*/
--- End Message ---
--- Begin Message ---
Doesn't work on any file type.
I've checked the usual suspects. e.g.
<form enctype="multipart/form-data" action="_url_" method=\"post\"> URL is my
php file.
Jason Wong wrote:
On Wednesday 29 December 2004 01:40, Al wrote:
What is a $_FILE[user][error]=> 6
I can't find Error level 6 in the manual or on Google.
Here is my files array:
[userfile] => Array
(
[name] => Readme.txt
[type] =>
[tmp_name] =>
[error] => 6
[size] => 0
)
Doesn't make sense. Readme.txt is simply a small text file on my local HD.
Note, type doesn't register either.
Does upload work at all, or does it only fail for that particular file?
--- End Message ---
--- Begin Message ---
not sure if its a typo but the array shows "userfile" and your variable
array shows "user"
it looks like the file isn't being passed at all, double check if you have
any typos.. type is blank which should at least show the mime type..
----- Original Message -----
From: "Al" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, December 28, 2004 2:51 PM
Subject: Re: [PHP] $_FILE[user][error] = 6 ?
> Doesn't work on any file type.
>
> I've checked the usual suspects. e.g.
> <form enctype="multipart/form-data" action="_url_" method=\"post\"> URL is
my
> php file.
>
> On Wednesday 29 December 2004 01:40, Al wrote:
>
> What is a $_FILE[user][error]=> 6
>
>I can't find Error level 6 in the manual or on Google.
>
>Here is my files array:
>
>[userfile] => Array
> (
> [name] => Readme.txt
> [type] =>
> [tmp_name] =>
> [error] => 6
> [size] => 0
> )
>
> Doesn't make sense. Readme.txt is simply a small text file on my local
HD.
--- End Message ---
--- Begin Message ---
is <form enctype="multipart/form-data" action="_url_" method=\"post\">
what comes out in the html or is it <form
enctype="multipart/form-data" action="_url_" method="post">?
can you upload any files at all?
--- End Message ---
--- Begin Message ---
I keyed "$_FILE[user][error]" from memory, and it's wrong. It really is
"userfile";
Weird problem, eh!
Sebastian wrote:
not sure if its a typo but the array shows "userfile" and your variable
array shows "user"
it looks like the file isn't being passed at all, double check if you have
any typos.. type is blank which should at least show the mime type..
----- Original Message -----
From: "Al" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, December 28, 2004 2:51 PM
Subject: Re: [PHP] $_FILE[user][error] = 6 ?
Doesn't work on any file type.
I've checked the usual suspects. e.g.
<form enctype="multipart/form-data" action="_url_" method=\"post\"> URL is
my
php file.
On Wednesday 29 December 2004 01:40, Al wrote:
What is a $_FILE[user][error]=> 6
I can't find Error level 6 in the manual or on Google.
Here is my files array:
[userfile] => Array
(
[name] => Readme.txt
[type] =>
[tmp_name] =>
[error] => 6
[size] => 0
)
Doesn't make sense. Readme.txt is simply a small text file on my local
HD.
--- End Message ---
--- Begin Message ---
I have written a function to generate and store a salt data for a
session cookie. I haven't written the MySQL code, so that is absent.
Basically what I am trying to do is make it so that if there is no
value submitted for an argument, I want it to fall back to the
defaults set up in my config.ini file. This file is successfully
parsed into the array "$_SETTINGS". I have no problems doing this. I
get an "Unexpected T_VARIABLE" in the line with the function
definition. I know this means that I've got a variable call in the
wrong place, but I don't know why it thinks it is wrong.
Can you not default to variables in a function? Or am I just writing
it incorrectly? Please enlighten me on this, I'm pretty much stuck.
--CODE SNIPPET--
function create_salt_data($destination =
$_SETTINGS['session.salt_var'], $prefix =
$_SETTINGS['session.salt_prefix'], $crypt_method =
$_SETTINGS['session.salt_crypt']) {
$crypt_command = '$salt_data = ' . $crypt_method . '(uniqid("' .
$prefix . '"));';
//Did compiling the salt together fail? If so, return failure.
if (!eval($crypt_command)) {
return false;
}
// $salt_data = $crypted_salt;
if ($destination != 'return') {
$_SESSION[$destination] = $salt_data;
return true;
}
else {
return $salt_data;
}
}
I have worked around it by making the defaults null, and then testing
and replacing them inside the function. It takes more code than I
would like it to, I'm trying to condense my files.
Thanks in advance!
--
The Disguised Jedi
[EMAIL PROTECTED]
PHP rocks!
"Knowledge is Power. Power Corrupts. Go to school, become evil"
Disclaimer: Any disclaimer attached to this message may be ignored.
This message is Certified Virus Free
--- End Message ---
--- Begin Message ---
On Wednesday 29 December 2004 01:46, The Disguised Jedi wrote:
> Can you not default to variables in a function?
No.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
If you don't know what game you're playing, don't ask what the score is.
*/
--- End Message ---
--- Begin Message ---
Hi all
I am making a gallery for my Homepage. Now, I want to make little
tumbnails of my work and make a table out of them. So, to not put them
all in a row, what whould make the site unreadable, i have to put them
in a little table, an i think 4 in each row would be ok.
I like to read out the pic's name etc. out of a mysql table. But how do
make the script to write a </tr> after it read out 4 entries of a mysql
table?
Thanks in advance :)
--- End Message ---
--- Begin Message ---
On Tue, 2004-12-28 at 19:47 +0100, [EMAIL PROTECTED] wrote:
> Hi all
>
> I am making a gallery for my Homepage. Now, I want to make little
> tumbnails of my work and make a table out of them. So, to not put them
> all in a row, what whould make the site unreadable, i have to put them
> in a little table, an i think 4 in each row would be ok.
>
> I like to read out the pic's name etc. out of a mysql table. But how do
> make the script to write a </tr> after it read out 4 entries of a mysql
> table?
>
> Thanks in advance :)
I'd reply, but I don't think it would go anywhere:
> [EMAIL PROTECTED] wrote:
--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | [EMAIL PROTECTED]
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now supporting PHP5 ---
****************************************/
--- End Message ---
--- Begin Message ---
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Hi all
>
> I am making a gallery for my Homepage. Now, I want to make
> little tumbnails of my work and make a table out of them.
> So, to not put them all in a row, what whould make the site
> unreadable, i have to put them in a little table, an i think
> 4 in each row would be ok.
>
> I like to read out the pic's name etc. out of a mysql table.
> But how do make the script to write a </tr> after it read
> out 4 entries of a mysql table?
>
> Thanks in advance :)
What I generally do is use the mod (%) operator to keep track of where
it is. It returns the remainder of the divisional operator, as such:
0 % 4 == 0
1 % 4 == 1
2 % 4 == 2
3 % 4 == 3
4 % 4 == 0
5 % 4 == 1
6 % 4 == 2
etc...
That way, you have a guaranteed 4-member looping variable.
Try something like this:
<?
$result = mysql_query("SELECT * FROM foo ORDER BY bar");
$count = 0;
while ($row = mysql_fetch_assoc($result)) {
$loopcount = $count % 4;
if ($loopcount == 0) {
echo "<tr>\n";
}
echo "<td>{$row['baz']}</td>\n";
if ($loopcount == 3) {
echo "</tr>\n";
}
}
?>
The only problem is that at the end of the while() loop, if you want to
have perfectly-formatted HTML, you need to figure out if it left off in
the middle of a row and fill with N empty <td></td> tags.
Also, if there's a better way to do this, I'm all ears. This is the way
I've done it for years, but it /is/ a pain to do.
Anyway, HTH!
--
Mike Johnson Smarter Living, Inc.
Web Developer www.smarterliving.com
[EMAIL PROTECTED] (617) 886-5539
--- End Message ---
--- Begin Message ---
Robby Russell wrote:
I'd reply, but I don't think it would go anywhere:
[EMAIL PROTECTED] wrote:
So that's who has 'domain.invalid'. Damn, I wanted to register that. ;)
--
John C. Nichel
�berGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Mike Johnson wrote:
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Hi all
I am making a gallery for my Homepage. Now, I want to make
little tumbnails of my work and make a table out of them.
So, to not put them all in a row, what whould make the site
unreadable, i have to put them in a little table, an i think
4 in each row would be ok.
I like to read out the pic's name etc. out of a mysql table.
But how do make the script to write a </tr> after it read
out 4 entries of a mysql table?
Thanks in advance :)
What I generally do is use the mod (%) operator to keep track of where
it is. It returns the remainder of the divisional operator, as such:
0 % 4 == 0
1 % 4 == 1
2 % 4 == 2
3 % 4 == 3
4 % 4 == 0
5 % 4 == 1
6 % 4 == 2
etc...
That way, you have a guaranteed 4-member looping variable.
Try something like this:
<?
$result = mysql_query("SELECT * FROM foo ORDER BY bar");
$count = 0;
while ($row = mysql_fetch_assoc($result)) {
$loopcount = $count % 4;
if ($loopcount == 0) {
echo "<tr>\n";
}
echo "<td>{$row['baz']}</td>\n";
if ($loopcount == 3) {
echo "</tr>\n";
}
}
?>
The only problem is that at the end of the while() loop, if you want to
have perfectly-formatted HTML, you need to figure out if it left off in
the middle of a row and fill with N empty <td></td> tags.
Also, if there's a better way to do this, I'm all ears. This is the way
I've done it for years, but it /is/ a pain to do.
Anyway, HTH!
Heh, that looks better than what I usually do, but to put a clean finish
on it, you could do something like:
$loopcount = $count % 4;
if($loopcount > 0)
{
for(;$loopcount < 4;++$loopcount) echo "<td>empty cell</td>\n";
echo "</tr>\n";
}
That should work, and could be cleaned up a bit better I imagine...
Chris
--- End Message ---
--- Begin Message ---
* Mike Johnson <[EMAIL PROTECTED]>:
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > I am making a gallery for my Homepage. Now, I want to make
> > little tumbnails of my work and make a table out of them.
> > So, to not put them all in a row, what whould make the site
> > unreadable, i have to put them in a little table, an i think
> > 4 in each row would be ok.
> >
> > I like to read out the pic's name etc. out of a mysql table.
> > But how do make the script to write a </tr> after it read
> > out 4 entries of a mysql table?
> >
> > Thanks in advance :)
>
> What I generally do is use the mod (%) operator to keep track of where
> it is.
<snip>
> The only problem is that at the end of the while() loop, if you want to
> have perfectly-formatted HTML, you need to figure out if it left off in
> the middle of a row and fill with N empty <td></td> tags.
>
> Also, if there's a better way to do this, I'm all ears. This is the way
> I've done it for years, but it /is/ a pain to do.
CSS and floats are your friend:
<style><!--
.gallery_image {
width: 200px;
float: left;
margin-right: 1em;
margin-bottom: 1em;
}
.clear {
clear: both;
margin: 0;
padding; 0;
height: 0;
}
--></style>
<!-- Loop over this, adding image sources and captions -->
<div class="gallery_image">
<img src="..." alt="..." /><br />
caption here...
</div>
<!-- End of loop -->
<div class="clear"> </div>
The beauty of this method is:
* As the browser window expands, more images are allowed per row
* No need to muck about with closing rows
* Separation of content from layout
The cons:
* If you have some images landscape, some portrait, you may get some
uneven spacing amongst rows. This can be solved by adding a height
attribute to the style, but if your captions are of variable length,
this could cause some strange display issues on longer captions.
--
Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
--- End Message ---
--- Begin Message ---
Hello,
I have the SOAP PEAR package set up correctly to the point where I can send a
request and get a response. However, my web service is designed to return XML
back to the caller. When I do this, all of the tags have their "<" and ">"
converted to < and >. I have spent much time searching the web for an
answer to this, but have come up empty handed. If anyone knows how to solve
this that would be great. Also, if anyone has experience writing a web service
in PHP that returns XML I am open to suggestions of approaches other than using
the PEAR SOAP package.
Thanks,
-------------------------
Doug Jones
Co-Op Web Developer
--- End Message ---
--- Begin Message ---
Just thought I'd throw this one out there to test the waters...
This past weekend, I was fiddling with cURL to create a "bot" that could
auto-post to my phpBB message board on-demand. All was working well with
getting it to login to the board and post, but the strange part came
when I discovered that it would shear form vars at a \n character.
I never did pinpoint it to whether it was cURL or phpBB doing it, but I
suspected cURL. I also didn't do much testing outside of my application
outside of messing with every CURLOPT_* setting I could lay my hands on.
Has anyone ever run into something like this, though? I Googled to no
avail...
--
Mike Johnson Smarter Living, Inc.
Web Developer www.smarterliving.com
[EMAIL PROTECTED] (617) 886-5539
--- End Message ---
--- Begin Message ---
Are you talking about the variable you're POSTing? Does it make a
difference if you urlencode the form var? Have you tried debugging
from the server end to see what cURL is passing over? I use cURL
quite a bit, although I've never tried passing muti-line form data.
On Tue, 28 Dec 2004 15:04:36 -0500, Mike Johnson <[EMAIL PROTECTED]> wrote:
> Just thought I'd throw this one out there to test the waters...
>
> This past weekend, I was fiddling with cURL to create a "bot" that could
> auto-post to my phpBB message board on-demand. All was working well with
> getting it to login to the board and post, but the strange part came
> when I discovered that it would shear form vars at a \n character.
>
> I never did pinpoint it to whether it was cURL or phpBB doing it, but I
> suspected cURL. I also didn't do much testing outside of my application
> outside of messing with every CURLOPT_* setting I could lay my hands on.
>
> Has anyone ever run into something like this, though? I Googled to no
> avail...
>
> --
> Mike Johnson Smarter Living, Inc.
> Web Developer www.smarterliving.com
> [EMAIL PROTECTED] (617) 886-5539
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
I started to put together a few classes that reads/writes files,
using the fopen() function, injunction with flock() to
lock files while reading/writing.
And I also was wrapping fopen()/flock() around copy()/unlink()/rename()
with the thinking that they needed file locking *features* while
modifying the filesystem.
I initially chose to use flock() to cut down possibilities of *race
conditions*.
Now Im beginning to question even using the fopen()/flock() way of
reading/writing
files, and instead go to file_[get|put]_contents().
As I understand it, race conditions *can* occur during the php steps
of reading/writing files using the fopen() method ->
fopen(...);
// read or write to file with fread()/fwrite()
fclose(...);
Now my thinking is that if I were to start using file_[get|put]_contents(),
and do away with fopen()/flock(), there would be no need for file locking,
since file_[get|put]_contents() is just one php operation.
I may be wrong with this assumption.
Im looking to see what others may think about file locking using php
functions,
file_[get|put]_contents()/copy()/unlink()/rename() to read/write/modify
the filesystem.
Is it even neccessary in php5?
Thanks for any insight that you can provide...
--- End Message ---
--- Begin Message ---
Which type of engine would y'all recommend for a user/customer and
session data storage database? I'm currently using MyISAM, but I just
was curious to see if you guys could tell me if you know of a better
one, or tell me what you use.
TIA,
--
The Disguised Jedi
[EMAIL PROTECTED]
PHP rocks!
"Knowledge is Power. Power Corrupts. Go to school, become evil"
Disclaimer: Any disclaimer attached to this message may be ignored.
This message is Certified Virus Free
--- End Message ---
--- Begin Message ---
> $a = $b ^^ $c
You sure? It didn't work for me, and it isn't listed in the PHP manual.
I used:
<?php
var_dump(1 ^^ 0);
var_dump(0 ^^ 1);
var_dump(0 ^^ 0);
var_dump(1 ^^ 1);
?>
to test it and got a syntax error.
I suppose you could use the bitwise one as a bit of a hack, so long as
you 'boolean-ised' both arguments first.
eg $a = (!!$b) ^ (!!$c); // or even $a = !$b ^ !$c; since xor
depends exclusively on both sides being different to each other.
> > Generally however there is no need to parentisize everything to the
> > right of the assignment operator(=), since besides 'and', 'or', 'xor',
> > and the comma operator. The only time I see the need to parentisize
> > everything to the right is when using the xor operator, since there is
> > no equivlent above the = operator.
>
> $a = $b ^^ $c;
>
> --
> Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
>
> http://www.smempire.org
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hi there I am in a bit of a dilemma, I have been leaning towards ADODB for
its speed, but I amliking to use some pear components that only handle pear db
etc .. Honest
opinions, I am doingweb applications and building a little framework for it,
will I notice any
performance differences if Iuse DB ? I have used DB alot in the past, but for
this current job had to
build a custom DBabstraction class with error handling. Let me know
--- End Message ---
--- Begin Message ---
Haven't done much with either of them, besides reading docs, but I'd
lean towards ADODB for its exception handling(with php5), if you need
error handling.
Having that said, I haven't really a clue what I'm talking about in
this regard, so I'll be listening in with interest.
On Wed, 29 Dec 2004 12:25:23 +1100 (EST), [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hi there I am in a bit of a dilemma, I have been leaning towards ADODB for
> its speed, but I amliking to use some pear components that only handle pear
> db etc .. Honest
> opinions, I am doingweb applications and building a little framework for it,
> will I notice any
> performance differences if Iuse DB ? I have used DB alot in the past, but for
> this current job had to
> build a custom DBabstraction class with error handling. Let me know
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
> Haven't done much with either of them, besides reading docs, but I'd
> lean towards ADODB for its exception handling(with php5), if you need
> error handling.
>
> Having that said, I haven't really a clue what I'm talking about in
> this regard, so I'll be listening in with interest.
>
I'm assuming PEAR error handling will come out with exception handling ?
Besides , i am using thepear syntax in adodb , i wonder if it will still work
with the components
ie DataGrid andDB_DataObjects. These tools will be highly useful, I cant see
much pear
stuff compatible withADODB
--- End Message ---
--- Begin Message ---
Hi all,
I'm testing an PHP application, this application
requires TTF extension.
Please help me a way to configure PHP enabling TTF
extension.
I have to download & install which application/module
to configure
successfully.
I'm using Linux OS (FC3).
Any help will be appreciated highly!
Thanks in advance.
Hung Le
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
--- End Message ---