php-general Digest 14 Aug 2010 06:08:38 -0000 Issue 6892
Topics (messages 307435 through 307460):
Setting up a 2 Column Display for SQL Recordset
307435 by: DealTek
307438 by: chris h
Resource logging PHP extension
307436 by: Bostjan Skufca
Re: Cake
307437 by: Philip Thompson
[ENCODING QUEUE] - anyone think of a good way to setup a queuing system so
everyone gets their turn
307439 by: Tristan
307440 by: Ashley Sheridan
307441 by: Tristan
307442 by: Ashley Sheridan
307459 by: Tristan
It's Friday (a MySQL Question)
307443 by: tedd
307444 by: Ashley Sheridan
307445 by: Daniel P. Brown
307446 by: Daevid Vincent
307447 by: Daniel P. Brown
307448 by: Ashley Sheridan
307450 by: Daniel P. Brown
307451 by: Ashley Sheridan
307452 by: Daevid Vincent
307453 by: tedd
307454 by: chris h
307456 by: Simon J Welsh
login to protected directory by php
307449 by: Ali Asghar Toraby Parizy
307455 by: chris h
Updating Multiple rows in mysql w php at once (newbie)
307457 by: DealTek
307458 by: chris h
PHP Reference
307460 by: Karl DeSaulniers
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 ---
newbie question:
Hi Folks,
I have a php / sql data recordset that has 200 names that I want to display in
a 2 column display ( down on left then down on right side - not left right -
left right).
So I can create a 2 column table. Then I need to split the data result in 2
parts - so part 1 (1-100 records) is on the left column and part 2 (101 - 200
records) is on the right column.
Q: I'm not quite sure how to split / display the records ... Is there some kind
of internal sql rec number that I can monitor? What is the best way to set this
up?
--
Thanks,
Dave - DealTek
[email protected]
[db-10]
--- End Message ---
--- Begin Message ---
Dave I would look into something like the array_slice function.
http://us3.php.net/manual/en/function.array-slice.php
With this function you could create two arrays - one for the left column,
and one for the right column - and iterate through them simultaneously.
i.e. untested: given $allNames is an array with all 200 names....
------
$firstNameSet = array_slice($allNames, 0, 100);
$secondNameSet = array_slice($allNames, 100);
foreach ($firstNameSet as $key => $nameA) {
$nameB = $secondNameSet[$key];
...
...
}
-----
Alternatively you can use a nested query to pull the results in two sets
directly from the sql db.
Hope that helps
Chris.
On Fri, Aug 13, 2010 at 12:51 PM, DealTek <[email protected]> wrote:
> newbie question:
>
> Hi Folks,
>
> I have a php / sql data recordset that has 200 names that I want to display
> in a 2 column display ( down on left then down on right side - not left
> right - left right).
>
> So I can create a 2 column table. Then I need to split the data result in 2
> parts - so part 1 (1-100 records) is on the left column and part 2 (101 -
> 200 records) is on the right column.
>
> Q: I'm not quite sure how to split / display the records ... Is there some
> kind of internal sql rec number that I can monitor? What is the best way to
> set this up?
>
>
>
> --
> Thanks,
> Dave - DealTek
> [email protected]
> [db-10]
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hi all!
I just wanted you to know that I've created an extension which does resource
logging for each pageload. Works with 5.2.14 and 5.3.3 versions of PHP,
tested with Apache and CLI sapis.
It logs PHP memory consumption, real time spent, cpu time spent (user and
sys, in jiffies), page faults etc etc.
Logging is done through syslog, example output is here:
------------------------------------------------------------------
Aug 13 18:25:50 sizif php-rsclog[27108]: file:/var/www/
www.DOMAIN.com/public/index.php memory:15990784b realTime:3321548us
utime:299j stime:13j majflt:0 minflt:4753 cutime:0j csutime:0j cmajflt:0
cminflt:0 request_uri=/index.php query_string=
------------------------------------------------------------------
Download URI:
http://rsclog.sourceforge.net/
WARNING: Extension is currently considered to be of RC quality! But it works
for me very well:)
Have fun!
b.
--- End Message ---
--- Begin Message ---
On Aug 13, 2010, at 10:49 AM, Philip Thompson wrote:
> Hi all.
>
> Having an issue with some CakePHP 1.3 stuff. I've read and read and read and
> haven't found my solution. I'm fairly new to Cake, so be nice. I'm trying to
> access a method from a different controller than the one I'm in and it's not
> letting me.
>
> -location.php (model) - create the relationship
> public $belongsTo = 'Address';
>
> -locations_controller.php - grab all the locations (+ addresses for each
> location) and format the addresses
> $locations = $this->Location->find('all');
> ...
> $this->Location->Address->format(...); // This line throws the error
> ...
>
> -addresses_controller.php
> public function format (...) { ... }
>
> From my understanding, everything is defined correctly, but it thinks that
> I'm calling a query when it errors:
>
> Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check
> the manual that corresponds to your MySQL server version for the right syntax
> to use near 'format' at line 1
> [CORE/cake/libs/model/datasources/dbo_source.php, line 681]
>
> It thinks that the method "format()" is a query. Why?! I just want it to call
> that method. Please help!
>
> Thanks in advance,
> ~Philip
I'm sure this is a rookie mistake, but I figured it out. I was putting the
format() method in the addresses_controller file when I should have been
putting it into the address model file. Upon putting it there, it worked as
expected!
Thanks!
~Philip
--- End Message ---
--- Begin Message ---
i have a list of people that uploaded their videos waiting to be encoded.
these are the line items for the db
id | member_id | created | status
I just want to make sure that everyone gets a turn processing.
I was thinking WHERE DISTINCT(member_id) and created (oldest)
but i see some flaw in that.
if someone uploaded 20 vids and then someone else uploads 30 vids they'll
still have to wait until the 20 finish.
Almost have to keep a list of the users being processed in another table and
if someone else comes along append them in.
say we have 5 people that uploaded multiple videos. I want it to go like
sandy, tom, jim, harry, star
and then back to
sandy, tom, jim, harry, star
then if someone else comes into the mix. add them to that queue
Thanks, T
--- End Message ---
--- Begin Message ---
On Fri, 2010-08-13 at 14:48 -0600, Tristan wrote:
> i have a list of people that uploaded their videos waiting to be encoded.
>
> these are the line items for the db
>
> id | member_id | created | status
>
> I just want to make sure that everyone gets a turn processing.
>
> I was thinking WHERE DISTINCT(member_id) and created (oldest)
>
> but i see some flaw in that.
>
>
> if someone uploaded 20 vids and then someone else uploads 30 vids they'll
> still have to wait until the 20 finish.
>
> Almost have to keep a list of the users being processed in another table and
> if someone else comes along append them in.
>
> say we have 5 people that uploaded multiple videos. I want it to go like
>
> sandy, tom, jim, harry, star
>
> and then back to
>
> sandy, tom, jim, harry, star
>
> then if someone else comes into the mix. add them to that queue
>
> Thanks, T
You can probably do it with the one video list in the DB. Each time your
video encoder has a free spot it should obtain a list of videos from
this table from the last time period, both processed and waiting to be
queued. Look up the first one from this list and check to see if a video
for the same user has been processed within a specific time period. If
yes, then move to the next video in the list and check that in the same
manner, and repeat until you find one. If you don't find any, then you
can just pick any video from the list.
You should be able to process several videos at the same time on a
decent server, and a 64-bit system should make mincemeat of an encode as
it should do that type of number crunching more quickly.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Here's a question for you about encoding on the server. If two videos are
encoding at the same time. Do they share the processing power.
lets say we have 2 vids same size
1 encodes at 1 minute
and then if 2 are going at the same time does it encode them both in 2
minutes?
Thanks, T
On Fri, Aug 13, 2010 at 3:08 PM, Ashley Sheridan
<[email protected]>wrote:
> On Fri, 2010-08-13 at 14:48 -0600, Tristan wrote:
>
> i have a list of people that uploaded their videos waiting to be encoded.
>
> these are the line items for the db
>
> id | member_id | created | status
>
> I just want to make sure that everyone gets a turn processing.
>
> I was thinking WHERE DISTINCT(member_id) and created (oldest)
>
> but i see some flaw in that.
>
>
> if someone uploaded 20 vids and then someone else uploads 30 vids they'll
> still have to wait until the 20 finish.
>
> Almost have to keep a list of the users being processed in another table and
> if someone else comes along append them in.
>
> say we have 5 people that uploaded multiple videos. I want it to go like
>
> sandy, tom, jim, harry, star
>
> and then back to
>
> sandy, tom, jim, harry, star
>
> then if someone else comes into the mix. add them to that queue
>
> Thanks, T
>
>
> You can probably do it with the one video list in the DB. Each time your
> video encoder has a free spot it should obtain a list of videos from this
> table from the last time period, both processed and waiting to be queued.
> Look up the first one from this list and check to see if a video for the
> same user has been processed within a specific time period. If yes, then
> move to the next video in the list and check that in the same manner, and
> repeat until you find one. If you don't find any, then you can just pick any
> video from the list.
>
> You should be able to process several videos at the same time on a decent
> server, and a 64-bit system should make mincemeat of an encode as it should
> do that type of number crunching more quickly.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--- End Message ---
--- Begin Message ---
On Fri, 2010-08-13 at 15:24 -0600, Tristan wrote:
> Here's a question for you about encoding on the server. If two videos are
> encoding at the same time. Do they share the processing power.
>
> lets say we have 2 vids same size
>
> 1 encodes at 1 minute
>
> and then if 2 are going at the same time does it encode them both in 2
> minutes?
>
> Thanks, T
>
> On Fri, Aug 13, 2010 at 3:08 PM, Ashley Sheridan
> <[email protected]>wrote:
>
> > On Fri, 2010-08-13 at 14:48 -0600, Tristan wrote:
> >
> > i have a list of people that uploaded their videos waiting to be encoded.
> >
> > these are the line items for the db
> >
> > id | member_id | created | status
> >
> > I just want to make sure that everyone gets a turn processing.
> >
> > I was thinking WHERE DISTINCT(member_id) and created (oldest)
> >
> > but i see some flaw in that.
> >
> >
> > if someone uploaded 20 vids and then someone else uploads 30 vids they'll
> > still have to wait until the 20 finish.
> >
> > Almost have to keep a list of the users being processed in another table and
> > if someone else comes along append them in.
> >
> > say we have 5 people that uploaded multiple videos. I want it to go like
> >
> > sandy, tom, jim, harry, star
> >
> > and then back to
> >
> > sandy, tom, jim, harry, star
> >
> > then if someone else comes into the mix. add them to that queue
> >
> > Thanks, T
> >
> >
> > You can probably do it with the one video list in the DB. Each time your
> > video encoder has a free spot it should obtain a list of videos from this
> > table from the last time period, both processed and waiting to be queued.
> > Look up the first one from this list and check to see if a video for the
> > same user has been processed within a specific time period. If yes, then
> > move to the next video in the list and check that in the same manner, and
> > repeat until you find one. If you don't find any, then you can just pick any
> > video from the list.
> >
> > You should be able to process several videos at the same time on a decent
> > server, and a 64-bit system should make mincemeat of an encode as it should
> > do that type of number crunching more quickly.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
Depends on several factors:
Do you have a multi-core processor? (unlikely that you don't)
Does your encoding software know about the different cores, i.e. can it
take advantage of them?
Do you have enough RAM on the machine to be shared efficiently by each
encode?
Do your hard drives have decent caching systems? If each encode were on
a separate physical disc, then that would speed things up, but only
marginally.
Sometimes a graphics card can help with encoding issues. Does your
system have such a card, and is the system able to make use of the
capability?
Incidentally, what software are you using to produce the encodes? Is it
something like ffmpeg or mencoder?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
I don't know what hardware we have to be honest. I'm sure they are multi
core and I know they are XEON's 64bit Linux
Graphics card i'm sure is just some integrated garbage.
As for software I am using FFMPEG
Thanks, T
On Fri, Aug 13, 2010 at 3:41 PM, Ashley Sheridan
<[email protected]>wrote:
> On Fri, 2010-08-13 at 15:24 -0600, Tristan wrote:
>
> Here's a question for you about encoding on the server. If two videos are
> encoding at the same time. Do they share the processing power.
>
> lets say we have 2 vids same size
>
> 1 encodes at 1 minute
>
> and then if 2 are going at the same time does it encode them both in 2
> minutes?
>
> Thanks, T
>
> On Fri, Aug 13, 2010 at 3:08 PM, Ashley Sheridan
> <[email protected]>wrote:
>
> > On Fri, 2010-08-13 at 14:48 -0600, Tristan wrote:
> >
> > i have a list of people that uploaded their videos waiting to be encoded.
> >
> > these are the line items for the db
> >
> > id | member_id | created | status
> >
> > I just want to make sure that everyone gets a turn processing.
> >
> > I was thinking WHERE DISTINCT(member_id) and created (oldest)
> >
> > but i see some flaw in that.
> >
> >
> > if someone uploaded 20 vids and then someone else uploads 30 vids they'll
> > still have to wait until the 20 finish.
> >
> > Almost have to keep a list of the users being processed in another table and
> > if someone else comes along append them in.
> >
> > say we have 5 people that uploaded multiple videos. I want it to go like
> >
> > sandy, tom, jim, harry, star
> >
> > and then back to
> >
> > sandy, tom, jim, harry, star
> >
> > then if someone else comes into the mix. add them to that queue
> >
> > Thanks, T
> >
> >
> > You can probably do it with the one video list in the DB. Each time your
> > video encoder has a free spot it should obtain a list of videos from this
> > table from the last time period, both processed and waiting to be queued.
> > Look up the first one from this list and check to see if a video for the
> > same user has been processed within a specific time period. If yes, then
> > move to the next video in the list and check that in the same manner, and
> > repeat until you find one. If you don't find any, then you can just pick any
> > video from the list.
> >
> > You should be able to process several videos at the same time on a decent
> > server, and a 64-bit system should make mincemeat of an encode as it should
> > do that type of number crunching more quickly.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>
>
> Depends on several factors:
>
> Do you have a multi-core processor? (unlikely that you don't)
>
> Does your encoding software know about the different cores, i.e. can it
> take advantage of them?
>
> Do you have enough RAM on the machine to be shared efficiently by each
> encode?
>
> Do your hard drives have decent caching systems? If each encode were on a
> separate physical disc, then that would speed things up, but only
> marginally.
>
> Sometimes a graphics card can help with encoding issues. Does your system
> have such a card, and is the system able to make use of the capability?
>
> Incidentally, what software are you using to produce the encodes? Is it
> something like ffmpeg or mencoder?
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--- End Message ---
--- Begin Message ---
Hi gang:
Normally if I want to dump a MySQL database, I read the database via
a PHP script (i.e., list tables and fetch rows) and save the results
as a text file -- after which I download the file -- it's not a big
deal.
However while I was doing my daily read of the MySQL Manual, namely:
http://dev.mysql.com/doc/refman/5.0/en/select.html
I came across this statement:
SELECT * FROM table_reference INTO OUTFILE 'file_name'
It looked to be bit simpler/shorter than my code, so I tried it. But
it reports:
Access denied for user 'me'@'localhost' (using password: YES).
I suspect that the "access being denied" is because MySQL doesn't
have permission to create the output file. The MySQL manual reports:
1) that a file cannot be present; 2) AND MySQL must have file
privileges to create the file -- but I don't know how to set that up.
So, has anyone got this to work? If so, how did you do it? If at all
possible, please provide code (MySQL/PHP) and not command-line
statements.
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
On Fri, 2010-08-13 at 17:48 -0400, tedd wrote:
> Hi gang:
>
> Normally if I want to dump a MySQL database, I read the database via
> a PHP script (i.e., list tables and fetch rows) and save the results
> as a text file -- after which I download the file -- it's not a big
> deal.
>
> However while I was doing my daily read of the MySQL Manual, namely:
>
> http://dev.mysql.com/doc/refman/5.0/en/select.html
>
> I came across this statement:
>
> SELECT * FROM table_reference INTO OUTFILE 'file_name'
>
> It looked to be bit simpler/shorter than my code, so I tried it. But
> it reports:
>
> Access denied for user 'me'@'localhost' (using password: YES).
>
> I suspect that the "access being denied" is because MySQL doesn't
> have permission to create the output file. The MySQL manual reports:
> 1) that a file cannot be present; 2) AND MySQL must have file
> privileges to create the file -- but I don't know how to set that up.
>
> So, has anyone got this to work? If so, how did you do it? If at all
> possible, please provide code (MySQL/PHP) and not command-line
> statements.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com/
>
I've only ever done something like this via the command line. Having
said that, could you maybe pass a command line string to exec().
Something like (untested):
echo 'password' | mysql -u root -p < query
I believe that is the right sort of thing, but I've never quite done it
all as a single statement like this before, I've always tended to type
in things on a line-by-line basis.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Fri, Aug 13, 2010 at 17:48, tedd <[email protected]> wrote:
>
> SELECT * FROM table_reference INTO OUTFILE 'file_name'
>
> It looked to be bit simpler/shorter than my code, so I tried it. But it
> reports:
>
> Access denied for user 'me'@'localhost' (using password: YES).
>
> I suspect that the "access being denied" is because MySQL doesn't have
> permission to create the output file. The MySQL manual reports: 1) that a
> file cannot be present; 2) AND MySQL must have file privileges to create the
> file -- but I don't know how to set that up.
No, the 'access denied' message means that either the username or
password is incorrect, or that the given user doesn't have permission
to access the given database on the given host.
Easiest method, from the command line on the server from which you
want to dump the database:
mysqldump -u user -p database_name > outfile.sql
(Where `user` is the username, `database_name` is the database to
dump, and `outfile.sql` is the name of the file to which you will
write. You will be prompted for the password.)
--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Ashley Sheridan [mailto:[email protected]]
> Sent: Friday, August 13, 2010 3:00 PM
> To: tedd
> Cc: [email protected]
> Subject: Re: [PHP] It's Friday (a MySQL Question)
>
> On Fri, 2010-08-13 at 17:48 -0400, tedd wrote:
>
> > Hi gang:
> >
> > Normally if I want to dump a MySQL database, I read the
> database via
> > a PHP script (i.e., list tables and fetch rows) and save
> the results
> > as a text file -- after which I download the file -- it's not a big
> > deal.
> >
> > However while I was doing my daily read of the MySQL Manual, namely:
> >
> > http://dev.mysql.com/doc/refman/5.0/en/select.html
> >
> > I came across this statement:
> >
> > SELECT * FROM table_reference INTO OUTFILE 'file_name'
> >
> > It looked to be bit simpler/shorter than my code, so I
> tried it. But
> > it reports:
> >
> > Access denied for user 'me'@'localhost' (using password: YES).
> >
> > I suspect that the "access being denied" is because MySQL doesn't
> > have permission to create the output file. The MySQL manual
> reports:
> > 1) that a file cannot be present; 2) AND MySQL must have file
> > privileges to create the file -- but I don't know how to
> set that up.
http://dev.mysql.com/doc/refman/5.0/en/grant.html
http://dev.mysql.com/doc/refman/5.0/en/privileges-provided.html#priv_file
GRANT SELECT, FILE ON mydb.table_reference TO 'me'@'localhost';
> I've only ever done something like this via the command line. Having
> said that, could you maybe pass a command line string to exec().
> Something like (untested):
>
> echo 'password' | mysql -u root -p < query
You know you can pass that on the command line right and avoid this pipe
business?
mysql -uroot -ppassword < query
Or
mysql --user=root --password=password < query
> I believe that is the right sort of thing, but I've never
> quite done it
> all as a single statement like this before, I've always tended to type
> in things on a line-by-line basis.
--- End Message ---
--- Begin Message ---
On Fri, Aug 13, 2010 at 17:59, Ashley Sheridan <[email protected]>
wrote:
>
> echo 'password' | mysql -u root -p < query
If you're going to do the password in plain text from the command
line like that (which is a bad idea), you don't need to pipe an echo.
Just type:
mysql -u root -ppassword < query
As long as there's no space between the -p flag and your password,
you're good to go. Still, not only is it a horrible idea, it's far
worse if it's your MySQL root. Far, far, FAR worse if it's the same
as your system root. You belong in jail --- no, *hell* --- if the
MySQL and system root passwords are the same, and you have remote root
login enabled with password authentication.
--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
--- End Message ---
--- Begin Message ---
On Fri, 2010-08-13 at 18:14 -0400, Daniel P. Brown wrote:
> On Fri, Aug 13, 2010 at 17:59, Ashley Sheridan <[email protected]>
> wrote:
> >
> > echo 'password' | mysql -u root -p < query
>
> If you're going to do the password in plain text from the command
> line like that (which is a bad idea), you don't need to pipe an echo.
> Just type:
>
> mysql -u root -ppassword < query
>
> As long as there's no space between the -p flag and your password,
> you're good to go. Still, not only is it a horrible idea, it's far
> worse if it's your MySQL root. Far, far, FAR worse if it's the same
> as your system root. You belong in jail --- no, *hell* --- if the
> MySQL and system root passwords are the same, and you have remote root
> login enabled with password authentication.
>
To both David and Daniel, thank you! How on earth I ever missed that
argument before is a wonder known only to the great electronic deity in
the sky!
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Fri, Aug 13, 2010 at 18:17, Ashley Sheridan <[email protected]>
wrote:
>
> To both David and Daniel, thank you! How on earth I ever missed that argument
> before is a wonder known only to the great electronic deity in the sky!
Hey, Daevid: you may have been thanked first, but at least my name
was spelled correctly.
--
</Daniel P. Brown>
UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
--- End Message ---
--- Begin Message ---
On Fri, 2010-08-13 at 18:22 -0400, Daniel P. Brown wrote:
> On Fri, Aug 13, 2010 at 18:17, Ashley Sheridan <[email protected]>
> wrote:
> >
> > To both David and Daniel, thank you! How on earth I ever missed that
> > argument before is a wonder known only to the great electronic deity in the
> > sky!
>
> Hey, Daevid: you may have been thanked first, but at least my name
> was spelled correctly.
>
> --
> </Daniel P. Brown>
> UNADVERTISED DEDICATED SERVER SPECIALS
> SAME-DAY SETUP
> Just ask me what we're offering today!
> [email protected] || [email protected]
> http://www.parasane.net/ || http://www.pilotpig.net/
>
Sorry Daevid, blame it on the wine I've been drinking! It is a Friday
after all!
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Ashley Sheridan [mailto:[email protected]]
> Sent: Friday, August 13, 2010 3:23 PM
> To: Daniel P. Brown
> Cc: tedd; [email protected]
> Subject: Re: [PHP] It's Friday (a MySQL Question)
>
> On Fri, 2010-08-13 at 18:22 -0400, Daniel P. Brown wrote:
>
> > On Fri, Aug 13, 2010 at 18:17, Ashley Sheridan
> <[email protected]> wrote:
> > >
> > > To both David and Daniel, thank you! How on earth I ever
> missed that argument before is a wonder known only to the
> great electronic deity in the sky!
> >
> > Hey, Daevid: you may have been thanked first, but at
> least my name
> > was spelled correctly.
> >
>
> Sorry Daevid, blame it on the wine I've been drinking! It is a Friday
> after all!
For the amount of crap I stir up on this list,
having my name misspelled is a slight penance. ;-p
--- End Message ---
--- Begin Message ---
At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote:
On Fri, Aug 13, 2010 at 17:48, tedd <[email protected]> wrote:
SELECT * FROM table_reference INTO OUTFILE 'file_name'
It looked to be bit simpler/shorter than my code, so I tried it. But it
reports:
Access denied for user 'me'@'localhost' (using password: YES).
I suspect that the "access being denied" is because MySQL doesn't have
permission to create the output file. The MySQL manual reports: 1) that a
file cannot be present; 2) AND MySQL must have file privileges to create the
file -- but I don't know how to set that up.
No, the 'access denied' message means that either the username or
password is incorrect, or that the given user doesn't have permission
to access the given database on the given host.
Daniel :
I don't think so and here's my reasoning.
You see in the same script, I tested the connection to the database
with a query *before* the OUTFILE statement and it worked! If the
username and/or password had been wrong, then it would have also
failed. Here's the demo:
http://php1.net/c/db-dump/db-2-dir.php
Please note that the string 'BKohl41' noted is the result of a query
to the same database *before* the OUTFILE query.
As far as I can tell, the MySQL statement does not have permission to
create a file and that's the problem as I see it.
I shall test Daevid's "GRANT SELECT, FILE ON mydb.table_reference TO
'me'@'localhost';" statement tomorrow -- it looks promising.
As for the:
"You know you can pass that on the command line right and avoid this pipe
business?"
No, I don't know how to do that.
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
Tedd I don't know if this will resolve your issue or not, but have you
looked into using mysqldump?
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
That's what I use for my backups.
Chris.
On Fri, Aug 13, 2010 at 6:47 PM, tedd <[email protected]> wrote:
> At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote:
>
>> On Fri, Aug 13, 2010 at 17:48, tedd <[email protected]> wrote:
>>
>>>
>>> SELECT * FROM table_reference INTO OUTFILE 'file_name'
>>>
>>> It looked to be bit simpler/shorter than my code, so I tried it. But it
>>> reports:
>>>
>>> Access denied for user 'me'@'localhost' (using password: YES).
>>>
>>> I suspect that the "access being denied" is because MySQL doesn't have
>>> permission to create the output file. The MySQL manual reports: 1) that
>>> a
>>> file cannot be present; 2) AND MySQL must have file privileges to create
>>> the
>>> file -- but I don't know how to set that up.
>>>
>>
>> No, the 'access denied' message means that either the username or
>> password is incorrect, or that the given user doesn't have permission
>> to access the given database on the given host.
>>
>
> Daniel :
>
> I don't think so and here's my reasoning.
>
> You see in the same script, I tested the connection to the database with a
> query *before* the OUTFILE statement and it worked! If the username and/or
> password had been wrong, then it would have also failed. Here's the demo:
>
> http://php1.net/c/db-dump/db-2-dir.php
>
> Please note that the string 'BKohl41' noted is the result of a query to the
> same database *before* the OUTFILE query.
>
> As far as I can tell, the MySQL statement does not have permission to
> create a file and that's the problem as I see it.
>
> I shall test Daevid's "GRANT SELECT, FILE ON mydb.table_reference TO
> 'me'@'localhost';"
> statement tomorrow -- it looks promising.
>
> As for the:
>
>
> "You know you can pass that on the command line right and avoid this pipe
> business?"
>
> No, I don't know how to do that.
>
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On 14/08/2010, at 9:59 AM, Ashley Sheridan wrote:
> I've only ever done something like this via the command line. Having
> said that, could you maybe pass a command line string to exec().
> Something like (untested):
>
> echo 'password' | mysql -u root -p < query
>
> I believe that is the right sort of thing, but I've never quite done it
> all as a single statement like this before, I've always tended to type
> in things on a line-by-line basis.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
That wont work, as pipping just passes stdout to stdin, which mysql grabs
queries to run from (which you're using file redirection for).
I know of someone that wanted to do something similar, but didn't want to use a
plaintext password in the command (shared host security and that sort of
stuff), so they got PHP to generate a defaults file with the user/password and
passed that instead (--defaults-extra-file)
---
Simon Welsh
Admin of http://simon.geek.nz/
Who said Microsoft never created a bug-free program? The blue screen never,
ever crashes!
http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
--- End Message ---
--- Begin Message ---
Hi. I have a protected directory in my host. I have configured .htaccess
successfully and it works prefect.
Now I'm looking for a solution to login and logout by a php script.
In my site I have a login page. In that page I set 'PHP_AUTH_USER' and '
PHP_AUTH_PW'. but when I try to open protected directory, user
authentication dialog appears.
How can I do this? What is my error?
--
Ali Asghar Torabi
--- End Message ---
--- Begin Message ---
Based off what your saying my guess is that the request is not hitting your
php script.
Is the php script in the protected directory? If so what is it's file name
and what url are you hitting for the test?
Chris.
On Fri, Aug 13, 2010 at 6:21 PM, Ali Asghar Toraby Parizy <
[email protected]> wrote:
> Hi. I have a protected directory in my host. I have configured .htaccess
> successfully and it works prefect.
> Now I'm looking for a solution to login and logout by a php script.
> In my site I have a login page. In that page I set 'PHP_AUTH_USER' and '
> PHP_AUTH_PW'. but when I try to open protected directory, user
> authentication dialog appears.
> How can I do this? What is my error?
>
> --
> Ali Asghar Torabi
>
--- End Message ---
--- Begin Message ---
Hi all,
another newbie question....
I have a recordset from mysql - a list of 20 or so products...
1 - I would like create an edit form to loop through the records and edit a
text field called 'favorite' for each of the records - (this, I have done)...
2 - then I would like to submit the form and update all records favorite field
at once...
Q: so how do I create the form and response page so that I can update all 20?
I'm sure it involves numbering the form names like:
$c = 1 - then increment counter
<input name ="favorite<?php echo $c; ?>" ... (1 - text)
<input name ="favorite<?php echo $c; ?>" ... (2 - text)
<input name ="favorite<?php echo $c; ?>" ... (3 - text)
<input name ="favorite<?php echo $c; ?>" ... (4 - text)
...not sure how to loop thru these on the response / update page to get them
updating correctly....
--
Thanks,
Dave - DealTek
[email protected]
[db-10]
--- End Message ---
--- Begin Message ---
you can do it like this...
<input name="field[]" value="zero" type="text" />
<input name="field[]" value="one" type="text" />
<input name="field[65]" value="sixty-five" type="text" />
<input name="field[car]" value="truck" type="text" />
on the php side this would equate to...
echo $_POST['field'][0]; // prints "zero"
echo $_POST['field'][1]; // prints "one"
echo $_POST['field'][65]; // prints "sixty-five"
echo $_POST['field']['car']; // prints "truck"
provided the form is submitted via a POST method.
Take care to ensure you have the right index on the array.
Chris.
On Fri, Aug 13, 2010 at 8:19 PM, DealTek <[email protected]> wrote:
> Hi all,
>
> another newbie question....
>
> I have a recordset from mysql - a list of 20 or so products...
>
>
> 1 - I would like create an edit form to loop through the records and edit a
> text field called 'favorite' for each of the records - (this, I have
> done)...
>
> 2 - then I would like to submit the form and update all records favorite
> field at once...
>
> Q: so how do I create the form and response page so that I can update all
> 20?
>
> I'm sure it involves numbering the form names like:
>
> $c = 1 - then increment counter
>
> <input name ="favorite<?php echo $c; ?>" ... (1 - text)
> <input name ="favorite<?php echo $c; ?>" ... (2 - text)
> <input name ="favorite<?php echo $c; ?>" ... (3 - text)
> <input name ="favorite<?php echo $c; ?>" ... (4 - text)
>
>
>
> ...not sure how to loop thru these on the response / update page to get
> them updating correctly....
>
>
>
>
> --
> Thanks,
> Dave - DealTek
> [email protected]
> [db-10]
>
>
>
>
--- End Message ---
--- Begin Message ---
Hello all,
I was wondering, can you reference php in a url string like you can
javascript.
EG:
"javascript:someFunction()"
Can you do something similar in php like
"php:someFunction()"
I am thinking that you can not do this, but was wondering if there
was something like that.
Thanks,
Karl DeSaulniers
Design Drumm
http://designdrumm.com
--- End Message ---