Re: Using variable in variable name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just security reasons.  If the system is secure, it shouldn't be a problem.

Edward Dudlik
Becoming Digital
www.becomingdigital.com


----- Original Message -----
From: "Lisi" <lists@shemeshdirectory.co.il>
To: "Becoming Digital" <subs@becomingdigital.com>; "heilo"
<grillen@abendstille.at>; "PHP-DB" <php-db@lists.php.net>
Sent: Sunday, 25 May, 2003 14:24
Subject: Re:  Using variable in variable name


Why? Is there a better method?  There isn't really any user input, the
script is set up by the site admin, and run via cron each day. I'm only
using PHP because I'm not that great with Perl, although I have a feeling
the script would be pretty similar.

-Lisi

At 11:03 AM 5/25/03 -0400, Becoming Digital wrote:
> > but using the exec-method seems very dangerous to me...
>
>I'll second that.
>
>Edward Dudlik
>Becoming Digital
>www.becomingdigital.com
>
>
>----- Original Message -----
>From: "heilo" <grillen@abendstille.at>
>To: "PHP-DB" <php-db@lists.php.net>
>Sent: Sunday, 25 May, 2003 06:24
>Subject: Re:  Using variable in variable name
>
>
>Use the string-operator .
>
>if i understood your code right:
>
>    exec('mysqldump -uroot --opt $db $show_a[Tables_in_$db] >
>..\admin\dbbackups\' . $show_a[ 'Tables_in_' . $db ] . '.sql');
>
>but using the exec-method seems very dangerous to me...
>
>.ma
>
>Lisi <lists@shemeshdirectory.co.il> wrote@25.05.2003 12:45 Uhr:
>
> > I am writing a script to backup tables in a specified database. I first
> > execute a query to get a listing of table names in that db(show tables).
> > Then I loop through the results one row at a time, using exec to pass the
> > name of the table to mysqldump.
> >
> > The problem is that the database name is defined in a variable at the top
> > of the script, like so:
> > $db = "DB";
> >
> > The variable $db is then used in the query, and the subsequent exec call
> >
> > $show_q = "SHOW TABLES FROM $db";
> > $show_a = mysql_fetch_array($show_r);
> > $show_rows = mysql_numrows($show_r);
> >
> > for ($i = 0; $i < $show_rows; $i++) {
> >   $show_a = mysql_fetch_array($show_r);
> >   exec("mysqldump -uroot --opt $db $show_a[Tables_in_$db] >
> > ..\admin\dbbackups\\$show_a[Tables_in_$db].sql");
> > }
> >
> > But I am getting a parse error for Tables_in_$db - how do I correctly use
> > the variable $db within the variable $show_a[Tables_in_$db]?
> >
> > Thanks,
> >
> > -Lisi
> >
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux