0

I'm currently running a DNS server with a MySQL Backend, and I'm creating scripts to insert data into the MySQL tables.

My question is: Is it possible to have the script run, then request input in the shell to then be put into the script to then be run in a query against the MySQL Server?

For example I have a query to be ran:

INSERT INTO table (domain, type, ttl) VALUES ('$domain', 'TXT', 120);

I want to change the $domain variable on each run of the script and do not want to keep editing the script file.

Thanks for any responses

  • 1
    While this is presumably something you run from the CLI, you should probably still address the SQL injection hole. – ceejayoz Nov 29 '17 at 15:22
  • Do you want to send those params as arguments (like this: `php myscript somedomain.com` or do you want your script to ask for the domain? If the former is OK, then look into `$argv`: http://php.net/manual/en/reserved.variables.argv.php If you want the latter, then I would suggest some console library. – M. Eriksson Nov 29 '17 at 15:22
  • Your example there would function well for my needs. I'll look into that. Thanks for the help. @MagnusEriksson –  Nov 29 '17 at 15:36

0 Answers0