Solved

Store MySQL result in a variable

Posted on 2013-06-03
1
526 Views
Last Modified: 2013-06-03
How would I store the MySQL code below into a variable?

    mysql --host=localhost --user=root --password=admin table <<EOF 2 >> logfile.log
    insert into video (title, description, url_video, upload_date) 
    values('testing','default_description','$filename', '$date_field');
    EOF

Open in new window


I want the script to log MySQL errors to the logfile and need to result of the query to be stored as a variable so it can be used a few times later in the script.
0
Comment
Question by:ipconfig610
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39216302
VAR=$(
mysql --host=localhost --user=root --password=admin table <<EOF 2 >> logfile.log
insert into video (title, description, url_video, upload_date)
values('testing','default_description','$filename', '$date_field');
EOF
)

echo "$VAR"
0

Featured Post

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question