Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-26-2010, 07:20 PM
|
#1
|
LQ Newbie
Registered: Dec 2010
Posts: 5
Rep:
|
Which php command for shell interaction shall i use?
Hi
As homework for my study I have to do some kind of browser GUI to send commands to mysql command line tool and to show the output in the browser.
I already set up sudo to have the right permissions for the www-data user.
In the php documentation I found that one of the following four commands are probably for tasks like mine.
exec
passthru
shell exec
system
Can anyone tell me which one is the best for my requirements?
The idea is to use php from the browser to connect to mysql like on the command line with:
"mysql –user=username –password"
And then give back the output of the command line to the browser.
If the above is working then the next step would be to put a link in order to execute the command “show database;” again through php by clicking that link.
After clicking this link it would give back to the browser what the command line would display.
Thanks
Markus
|
|
|
12-26-2010, 09:47 PM
|
#2
|
LQ Newbie
Registered: Sep 2009
Distribution: OpenSuSE & Centos
Posts: 8
Rep:
|
If you simply have to connect to mysql, why not use mysql_connect(host, user, password) and then mysql_select_db("name of db") and so on? Then you can use the mysql_error() command to generate the error you need from the connection. However, if you need to see actual command line output, I prefer exec, but that's me.
|
|
|
12-27-2010, 03:03 AM
|
#3
|
LQ Newbie
Registered: Dec 2010
Posts: 5
Original Poster
Rep:
|
phpdba: Please read my whole posting. I'm study information technology and i have to do a homework for learning purpose.
Does anyone else have a recommendation on which php command i shall use for interaction of php with the mysql on the sell?
I was even think about to hack a little bit in the phpmyadmin scripts but my php knowhow is just not enough yet.
Thanks
Markus
|
|
|
12-27-2010, 05:20 AM
|
#4
|
Member
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525
Rep:
|
Hi,
The documentation of PHP is freely available from the web ( http://www.php.net).
That said, the best way to connect to a MySQL database from PHP is what has been suggested to you by phpdba.
So now, you have a homework.
So do it your self!
Don't ask or expect others to do it for you.
Regards,
Tshimanga.
|
|
|
12-27-2010, 05:41 AM
|
#5
|
LQ Newbie
Registered: Dec 2010
Posts: 5
Original Poster
Rep:
|
I was just expecting kind of an advice from a more advanced linux user to guide me in the right direction. My homework I will do myself, don’t worry about that;-)
To be honest, I don’t see the sense of your posting tshikose, or do you just want to increase your posting count?
bye
Markus
|
|
|
All times are GMT -5. The time now is 12:37 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|