php-general Digest 20 Apr 2006 10:36:31 -0000 Issue 4082
Topics (messages 234316 through 234345):
Query for two fields with the same name
234316 by: Kevin Murphy
234318 by: Jochem Maas
234321 by: admin.ensifex.nl
234323 by: Richard Lynch
Re: session_destroy
234317 by: Jochem Maas
234337 by: Richard Lynch
Re: pause until page is loaded
234319 by: Jochem Maas
Modest Module: perror (exec error codes)
234320 by: Richard Lynch
Re: no offense to Rasmus... are you kidding me
234322 by: Robin Vickery
234329 by: Richard Lynch
Re: Mnogosearch extension - not working with php 4.4.2
234324 by: Richard Lynch
Re: PHP CLI not present
234325 by: Richard Lynch
issue with MySQL procedure and a result set
234326 by: Alain Roger
234339 by: Richard Lynch
Re: how should MS Access DATETIME be handled in PHP?
234327 by: John Wells
234334 by: Richard Lynch
Re: Pushing Vars into $_SESSION
234328 by: Chris Grigor
234330 by: Barry
Execute script and redirect
234331 by: Peter Lauri
234332 by: Barry
234338 by: Richard Lynch
234340 by: Peter Lauri
Re: programming contests as a way of finding/evaluating offshore talent...
234333 by: Richard Lynch
Re: Forking a search - pcntl
234335 by: Richard Lynch
Re: New image already cached.
234336 by: Richard Lynch
Best way to start a CRON
234341 by: Barry
234342 by: nicolas figaro
234343 by: Pure Web Solution
234344 by: Barry
POST arrays?
234345 by: William Stokes
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 ---
This is probably a simple question, but I can't seem to find the
answer online.
I'm using this query:
$connection = "select * from connection, pr WHERE connection.area_id
= '$gateway_link' and connection.pr_id = pr.id";
Both tables have a field called ID but they have different
information in them. $row['id'] gets me the one from the table called
"pr" but I need to call the ID from the table connection.
--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326
--- End Message ---
--- Begin Message ---
NOT a php question.
Kevin Murphy wrote:
This is probably a simple question, but I can't seem to find the answer
online.
I'm using this query:
$connection = "select * from connection, pr WHERE connection.area_id =
'$gateway_link' and connection.pr_id = pr.id";
doing "SELECT * FROM bla" is not recommended, better to actually specify _just_
the fields you need.
"SELECT c.id AS cid, p.id AS pid FROM connection AS c, pr AS p WHERE ... "
this stuff can be found in the mysql docs.
Both tables have a field called ID but they have different information
in them. $row['id'] gets me the one from the table called "pr" but I
need to call the ID from the table connection.
--- End Message ---
--- Begin Message ---
Maybe something like this :
$connection = "SELECT t2.id AS idtwo, t1.id AS idone FROM connection AS
t1, pr AS t2 WHERE t1.area_id
= '$gateway_link' AND t1.pr_id = t2.id";
> This is probably a simple question, but I can't seem to find the
> answer online.
>
> I'm using this query:
>
> $connection = "select * from connection, pr WHERE connection.area_id
> = '$gateway_link' and connection.pr_id = pr.id";
>
> Both tables have a field called ID but they have different
> information in them. $row['id'] gets me the one from the table called
> "pr" but I need to call the ID from the table connection.
>
> --
> Kevin Murphy
> Webmaster: Information and Marketing Services
> Western Nevada Community College
> www.wncc.edu
> 775-445-3326
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Wed, April 19, 2006 5:55 pm, Kevin Murphy wrote:
> $connection = "select * from connection, pr WHERE connection.area_id
> = '$gateway_link' and connection.pr_id = pr.id";
>
> Both tables have a field called ID but they have different
> information in them. $row['id'] gets me the one from the table called
> "pr" but I need to call the ID from the table connection.
You have now stumbled into ONE of many reasons why "SELECT *" is just
Bad Code. :-)
Figure out which fields you REALLY need and specify them by name in
place of *
In addition, to actually solve your problem, you'll be able to do
something like:
SELECT pr.id as pr_id, connection.id as connection_id, area_id, ...
You can use " as XYZ" to sort of "rename" any column you want on the
fly, and that is what it will be called.
It's also really handy when you have formulas in your select:
SELECT (x.size + y.size) as sum, x.id, y.id from x, y ...
Without the "as sum" $row['something goes here'] will have your sum
answer, but what will it be called?
I don't even know the answer to that one, cuz whatever it is, it's
just too painful compared to using 'sum'
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Shannon Doyle wrote:
Hi People,
Trying to get a session to destroy correctly, however the darn thing just
refuses to destroy. I call the following in a separate webpage in a effort
to destroy the session, only to find that the session still persists.
<?php
session_start();
session_unset();
session_destroy();
Header("Location: index.php");
?>
Any help would be appreciated.
I looked into really nuking a session quite a while back
and after searching around and scraping together some snippets of
code I came up with this:
<?php
function destroySession($delSessFile = false)
{
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
$CookieInfo = session_get_cookie_params();
if ( (empty($CookieInfo['domain'])) && (empty($CookieInfo['secure'])) ) {
setcookie(session_name(), '', time()-3600, $CookieInfo['path']);
} elseif (empty($CookieInfo['secure'])) {
setcookie(session_name(), '', time()-3600, $CookieInfo['path'],
$CookieInfo['domain']);
} else {
setcookie(session_name(), '', time()-3600, $CookieInfo['path'],
$CookieInfo['domain'], $CookieInfo['secure']);
}
}
// Finally, destroy the session.
session_destroy();
// go over board and actually delete the file right here and now!
if ((boolean)$delSessFile) {
$orgpath = getcwd(); /* chdir(PHP_BINDIR); */
chdir(session_save_path());
$path = realpath(getcwd()).'/';
if(file_exists($path.'sess_'.$id)) {
// Delete it here
unlink($path.'sess_'.$id);
}
chdir($orgpath);
}
}
?>
hth
--- End Message ---
--- Begin Message ---
On Wed, April 19, 2006 9:11 am, Paul Waring wrote:
> setcookie(session_name(), '', (time() - 86400), /);
/ should be in quotes or apostrophes.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Tue, April 18, 2006 4:19 pm, Benjamin Adams wrote:
I created a script to redirect to a download auto.
but it redirects before the Whole page is loaded.
How do I pause until page is loaded?
If you want to wait until the BROWSER loads the whole page, then the
BROWSER has to tell you when it has finished.
Since the communication between the BROWSER and PHP is limited to:
BROWSER: Gimme this URL
PHP: Here, here's your data. Bye. I'm gone.
Note that the browser could spend an HOUR (in principle) rendering the
data sent by PHP, if that rendering was particularly difficult.
So, clearly, PHP is *NOT* going to be able to do what you want.
You are therefore urged to consult a Javascript list.
Or an AJAX list.
Or, really, any kind of mailing list about running code on a BROWSER,
but not PHP, which runs on the SERVER.
I don't suppose this is the time to mention that Wez Furlong wrote a
browser plugin that allows you to run php code in the browser in the same
way you would normally run javascript ;-)
[http://pecl.php.net/package/PHPScript]
(Benjamin - just to be clear, Richard is correct and my comment doesn't help
your problem 1 iota, sorry :-)
:-)
--- End Message ---
--- Begin Message ---
I've written my first external Module for PHP: perror
It provides functionality I've always felt was "missing" in PHP.
I'm particularly interested in feedback from anybody who has written
PHP extensions of their own -- I'm sure there's room for improvement
in my very rusty C skills!
Here's why I wrote it. Consider this:
<?php
exec("ls /root", $output, $error);
if ($error) die("OS Error: $error");
echo nl2br(implode('', $output));
?>
Wouldn't it be nice if PHP "knew" the error message that went with
Error code number 1?
Well, install this 'perror' module, and PHP does know :-)
As a special bonus, since it was pretty much the exact same thing, I
threw in the codes for "signals" as well.
A quick phpize and compile and a php.ini change, and you're set!
I can't promise no problems, but it's pretty dang simple, really, so
should be pretty safe. And you can always comment out php.ini
extension setting pretty quickly if it causes problems.
See sample output (live, actually) and download the source:
http://www.l-i-e.com/perror/
PS
*HUGE* thanks to the folks on PHP-Dev who put up with my bumbling
through the compiling process for an extension on a shared server!
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On 19/04/06, Matt Todd <[EMAIL PROTECTED]> wrote:
>
> I know that PHP is a functional language, and secondly, an OO
> language, but I think that you can blend these things better and have
> the OO brought to the forefront a bit more.
PHP is not a functional language, it's an imperative language.
-robin
--- End Message ---
--- Begin Message ---
On Wed, April 19, 2006 9:42 am, Matt Todd wrote:
> Honestly, I'd love to see basic variables be objects, as models of
> real world data with properties for the data such as a $number->length
> or $word->as_array() giving you letters.
I think you might want to consider using Common Lisp, then.
Cuz pretty much everyting in Common Lisp is an Object.
'Course, it's even WAY older than PHP, so you won't, but there it is.
I am curious to know what you think this should do:
$number = 5;
echo $number->length;
Exactly what is the length of a number?
Is 5 longer than 4?
How about -5?
Is that the same length as 5?
Sheesh!
Let me know when Web 2.0 is actually released. Until then: SHUT UP!
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Wed, April 19, 2006 4:55 pm, Yannick Warnier wrote:
> for. From the type of errors (very unclear and undetailed) that I get,
> my first guess would be that one function declaration in php_mnogo.c
> or
> php_mnogo.h would not be recognized anymore (because it used a funny
> declaration?).
Call me crazy, but I think you should post the actual error messages
-- the first few, at least.
C compiler error messages are frequently arcane, incredibly terse, and
complete gibberish to anybody other than a C programmer...
But they are rarely unclear and undetailed, once you have figured out
what the error message means the first time you encounter it.
'Course, I probably won't be the guy who understand the message
either, as my C skills have 20 years of rust and only a couple days of
scraping that off.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Wed, April 19, 2006 3:01 pm, Jeff wrote:
> I'm running PHP Ver 4.4.1 on a redhat ES3 system. It appears that the
> CLI is not running or not present. I thought it was installed by
> default in versions >= 4.3.x.
>
> If I run /usr/local/bin/php -v at the command line I get nothing.
>
> How do I get the PHP CLI working?
I don't remember at which version CLI became installed by default with
Apache, but if you still have your config.nice script you'd want to
check that, and the config.log and config.debug to see what happened.
It's possible you just installed it in some different directory...
Something like:
locate php | grep bin
might be useful for finding that.
You could also download the source and install just the CLI pretty
quickly and easily. Or you may want to upgrade anyway :-)
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Hi,
I'm trying to run a MySQL Procedure from one of my PHP page.
1. the procedure works perfectly under MySQL (it gives the correct results),
so no issue from this side.
2.user is able to connect without any issue to MySQL RDBMS, so no issue from
this side.
Here is what i've as error message when PHP page is displayed :
"PROCEDURE test1 can't return a result set in the given context"
i've searched on internet and i've found 2 intereseting information :
1. i should update MyODBC connector. But i do not understand it as it work
perfectly under MySQL query browser or under another Query tool.
2. i should add a flag in my command : mysql_connect(....);
this flag should be something like MULTI_CLIENT_..... After controling the
PHP documentation (v5.1 and 4.6) this flag does not exist...
here is my stored procedure "test1" (this procedure as 1 IN parameter named
"criteria"
....
BEGIN
DECLARE crit VARCHAR(256) DEFAULT "";
SET crit = CONCAT("%", criteria, "$");
SELECT * FROM persons WHERE login LIKE crit;
END
...
So what should i do ?
thanks a lot for help.
Alain
--- End Message ---
--- Begin Message ---
On Thu, April 20, 2006 1:55 am, Alain Roger wrote:
> I'm trying to run a MySQL Procedure from one of my PHP page.
>
> 1. the procedure works perfectly under MySQL (it gives the correct
> results),
> so no issue from this side.
> 2.user is able to connect without any issue to MySQL RDBMS, so no
> issue from
> this side.
>
> Here is what i've as error message when PHP page is displayed :
> "PROCEDURE test1 can't return a result set in the given context"
>
> i've searched on internet and i've found 2 intereseting information :
> 1. i should update MyODBC connector. But i do not understand it as it
> work
> perfectly under MySQL query browser or under another Query tool.
Are you using MyODBC?
Why?!
If you are, then this is probably the problem/solution.
See, what MySQL supports and what MyODBC will support in terms of SQL
and PROCEDURES and whatnot don't have to match up.
So you need the new MyODBC and that's all there is to it.
Or switch to using PHP's mysql() functions.
> 2. i should add a flag in my command : mysql_connect(....);
> this flag should be something like MULTI_CLIENT_..... After controling
> the
> PHP documentation (v5.1 and 4.6) this flag does not exist...
Check the MySQL docs. It's probably a constant in MySQL, not in PHP.
Also just try this:
<?php echo MULTI_CLIENT.....;?>
Only type the real constant name.
If it's not defined in PHP, you'll just see 'MULTI_CLIENT....'
If it is defined, it will probably be a number like 15 or 63 or
something.
If it is not defined, you can probably find out what the number is in
the MySQL docs. If you find out that it is, say, 3, then do:
<?php
define('MULTI_CLIENT...', 3);
?>
and just follow the directions about connect.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
I don't know if MS Access will behave the same, but in MySQL you can
have a query like so:
SELECT *, DATE_FORMAT(end_date, '%d %m %Y') as end_date_formatted FROM projects;
And it will retrieve all columns from your projects table, plus the
extra one you've created on the fly, and it will be named
"end_date_formatted".
HTH,
John W
On 4/19/06, Bing Du <[EMAIL PROTECTED]> wrote:
> > Do the search as Richard suggested.
> >
> > MS Access might have a similar function you can use, but you'll need
> > to do some searching yourself to find the answer.
> >
> Sure. I always appreciate various opinions. I've checked with an Access
> expert. It can be done for Access like Format([DateFieldName], "dddd mmmm
> yyyy"). But if fields of date type should be formated as needed in the
> query, there is one situation in which I'm not clear how that would work.
> Say, I need to query all the fields from a table which has quite a fields.
> Some of the fields are of some kind of date type. Enumerating the fields
> is not feasible.
>
> SELECT * from table;
>
> So in this case, how should the date fields be formated in the query?
>
> Thanks,
>
> Bing
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Wed, April 19, 2006 9:38 am, Bing Du wrote:
>> Do the search as Richard suggested.
>>
>> MS Access might have a similar function you can use, but you'll need
>> to do some searching yourself to find the answer.
>>
> Sure. I always appreciate various opinions. I've checked with an
> Access
> expert. It can be done for Access like Format([DateFieldName], "dddd
> mmmm
> yyyy"). But if fields of date type should be formated as needed in
> the
> query, there is one situation in which I'm not clear how that would
> work.
> Say, I need to query all the fields from a table which has quite a
> fields.
> Some of the fields are of some kind of date type. Enumerating the
> fields
> is not feasible.
>
> SELECT * from table;
>
> So in this case, how should the date fields be formated in the query?
If you've got too many fields in the table to enumerate them all and
apply Format() to them, then you've got MUCH bigger problems on your
hands than date format... :-^
That said, there MAYBE is some kind of introspection function in
whatever you are using to find out which fields are date type and
which are not.
PHP and MySQL have it as:
http://php.net/mysql_field_type
So you should be able to come up with a script that:
#1. Examines the table and finds all the fields of type: 'date'
#2. Constructs a query that gets all the fields, but for those of type
'date' wraps Format(date, 'YYYY-MM-DD HH:II:SS') around them. (Or
whatever you need to get what you want)
#3. Send your programmatically-constructed query to the database to
get the data you want, the way you want it.
#4. Drive-through Burger King.
You're on your own to actually find the functions that do the
introspection, if they exist for Access. Ain't nobody got enough
money to make me actually use Access.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Wed, April 19, 2006 1:36 am, Chris Grigor wrote:
Richard Lynch wrote:
On Tue, April 18, 2006 10:05 am, Chris Grigor wrote:
Was wondering if there is an easier way to get returned variables
into
the $_SESSION rather than going through each one??
foreach($line as $key => $value) $_SESSION[$key] = $value;
Why do this?
Is it really going to help you to have the data stored in TWO
places?
I predict that if you really think about what you are doing, you
won't
want to do this. There are simply too many pitfalls for this to be a
The point of me doing this is that I will be pulling menu flags from a
database on a user level.
in the db I will have menu items 1 to 20 turned on or off. When a user
logs in these flags are pulled
and depending if they are truned on or off, the menu will display.
Catch my drift??
Tell us the part about where having them copied into $_SESSION makes
your software better... :-)
Database -> Menu is a very simple and common web design.
Database -> $_SESSION -> Menu only adds an extra step, AFAICT.
Are you able to completely avoid connecting to the database on many
subsequent pages this way? That could be Good Code.
Or are you just avoiding a single simple query that, with indexed
fields, should run in a splintered second? That's probably Bad Code.
$_SESSION data is not free.
It's not even cheaper than MySQL data, as a general rule -- though it
might be in specific cases.
Simplify, grasshopper.
:-)
The method behind the madness here, is that I am only pulling the data
once from the db throughout the whole session. This means that all the
user info is available on every page they visit. I can also
then identify on each page that loads if a user has signed in and a
session is present. Do you think I am going about this in the wrong way?
What would you suggest is a better idea???
Chris
--- End Message ---
--- Begin Message ---
Chris Grigor wrote:
The method behind the madness here, is that I am only pulling the data
once from the db throughout the whole session. This means that all the
user info is available on every page they visit. I can also
then identify on each page that loads if a user has signed in and a
session is present. Do you think I am going about this in the wrong way?
What would you suggest is a better idea???
Chris
All the user info? Wouldn't it be enough to have a link on that User?
So that you can get the information you need rather than have all stored
in a Session.
Btw. what would you do if the User starts updating his Profile.
Wouldn't it be easier to just update the Data-Field of the User rather
than updating session and Data-Field?
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
Best groupmember,
I have a form that is being filled out. This is the process:
1. Fill out form and click submit
2. Script validates data
3. Data is being sent to external source via Web Service
4. A file is being downloaded (redirects to files location)
The problem is that #3 is taking around 15 seconds to complete because the
Web Service is very slow. I would like to run #3 in the background and
directly jump to #4.
Is this possible?
A little confused :)
/Peter
--- End Message ---
--- Begin Message ---
Peter Lauri wrote:
Best groupmember,
I have a form that is being filled out. This is the process:
1. Fill out form and click submit
2. Script validates data
3. Data is being sent to external source via Web Service
4. A file is being downloaded (redirects to files location)
The problem is that #3 is taking around 15 seconds to complete because the
Web Service is very slow. I would like to run #3 in the background and
directly jump to #4.
Is this possible?
Yes. you might use the shell execution for that OR fopen() without url
restriction and send the commands to the file.
There are lots of ways to do that...
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
On Thu, April 20, 2006 2:23 am, Peter Lauri wrote:
> 1. Fill out form and click submit
> 2. Script validates data
> 3. Data is being sent to external source via Web Service
> 4. A file is being downloaded (redirects to files location)
>
> The problem is that #3 is taking around 15 seconds to complete because
> the
> Web Service is very slow. I would like to run #3 in the background and
> directly jump to #4.
>
> Is this possible?
There's possible, and then there's possible...
How about this:
The BEST solution would be to insert the [valid/clean] data into a
database, and run a cron job to send off everything to the Web
Service.
You'll have to mark what's sent and what isn't and be careful not to
run two jobs at once when it's really slow (sending duplicate data)
nor to "skip" data that didn't safely get sent.
But should do all that anyway in your script.
There might even be functions in the Web Service to make it easy for
you to send a whole BUNCH of records at once, saving a lot of time on
your end.
And, for sure, if all your script has to do is insert to a database
table for step 3, it's gonna be pretty fast.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
That was a smart solution. However, my client have not given me access to
the MySQL database at this stage (just doing a small side project of the
clients web site). If you could not take advantage of database and cron job,
what would you do?
PS! I am not sure that my clients host supports cron jobs DS!
-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 20, 2006 2:57 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Execute script and redirect
On Thu, April 20, 2006 2:23 am, Peter Lauri wrote:
> 1. Fill out form and click submit
> 2. Script validates data
> 3. Data is being sent to external source via Web Service
> 4. A file is being downloaded (redirects to files location)
>
> The problem is that #3 is taking around 15 seconds to complete because
> the
> Web Service is very slow. I would like to run #3 in the background and
> directly jump to #4.
>
> Is this possible?
There's possible, and then there's possible...
How about this:
The BEST solution would be to insert the [valid/clean] data into a
database, and run a cron job to send off everything to the Web
Service.
You'll have to mark what's sent and what isn't and be careful not to
run two jobs at once when it's really slow (sending duplicate data)
nor to "skip" data that didn't safely get sent.
But should do all that anyway in your script.
There might even be functions in the Web Service to make it easy for
you to send a whole BUNCH of records at once, saving a lot of time on
your end.
And, for sure, if all your script has to do is insert to a database
table for step 3, it's gonna be pretty fast.
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Wed, April 19, 2006 9:58 am, bruce wrote:
> i'm looking for opinions on the "worth" of programming contests as a
> way of
> judging the talent of potential software developers...
>
> any thoughts/pros/cons would be appreciated..
>
> and yeah.. i know this is a little off topic.. but some of us here
> deal with
> these issues.. if you know of a better email list for this kind of
> question,
> let me know, and i'll move it to there..
Seems to me the BEST candidates will be much too busy working to play
around with the contest...
Even assuming you only want currently-unemployed with nothing better
to do people, I doubt that the contest will really exercise nearly
enough of their skillset to be of much value.
A strong portfolio and years of experience are better indicators.
Not to mention that the code might "win" the contest, but does that
make it good code? Guess you can write the rules any way you want to
cover that, but so what? Does being able to code once to your "rules"
mean my code is always that neat and clean?
Seems to me you'd be better off winnowing down the candidate pool
first, then hiring the best on a trial basis for a few weeks/months.
If it doesn't work out, start calling down the list of second best and
so on and give them a trial run.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Wed, April 19, 2006 3:17 am, James Nunnerley wrote:
> Thanks for everyone's replies - but I'm a little uncertain as to what
> the
> reasons for not running the pcntl functions under the web browser are
> - is
> it down to security?
I could be wrong, but I believe the correct response is:
No, it's down to various threads tromping all over each other
corrupting RAM and crashing your machine in about 5 seconds under any
kind of load.
Other than that, though, you're all set. :-)
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
$image_file = 'foo.jpg';
$random = mt_rand(1, 2000000000);
$url = "http://example.com/program/$random/$image_file";
echo "<img src=\"$url\">
In program, if you echo out $_SERVER['PATHINFO'] you will see:
/454398574395/foo.jpg
The number will change, of course.
You can tear that apart and get the foo.jpg part to do whatever you want.
Or, you could have the URL sometimes have 'copyright' in it, and
sometimes not, and merge only when the URL has copyright in it.
You could even pass is paraeters like this:
http://example.com/program/width=200/2343242343/foo.jpg
Take the width=200 and scale the image to be 200 pixels wide.
Here is a real live example where I do this:
http://uncommonground.com/artist_profile/Ellen+Rosner
Right-click on that image of Ellen in the chair and check out that URL.
thumbnail is my PHP script.
target is a max width/height (I scale it proporationally and 200 is
max for both)
credits is the photographer credits from my database.
The rest is the URL of the actual real image I'm dinking with.
Feel free to play with the URL and change the 200 to, say, 100, or
make believe YOU took that photograph.
All just from the URL which, as far as the browser can tell, is a
perfectly valid set of directory paths on my machine, so the browser
can't possibly screw up. (Rule #1: Never trust the browser.)
And in the main link, artist_profile is the PHP script, and if you
look at the links to the other artists at the bottom of the page,
you'll see that it also uses PATH_INFO to either show an artist by ID
or to search for their name in our database.
If multiple matches are found, the user is asked which one they meant:
http://uncommonground.com/artist_profile/Ellen
If I have the ID, then I know exactly which one to display.
I actually would suggest you go with:
/width=200/ though, instead of /width/200/ as it's easier to code and
have optional parameters using = and / as an arg separator.
I haven't bothered to fix that old script, but that's how I do it
nowadays.
On Wed, April 19, 2006 8:19 am, tedd wrote:
>>You're also better off embedding the parameters in the URL so that it
>>"looks like" a directory to the browser:
>>
>>http://example.com/actual_script/57823642346963/copyright/whatever.png
>>
>>The PHP scritp is actual_script.
>>
>>You can use .htaccess and ForceType to make Apache run it.
>>
>>$_SERVER['PATH_INFO'] will have all the parameters you need.
>>
>>The embedded parameters pretty much give the browser NO opportunity
>> to
>>screw up.
>
>
>
> Richard:
>
> Far out ! -- I never saw .htaccess and ForceType used before. But it
> works slick in dropping the extension of "program.php" to "program".
> (Now if I can only get my editor to still treat the document as php,
> but that's a different matter).
>
> However, I don't see how I can generate a random number for a url
> each time an image is needed and have .htaccess and ForceType make
> Apache run it -- do I rewrite. htaccess each time, or what?
>
> Also, $_SERVER['PATH_INFO'] (or in my case
> $_SERVER['PATH_TRANSLATED'] ) gives me the path -- so how does that
> fit in?
>
> Please explain.
>
> Thanks.
>
> tedd
>
> --
> --------------------------------------------------------------------------------
> http://sperling.com
>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Hello Everyone!
What would be the best way to start a PHP Script via CRONJOB?
Should i use the 'php' command or use curl or lynx or something to
open that URL?
The Script does a MySQL query, collects data and sends it via E-Mail
every monday morning to the recipient.
Any help will be appriciated :)
Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
Barry a écrit :
Hello Everyone!
What would be the best way to start a PHP Script via CRONJOB?
Should i use the 'php' command or use curl or lynx or something to
open that URL?
Hi,
unless you need to be sure the http server is up and running, it's a
better way to run your script via a cronjob.
N F
The Script does a MySQL query, collects data and sends it via E-Mail
every monday morning to the recipient.
Any help will be appriciated :)
Barry
--- End Message ---
--- Begin Message ---
I run several PHP scripts via CRON in the following way:
put the following in the top of the php script:
#!/usr/local/bin/php -q (linux system - location of php bin)
and in the CRONTAB I have the following:
10 1 * * * root /usr/local/bin/php -q /script/CRONexport.php
the -q supress HTML headers.
hope this helps!
Pure Web Solution
http://www.purewebsolution.co.uk
PHP, MYSQL, Web Design & Web Services
Barry <[EMAIL PROTECTED]> wrote:
> Hello Everyone!
>
> What would be the best way to start a PHP Script via CRONJOB?
> Should i use the 'php' command or use curl or lynx or something to
> open that URL?
>
> The Script does a MySQL query, collects data and sends it via E-Mail
> every monday morning to the recipient.
>
> Any help will be appriciated :)
>
> Barry
--- End Message ---
--- Begin Message ---
Pure Web Solution wrote:
I run several PHP scripts via CRON in the following way:
put the following in the top of the php script:
#!/usr/local/bin/php -q (linux system - location of php bin)
and in the CRONTAB I have the following:
10 1 * * * root /usr/local/bin/php -q /script/CRONexport.php
the -q supress HTML headers.
hope this helps!
Yes it does. Thanks :)
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--- End Message ---
--- Begin Message ---
Hello,
How to post an array with associated values?
This works ok
<?php
$arr_siirto = array(1,2,3);
print_r($arr_siirto);
$arse = $arr_siirto;
print_r($arse);
?>
But if I post it to another form with this:
<input type="hidden" name="arr_siirt_jouk" value="<?php echo "$arse";?>">
And print there with:
print_r($arr_siirt_jouk);
prints: Array
So how can post the values forward?
Thanks
-Will
--- End Message ---