Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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 using the following rpms on redhat 8.0:
php-4.2.2-8.0.7
php-mysql-4.2.2-8.0.7
httpd-2.0.40-11
mysql-3.23.54a-4
i'm having a slight issue and i can't figure out what it is.
php and mysql both work correctly -- independently of each other.
however, if i have a page on php that is supposed to do something to a database, it does not work. for example, if i have code that is supposed to connect to database xyz with username punt and password x123 and insert values to a db, it will not do so.
right now, i have a submit button that does "if submit... insert the data and redirect to the page. else: reload the form." and each time i hit the submit button, the form reloads.
i probably should get "else" to output the php error, but i don't know the php code for outputting the error.
but also, does anyone know specifically what may be wrong with my php-mysql configuration? is this a known problem?
It could be a few things. Does Apache have the php modules loaded? Does the user punt have INSERT privelages to the database xyz? Are you sure your php is correctly coded?
1) Is it connecting to the databse ok?
2) If so print out the SQL statement that you are trying to use and try to manually insert it from mysql CLI
Quote:
right now, i have a submit button that does "if submit... insert the data and redirect to the page. else: reload the form." and each time i hit the submit button, the form reloads.
Depending on your PHP configuration you may not be able to just use if(!submit)
You may have to use $_POST[submit] or $_GET[submit]
i don't know if it's connecting to the database ok. but it doesn't say "warning, cannot connect to the database at mysql.sock" or whatever i usually get. in fact, the page that retrieves the records (i have an insert records page and a retrieval page) has no problems. it is only on the page with insertions that i am getting no inserts -- just a reload of the page... so it's executing the "else" which just reloads the form.
how can i output the actual error? what would the php command be?
i don't know about the $_POST[submit] or $_GET[submit] unless these are new additions to php 4.2.2. it worked before... that's why i'm clueless. and since i did a huge upgrade of httpd and the like, i'm thinking that something in my configuration of httpd/apache2.0 and mysql/php is wrong.
yes. well how can i find out what the problem is? i didn't modify the insertion scripts and this is occurring in two similar pieces of code that connect to two different databases...
i'm pretty sure it's a php config. but i want to know how i can further pinpoint the problem. this is driving me crazy...
Punt, mind trying using
if($_POST[submit])
or
if($_GET[submit])
instead of if($submit) (Use post or get per form method).
Quote:
i probably should get "else" to output the php error, but i don't know the php code for outputting the error.
There is no error. $submit simply does not exist if it is hitting the else (assuming you are using if($submit)). Give $_POST[submit] or $_GET[submit] a try and see if that fixes it.
i ended up changing all the settings that looked possibly applicable in /etc/php.ini.
turns out that register_globals is turned off by default in php 4.2.2 but is on in earlier versions.
register_globals = On
was all i needed to do to fix it.
though i'm curious as to how to avoid a security breach, as the comments in php.ini say the following:
; You should do your best to write your scripts so that they do not require
; register_globals to be on; Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.