ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
I have written a program in PHP that will execute SQL queries and display the results in my browser. The program is not performing the functions when information is input and query button is submitted. The page returns with no information in the text box. I am usig a remote server, MySQL for my server is managed by phpMyAdmin but this is not specified in the program. Could this be part of the issue?
I am a newbie and need some clarity on how to use php programming to request and display results from MySQL which is managed by phpMyAdmin from a remote server.
1. Yes, you should be able to do exactly what you're describing.
2. No, phpAdmin has nothing to do with it.
SUGGESTION:
Please post your PHP code, or a short, equivalent test case.
It should be fairly short (under 50 lines).
Please use code tags.
Once we see the code, we should be able to figure out what's going wrong.
Thank you in advance .. PSM
PS:
Typically, your web server and your MySQL server are both co-located on the same host.
Is this your scenario, or are HTTP and MySQL on two different servers?
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
You should approach this problem logically:
Have you tried to connect using the mysql client?
Code:
mysql -h your.mysql.host -u user -ppass
. If that fails, connecting using PHP is not much use. You should check why mysql is not allowing remote connections. You might want to login on the mysql box and try the same, omitting the -h your.mysql.host
<html>
<form method="post" action="test.php">
User Name : <input name="UserName" type="text" id="UserName"
value="User Name" size="20" maxlength="30" />
<input type="submit" name="submit" value="Submit">
</form>
</html><?php
if (isset($_POST['submit'])) {
mysql_connect("Localhost","username","password")
or die("Failure to communicate");
mysql_select_db("mydb")
or die("Could not connect to Database");
if ($_REQUEST['UserName'] == NULL) {
echo "Please Enter a User Name";
}
else {
$p="INSERT INTO mytable(UserName)VALUES('$UserName')";
$q=mysql_query($p);
}
}
else {
echo "Enter a User Name";
}
?>
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.