LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 03-04-2003, 01:32 PM   #1
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 22
Posts: 371

Rep: Reputation: 30
php and mysql problems


hi.

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?

thanks.
 
Old 03-04-2003, 01:34 PM   #2
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
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?
 
Old 03-04-2003, 02:20 PM   #3
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 22
Posts: 371

Original Poster
Rep: Reputation: 30
yes. it worked fine prior to my upgrade to rh 8.0. the code was fully functional and was not touched when i was using php 4.2.1 and apache 1.3.
 
Old 03-04-2003, 02:22 PM   #4
jkrohn
Member
 
Registered: Jan 2003
Location: Urbana, IL
Distribution: Slackware, Mandrake
Posts: 62

Rep: Reputation: 15
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]
 
Old 03-04-2003, 04:22 PM   #5
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 22
Posts: 371

Original Poster
Rep: Reputation: 30
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.
 
Old 03-04-2003, 04:25 PM   #6
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
It sounds like there is a problem in your php code. If you can view the "retrieval" page then you ARE connecting to the database.
 
Old 03-04-2003, 04:57 PM   #7
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 22
Posts: 371

Original Poster
Rep: Reputation: 30
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...

thanks.
 
Old 03-04-2003, 09:40 PM   #8
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 22
Posts: 371

Original Poster
Rep: Reputation: 30
btw, this is how my code works.

http://hotwired.lycos.com/webmonkey/...tw=programming
 
Old 03-04-2003, 10:16 PM   #9
jkrohn
Member
 
Registered: Jan 2003
Location: Urbana, IL
Distribution: Slackware, Mandrake
Posts: 62

Rep: Reputation: 15
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.
 
Old 03-04-2003, 10:23 PM   #10
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 22
Posts: 371

Original Poster
Rep: Reputation: 30
i tried both. didn't work.

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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql-php-apache problems.. khuti2005 Linux - Newbie 4 10-20-2005 04:28 PM
problems in installing php with mysql krunal Linux - Newbie 3 08-18-2005 09:38 AM
Php, mysql, nvidia problems rohmanovich Linux - Software 2 04-01-2005 05:18 AM
PHP Problems with Mysql MattJohnson Linux - Newbie 3 11-23-2004 12:12 PM
PHP Problems with Mysql MattJohnson Linux - Networking 1 11-23-2004 10:19 AM


All times are GMT -5. The time now is 06:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration