Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

MySQL CGI script not working in browser

by jvd (Initiate)
on Sep 10, 2001 at 02:24 UTC ( [id://111341]=perlquestion: print w/replies, xml ) Need Help??

jvd has asked for the wisdom of the Perl Monks concerning the following question:

I'm using RH linux 7.0 and Perl 5.6.0. From the Linux commandline I can run a test-script that connects to a MySQL database and returns some data. When I run it as a cgi-script from the browser,it doesn't work. Other scripts ( no MySQL) are working fine. Is it some setting in Apache or MySQL ?

Edit kudra, 2001-09-10 Added to title

  • Comment on MySQL CGI script not working in browser

Replies are listed 'Best First'.
Re: MySQL
by suaveant (Parson) on Sep 10, 2001 at 02:49 UTC
    do you print out a conten-type header at the top of your script? You need it in cgi scripts... either
    print "Content-Type: text/html\n\n"; #for html #or print "Content-Type: text/plain\n\n"; #for regular text

                    - Ant
                    - Some of my best work - Fish Dinner

Re: MySQL
by synapse0 (Pilgrim) on Sep 10, 2001 at 03:35 UTC
    What exactly does "it doesn't work" mean? do you get a 500 error, a 404 error, a blank browser screen?? Aside from printing the content type mentioned above, there is also the fact that the web server usually runs as a different user. So if your script is assuming that it's executor is you, then it will be wrong when being executed by the web server and the mysql server may be denying the access.
    -Syn0
Re: MySQL
by ralphie (Friar) on Sep 10, 2001 at 04:01 UTC
    i suspect you haven't added the user that the cgi connects as (in apache, by default, www-data) rights to the database.
Re: MySQL
by ghost (Beadle) on Sep 10, 2001 at 11:09 UTC
    Assuming you've checked the other stuff listed above and it's still breaking, make sure that you have DBD::mysql installed. I've seen this behaviour with a mod_perl server that had DBI but not DBD::mysql. The scripts work great in the shell, but cause a segfault when they're run in Apache.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://111341]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-24 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found