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 am trying to make a php form on the web that will write data to and query data from an existant database. When I attemp to do this, I get the return info
query($query); if ($result) echo 'Record entered.'; $db->close(); ?>
regardless of whether or not I actually entered any data into the form to begin with. As I understand it, it should be stopping the script at the first if statement when none of the variables have any values. Here is the html form for the input, followed by the php script that should be connecting to my database. I know the php form isn't complete with data input, I removed most of the queries to simplify this. Thanks in advance for any help.
<!--This page is the main php file for the MySQL interface for the UTHookup Database-->
I have of course changed some of the actual info (the mysqli command, for example), but beside that, this is what I have. I have double checked and triple checked to make sure the database is active and listening, that the user I have is able to insert data, and that my fields are all correct. I suspect that the variables aren't getting any values at all to begin with, though, since even if i submit the form with all blanks, it is not stopped at the first if statement. The error I'm getting isn't really even an error, just a line from the script
query($query); if ($result) echo 'Record entered.'; $db->close(); ?>
but the database isn't being connected to. I do have the latest version of php installed, and I am hosting several php pages from my webserver right now that work just fine.
ok, I've tried a few things, here is the case now. I put the code up on my webserver and surfed to it. If i leave the values NULL, i get the error that I need to enter my data again, just like i wanted. The only problem now is that if i enter all the data, i get a blank screen, and the database is untouched. No errors, nor does it show me any of the error messages i put in the if statement in case it couldnt connect. this line appears often in my /var/log/apache/error_log
[error] PHP Notice: Undefined index: section in /var/www/htdocs/index.php on line 2
as well as
[error] PHP Notice: Undefined index: gender in /var
/www/htdocs/processinfo.php on line 12
I was using the wrong version of mysql. The code I used uses mysqli() for the connections, but I was using an old version of PHP3 and an old version of MySQL. Upgrade them both and you'll be fine. If you do have the latest version of PHP and MySQL, make sure that you used the --with-mysqli switch in your ./configure.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.