php-general Digest 8 Dec 2008 10:23:15 -0000 Issue 5833
Topics (messages 284291 through 284308):
Re: A MySQL Question
284291 by: Chris
284293 by: German Geek
284294 by: Ashley Sheridan
284295 by: Chris
284296 by: German Geek
284297 by: Chris
284298 by: German Geek
284299 by: Chris
284300 by: German Geek
284301 by: Chris
284302 by: German Geek
284303 by: Chris
284304 by: German Geek
Re: Parsing Strings
284292 by: German Geek
Re: Poll of sorts: Javascript Form validation or PHP
284305 by: Per Jessen
284306 by: Per Jessen
Re: Refresh (F5) adds another SQL record.
284307 by: Bhupendra Patel
Re: Downloading file from local network machine
284308 by: Mayer, Jonathan
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 ---
tedd wrote:
Hi gang:
I just interviewed for a job teaching at the local college (imagine me
taking minds of mush and molding them to the world according to tedd --
frightening huh?)
In any event, the interviewer asked me how long I've been using MySQL
and I replied several years. After which she asked a single question,
which was "What does EXIST mean?"
There is no 'Exist' keyword in sql, it's 'EXISTS'. Everyone seems to
know the "drop table if exists" syntax but that's not the right one they
are after (and it's non-standard sql).
There is an 'Exists' keyword for subselects. Instead of doing an IN
query, you can do an 'exists' query - but it's use is very different.
It returns true if any row in the subquery exists or false if none
exist. The idea is instead of:
select * from accounts where company_id in (select company_id from
companies where name='X');
you do
select * from company where company_id exists (select company_id from
companies where name='X');
the subselect checks the company table for the id, if it exists, the
outer query runs. It does not matter what company_id is returned from
the subquery, just that at least 1 does return.
I've never used this anywhere myself because I usually care what id's
are returned from the subquery.
(Yes, that's from the top of my head :P but here's doc's to help).
http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html
http://www.postgresql.org/docs/8.3/static/functions-subquery.html
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
EXIST? Yeah I certainly have seen it before in the result of a mysqldump,
but from the top of my head, I probably wouldn't have known in exactly what
context it is used. I've used MySQL for 5 years now and i think if you ask
such a question, you don't know what you should be asking because the
context of EXIST is hardly ever needed, and if, if you know where to look
for it, that's more important than being able to reproduce it in from the
top of your head. It's like asking: "Do you know the syntax for ..." where
... is a rarely used function in PHP or any other language. It's like
requiring your employees to know every function of a language...
On Mon, Dec 8, 2008 at 4:03 AM, tedd <[EMAIL PROTECTED]> wrote:
> Hi gang:
>
> I just interviewed for a job teaching at the local college (imagine me
> taking minds of mush and molding them to the world according to tedd --
> frightening huh?)
>
> In any event, the interviewer asked me how long I've been using MySQL and I
> replied several years. After which she asked a single question, which was
> "What does EXIST mean?"
>
> Now without running to the manuals, please be honest and tell me how many
> of you know off the top of your head what EXIST means? I would be curious to
> know.
>
> I answered the question correctly, (I'm one of those weird types who read
> manuals for fun) but I have never used EXIST in a query. Have any of you?
>
> And while we're on the subject of MySQL -- while we all know how to write
> it, how do you say it?
>
> I've read that the common way is to say "My Squell", or something like
> that. But I always sounded out each letter, such as "My S-Q-L". The
> interviewer pronounced it the same as I, but I have heard others say it
> differently.
>
> What say you?
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
On Mon, 2008-12-08 at 12:33 +1300, German Geek wrote:
> EXIST? Yeah I certainly have seen it before in the result of a mysqldump,
> but from the top of my head, I probably wouldn't have known in exactly what
> context it is used. I've used MySQL for 5 years now and i think if you ask
> such a question, you don't know what you should be asking because the
> context of EXIST is hardly ever needed, and if, if you know where to look
> for it, that's more important than being able to reproduce it in from the
> top of your head. It's like asking: "Do you know the syntax for ..." where
> ... is a rarely used function in PHP or any other language. It's like
> requiring your employees to know every function of a language...
>
> On Mon, Dec 8, 2008 at 4:03 AM, tedd <[EMAIL PROTECTED]> wrote:
>
> > Hi gang:
> >
> > I just interviewed for a job teaching at the local college (imagine me
> > taking minds of mush and molding them to the world according to tedd --
> > frightening huh?)
> >
> > In any event, the interviewer asked me how long I've been using MySQL and I
> > replied several years. After which she asked a single question, which was
> > "What does EXIST mean?"
> >
> > Now without running to the manuals, please be honest and tell me how many
> > of you know off the top of your head what EXIST means? I would be curious to
> > know.
> >
> > I answered the question correctly, (I'm one of those weird types who read
> > manuals for fun) but I have never used EXIST in a query. Have any of you?
> >
> > And while we're on the subject of MySQL -- while we all know how to write
> > it, how do you say it?
> >
> > I've read that the common way is to say "My Squell", or something like
> > that. But I always sounded out each letter, such as "My S-Q-L". The
> > interviewer pronounced it the same as I, but I have heard others say it
> > differently.
> >
> > What say you?
> >
> > Cheers,
> >
> > tedd
> >
> > --
> > -------
> > http://sperling.com http://ancientstones.com http://earthstones.com
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
Better questions really ought to be along the lines of "how would you
tackle this problem?" and then accept a variety of answers back, or some
debugging on erroneous code. Unfortunately, these tests all too often
feature questions on those obscure functions that are rarely used.
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
German Geek wrote:
EXIST? Yeah I certainly have seen it before in the result of a mysqldump,
but from the top of my head, I probably wouldn't have known in exactly what
context it is used. I've used MySQL for 5 years now and i think if you ask
such a question, you don't know what you should be asking because the
context of EXIST is hardly ever needed, and if, if you know where to look
for it, that's more important than being able to reproduce it in from the
top of your head. It's like asking: "Do you know the syntax for ..." where
... is a rarely used function in PHP or any other language. It's like
requiring your employees to know every function of a language...
You're making an assumption about the situation. What if it was for a
dba job or teaching advanced sql?
And 'exists' is not for mysqldump.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 2:59 PM, Chris <[EMAIL PROTECTED]> wrote:
> German Geek wrote:
>
>> EXIST? Yeah I certainly have seen it before in the result of a mysqldump,
>> but from the top of my head, I probably wouldn't have known in exactly
>> what
>> context it is used. I've used MySQL for 5 years now and i think if you ask
>> such a question, you don't know what you should be asking because the
>> context of EXIST is hardly ever needed, and if, if you know where to look
>> for it, that's more important than being able to reproduce it in from the
>> top of your head. It's like asking: "Do you know the syntax for ..." where
>> ... is a rarely used function in PHP or any other language. It's like
>> requiring your employees to know every function of a language...
>>
>
> You're making an assumption about the situation. What if it was for a dba
> job or teaching advanced sql?
>
> And 'exists' is not for mysqldump.
DROP TABLE IF EXISTS `mytable`;
I said, I've seen EXIST in a result of a mysqldump before, which is not
wrong is it? Unless I'm hallucinating... Or is EXISTS something completely
different?
And even a DBA or teacher doesn't need to know every part of syntax in
MySQL. It's more important that they know the concepts...
Anyway, I think this is all off-topic in a PHP mailing list...
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
And 'exists' is not for mysqldump.
DROP TABLE IF EXISTS `mytable`;
"if exists" can be used in lots of places other than "drop table", like
triggers, functions and i'm sure other things.
I said, I've seen EXIST in a result of a mysqldump before, which is not
wrong is it? Unless I'm hallucinating... Or is EXISTS something
completely different?
Yes it is completely different.
http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 3:24 PM, Chris <[EMAIL PROTECTED]> wrote:
>
> And 'exists' is not for mysqldump.
>>
>>
>> DROP TABLE IF EXISTS `mytable`;
>>
>
> "if exists" can be used in lots of places other than "drop table", like
> triggers, functions and i'm sure other things.
>
> I said, I've seen EXIST in a result of a mysqldump before, which is not
>> wrong is it? Unless I'm hallucinating... Or is EXISTS something completely
>> different?
>>
>
> Yes it is completely different.
Sorry, I couldnt find EXIST there, only EXISTS.
>
>
>
> http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
German Geek wrote:
On Mon, Dec 8, 2008 at 3:24 PM, Chris <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
And 'exists' is not for mysqldump.
DROP TABLE IF EXISTS `mytable`;
"if exists" can be used in lots of places other than "drop table",
like triggers, functions and i'm sure other things.
I said, I've seen EXIST in a result of a mysqldump before, which
is not wrong is it? Unless I'm hallucinating... Or is EXISTS
something completely different?
Yes it is completely different.
Sorry, I couldnt find EXIST there, only EXISTS.
If you're going to be that pedantic, "exist" isn't in mysqldump either :P
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 5:06 PM, Chris <[EMAIL PROTECTED]> wrote:
> German Geek wrote:
>
>>
>>
>> On Mon, Dec 8, 2008 at 3:24 PM, Chris <[EMAIL PROTECTED] <mailto:
>> [EMAIL PROTECTED]>> wrote:
>>
>>
>> And 'exists' is not for mysqldump.
>>
>>
>> DROP TABLE IF EXISTS `mytable`;
>>
>>
>> "if exists" can be used in lots of places other than "drop table",
>> like triggers, functions and i'm sure other things.
>>
>>
>> I said, I've seen EXIST in a result of a mysqldump before, which
>> is not wrong is it? Unless I'm hallucinating... Or is EXISTS
>> something completely different?
>>
>>
>> Yes it is completely different.
>>
>> Sorry, I couldnt find EXIST there, only EXISTS.
>>
>
> If you're going to be that pedantic, "exist" isn't in mysqldump either :P
>
I know it's pedantic, but unfortunately computers are strictly pedantic and
I wasn't sure why you said
"if exists" can be used in lots of places other than "drop table",
like triggers, functions and i'm sure other things."
I was just stating that I saw it in a dump and I never really used it, so
assume(d), it's not very important because you can do the same thing with IN
etc and other conditions, can't u?
Anyway, this discussion is getting rediculous. Let's move on. Didn't mean to
offend anyone here. Don't worry about answering the last question if you
also think it's irrelevant...
All good. :)
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
Sorry, I couldnt find EXIST there, only EXISTS.
If you're going to be that pedantic, "exist" isn't in mysqldump
either :P
I know it's pedantic, but unfortunately computers are strictly pedantic
and I wasn't sure why you said
"if exists" can be used in lots of places other than "drop table",
like triggers, functions and i'm sure other things."
I was just stating that I saw it in a dump and I never really used it,
so assume(d), it's not very important because you can do the same thing
with IN etc and other conditions, can't u?
They are completely different things you're mixing up here.
"IF EXISTS" with "DROP TABLE" means "if the table does not exist, do not
give an error".
Same for "drop view", "drop trigger". If the view/table/trigger/function
does not exist, do not give an error.
"EXISTS" in a select query is a subquery - same as using "IN".
Completely different.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 5:50 PM, Chris <[EMAIL PROTECTED]> wrote:
>
> Sorry, I couldnt find EXIST there, only EXISTS.
>>
>>
>> If you're going to be that pedantic, "exist" isn't in mysqldump
>> either :P
>>
>> I know it's pedantic, but unfortunately computers are strictly pedantic
>> and I wasn't sure why you said "if exists" can be used in lots of places
>> other than "drop table",
>> like triggers, functions and i'm sure other things."
>> I was just stating that I saw it in a dump and I never really used it, so
>> assume(d), it's not very important because you can do the same thing with IN
>> etc and other conditions, can't u?
>>
>
> They are completely different things you're mixing up here.
>
> "IF EXISTS" with "DROP TABLE" means "if the table does not exist, do not
> give an error".
I do understand that it's a bit different here.
>
>
> Same for "drop view", "drop trigger". If the view/table/trigger/function
> does not exist, do not give an error.
>
> "EXISTS" in a select query is a subquery - same as using "IN".
>
> Completely different.
>
Right....
So, how are these different:
SELECT * FROM t1 WHERE id EXISTS (SELECT id FROM t2)
to
SELECT * FROM t1 WHERE id IN (SELECT id FROM t2)
??
According to my understanding of the documentation, these would have the
same result. Can't think of any sub query that could not have an equivalent
statement with IN (NOT IN).
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
Right....
So, how are these different:
SELECT * FROM t1 WHERE id EXISTS (SELECT id FROM t2)
If there are *any* results for the subselect, the exists returns true.
It's the equivalent of:
select * from t1 where id is true;
ie
select * from t1;
If there are no results for the subselect, the exists returns false, ie:
select * from t1 where false;
which will return nothing.
to
SELECT * FROM t1 WHERE id IN (SELECT id FROM t2)
this returns specific id's that match.
According to my understanding of the documentation, these would have the
same result.
No, they aren't.
create table t1(id int, name varchar(5));
insert into t1(id, name) values (1, 'one');
insert into t1(id, name) values (2, 'two');
insert into t1(id, name) values (3, 'three');
insert into t1(id, name) values (4, 'four');
insert into t1(id, name) values (5, 'five');
create table t2(id int, other_name varchar(5));
insert into t2(id, other_name) values (1, 'one');
insert into t2(id, other_name) values (2, 'two');
this returns everything from t1:
SELECT * FROM t1 WHERE EXISTS (SELECT id FROM t2);
this returns 2 rows that match:
SELECT * FROM t1 WHERE id IN (SELECT id FROM t2);
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 7:06 PM, Chris <[EMAIL PROTECTED]> wrote:
>
> Right....
>>
>> So, how are these different:
>>
>> SELECT * FROM t1 WHERE id EXISTS (SELECT id FROM t2)
>>
>
> If there are *any* results for the subselect, the exists returns true.
>
> It's the equivalent of:
>
> select * from t1 where id is true;
>
> ie
>
> select * from t1;
>
> If there are no results for the subselect, the exists returns false, ie:
>
> select * from t1 where false;
>
> which will return nothing.
>
> to
>> SELECT * FROM t1 WHERE id IN (SELECT id FROM t2)
>>
>
> this returns specific id's that match.
>
> According to my understanding of the documentation, these would have the
>> same result.
>>
>
> No, they aren't.
>
> create table t1(id int, name varchar(5));
>
> insert into t1(id, name) values (1, 'one');
> insert into t1(id, name) values (2, 'two');
> insert into t1(id, name) values (3, 'three');
> insert into t1(id, name) values (4, 'four');
> insert into t1(id, name) values (5, 'five');
>
> create table t2(id int, other_name varchar(5));
>
> insert into t2(id, other_name) values (1, 'one');
> insert into t2(id, other_name) values (2, 'two');
>
> this returns everything from t1:
> SELECT * FROM t1 WHERE EXISTS (SELECT id FROM t2);
>
> this returns 2 rows that match:
> SELECT * FROM t1 WHERE id IN (SELECT id FROM t2);
Oh OK. Thanks for clearing that up.
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
Why not preg_split ( http://nz.php.net/manual/en/function.preg-split.php ):
$str = 'SCOTTSDALE, AZ 85254';
$ar = preg_split('/,? ?/', $str); //optional comma, followed by optional
space
// $ar = array('SCOTTSDALE', 'AZ', '85254');
On Sat, Dec 6, 2008 at 1:18 PM, Jason Todd Slack-Moehrle <
[EMAIL PROTECTED]> wrote:
>
> How might I also parse and address like: SCOTTSDALE, AZ 85254
>
> It has a comma and a space
>
> -Jason
>
>
> On Dec 5, 2008, at 4:02 PM, Jason Todd Slack-Moehrle wrote:
>
> OK, making good learning progress today.
>>
>> I have a string that is: Jason Slack
>>
>> and I want it broken at the space so i get Jason and then Slack
>>
>> I am looking at parse_str, but I dont get how to do it with a space. The
>> example is using []=.
>>
>> Then I want to assign like:
>>
>> $fname = "Jason";
>> $lname = "Slack";
>>
>> Any ideas?
>>
>> -Jason
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
tedd wrote:
> At 5:10 PM +0100 12/7/08, Per Jessen wrote:
>> You cannot have 8bit characters to the left of the @ in the email
>> address.
>
>
> I'm not sure that's correct.
I am sure. In fact, the entire email header must not contain any 8-bit
characters. I.e. it _can_, but it is a violation of the standard, and
particularly in the email address it will cause problems, whereas it
will most probably work in the Subject:.
> I distinctly remember Paul Hoffman, the director of the Internet Mail
> Consortium (http://www.imc.org/) saying that the left side of the @
> has always been open to whatever characters you want to use.
I don't know him nor the IMC, but RFC2821 is fairly clear (as clear RFCs
can be) on the matter. Still, I think this W3 webpage says it very
clearly:
http://www.w3.org/Mail/unencoded-8bits.html
"W3C's mail servers are configured to reject messages with unencoded
8bit characters in the message email headers.".
> The "xn--" is the prefix for PUNYCODE. Previous
> algorithms (AMC, RACE, etc.) used other prefixes.
>
> After all is said and done, these were just ways to use 7 bit
> characters (unfortunately, the default for the Internet) to
> assemble/represent 8 bit characters.
Absolutely.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
tedd wrote:
> The php routine also passed [EMAIL PROTECTED], which is real -- but
> it's interesting that most email (if not all) programs cannot show
> the domain name correctly, which is [EMAIL PROTECTED] I have yet to find an
> email program that can show IDNS correctly.
Tedd, I've got a distinct feeling of deja-vu here, but Thunderbird
displays all Swiss, German, French, Greek and Danish IDNs 100%
correctly, probably many more too.
The ones you're having a problem with are the ones that allow the entire
UTF8 charset, IIRC.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
If the user hits the back button and then the forward, it sometimes
resubmits the form.
This is why i initiated the session and ended it at the end of the data
processing page. If they happen to press forward, or back, it will still not
initiate the form unless they have actually visitied and submitted the form.
2008/12/7 Ashley Sheridan <[EMAIL PROTECTED]>
> On Sun, 2008-12-07 at 16:44 +0000, Bhupendra Patel wrote:
> > I've found a way that works for me.
> >
> > Using the START SESSION on the initial form, e.g.
> > <?php
> > session_start();
> > // store session data
> > $_SESSION['form'] = "1";
> > ?>
> >
> > and the using the code below in the processing form.
> >
> > You can do a check if the user has already submitted the from by the
> initial
> > session that starts then he/she is on the submitting form. If it is
> already
> > set it can continue, else stop and redirect.
> > MAKE SURE to put the unset session at the end of the form.
> >
> > <html>
> > <head>
> > <title>Add Publication</title>
> > </head>
> > <body>
> > <h1>Add</h1>
> > <?php
> > // Check session
> > session_start();
> > if ($_SESSION['form'] == 1)
> > {
> > // create short variable names
> > $producttype=$_POST['producttype'];
> > $producttitle=$_POST['producttitle'];
> > $productdescription=$_POST['productdescription'];
> > $productauthor=$_POST['productauthor'];
> > $productlang=$_POST['productlang'];
> > $productprice=$_POST['productprice'];
> > $productstatus=$_POST['productstatus'];
> > $productimg=$_POST['productimg'];
> > }
> > else
> > {
> > echo 'Go back and complete the form';
> > echo header('Location: insertpublication.php');
> > exit;
> > }
> > // End session checking
> >
> > if (!$producttype || !$producttitle || !$productauthor || !$productlang
> ||
> > !$productprice || !$productstatus)
> > {
> > echo 'You have not entered all the required details.<br />'
> > .'Please go back and try again.';
> > unset($_SESSION['form']);
> > exit;
> > }
> >
> > @ $prodb = new mysqli('I DONT THINK SO!!!');
> > if (mysqli_connect_errno())
> > {
> > echo 'Error: Could not connect to database. Please try again
> later.';
> > exit;
> > }
> > $query = "INSERT into tblproductinfo
> > (ProductType, ProductTitle, ProductDesc, ProdAuthor,
> > ProductLang, ProductPrice, ProductStatus, ProductImg)
> > VALUES
> > ('".$producttype."', '".$producttitle."',
> > '".$productdescription."', '".$productauthor."', '".$productlang."',
> > '".$productprice."', '".$productstatus."',
> '".$productimg."')";
> >
> > $result = $prodb->query($query);
> > if ($result)
> > echo $prodb->affected_rows.' book inserted into database.';
> >
> > $queryshow = "
> > SELECT
> > tblproductinfo.ProductID,
> > tblproductinfo.ProductTitle,
> > tblproductinfo.ProductDesc,
> > tblproductinfo.ProductPrice,
> > tblproductinfo.ProductTQty,
> > tblproductinfo.ProductImg,
> > tblauthor.AuthorName,
> > tblproductlang.ProductLang,
> > tblproducttype.ProductType,
> > tblproductstatus.ProductStatus
> > FROM
> > tblproductinfo
> > Inner Join tblproductstatus ON tblproductinfo.ProductStatus =
> > tblproductstatus.ProductStatusID
> > Inner Join tblproductlang ON tblproductinfo.ProductLang =
> > tblproductlang.ProductLangID
> > Inner Join tblauthor ON tblproductinfo.ProdAuthor =
> tblauthor.AuthorID
> > Inner Join tblproducttype ON tblproductinfo.ProductType =
> > tblproducttype.ProductTypeID";
> > $resultshow = $prodb->query($queryshow);
> >
> > $num_results = $resultshow->num_rows;
> > echo '
> > <table width="700" border="1">
> > <tr>
> > <td>
> > Book ID
> > </td>
> > <td>
> > Type
> > </td>
> > <td>
> > Title
> > </td>
> > <td>
> > Description
> > </td>
> > <td>
> > Author
> > </td>
> > <td>
> > Language
> > </td>
> > <td>
> > Price
> > </td>
> > <td>
> > Status
> > </td>
> > <td>
> > Image
> > </td>
> > </tr>';
> > for ($i=0; $i <$num_results; $i++)
> > {
> > $row = $resultshow->fetch_assoc();
> > echo '<tr>';
> > echo '<td>'.($row['ProductID']).'</td>';
> > echo '<td>'.($row['ProductType']).'</td>';
> > echo '<td>'.($row['ProductTitle']).'</td>';
> > echo '<td>'.($row['ProductDesc']).'</td>';
> > echo '<td>'.($row['AuthorName']).'</td>';
> > echo '<td>'.($row['ProductLang']).'</td>';
> > echo '<td>£'.($row['ProductPrice']).'</td>';
> > echo '<td>'.($row['ProductStatus']).'</td>';
> > echo '<td><a href=images/'.($row['ProductImg']).'>Preview image
> > </a></td>';
> > echo '</tr>';
> > };
> > echo '</table>';
> >
> > unset($_SESSION['form']);
> >
> > $prodb->close();
> > ?>
> > </body>
> > </html>
> Would redirecting the user with a header() request do the job? Or,
> failing that, how about outputting a
> <script>location.href='foo.com'</script> line?
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
--- End Message ---
--- Begin Message ---
Cheers Ash et al... got it working now using fileread(), based on the
example on php.net. I have it in a separate download.php file which
takes a variety of inputs and spews out a file download.
Many thanks all.
-----Original Message-----
From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
Sent: 05 December 2008 20:23
To: Mayer, Jonathan
Cc: Wolf; [EMAIL PROTECTED]
Subject: RE: [PHP] Downloading file from local network machine
On Fri, 2008-12-05 at 17:32 +0000, Mayer, Jonathan wrote:
> Thanks Wolf :)
>
> Yup, I had considered that, although there could be up to 8 different
servers so that's 8 seperately mapped drives.
>
> If that's the simplest/neatest way, I'll do that, although I did
wonder whether there was some other clever another way around it.
>
> -----Original Message-----
> From: Wolf [mailto:[EMAIL PROTECTED]
> Sent: 05 December 2008 17:29
> To: Mayer, Jonathan; [EMAIL PROTECTED]
> Subject: Re: [PHP] Downloading file from local network machine
>
> <!-- SNIP -->
> > I would like to present users to our internal intranet with a link
to
> > download a file from a folder on a different machine on our local
> > network (such as \\computername\folder\file)
> <!-- SNIP -->
>
> Map the drive to the server so that it is accessible as /folder/file
on the website.
>
> Voila, no more problem.
>
> HTH,
> Wolf
>
>
I don't have the code to hand right now, but I can try and post it
later. You were on the right track with fread() et al. Basically, set
the correct headers for a download (application/octet-stream I believe)
and print out the results of the fread(). Don't forget the binary flag
on fread() if you are opening binary files, and it should create a file
that auto-downloads. There are extra headers to set the default filename
of the download, but I forget these at the moment. A Google should give
you what you need though. This way, the file can even be delivered to
someone outside of your network should you wish, without you needing to
put the file in a web-accessible directory.
Ash
www.ashleysheridan.co.uk
--- End Message ---