php can connect mysql, but can't do anything else?
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.
php can connect mysql, but can't do anything else?
hey everyone:
First off, my apologies for the really long post, and if it would be more
appropriate in another forum, please let me know so I'll know next time.
I'm making a web app with php and mysql. Using the default versions
which came with Slack 9.1.
For some reason, i can get php to make a connection with mysql,
but none of the other functions seem to work, even though I'm
connecting as root.
Here is the code (just a test to demonstrate the problem):
The mysqlu() and mysqlp() return 'root' and 'rootpassword'.
This is the same example as in the php manual (html) page
for msyql_select_db.
The mysql_select_db is the function i used in this case, but
none of my other mysql functions, other than connect,
seem to be working.
Below is the output followed by some version info, as well
as php.ini. I also tried changing the default socket path
line in php.ini to:
/var/run/mysql/mysql.sock
and restarting the system. But the output was exactly
the same.
; Load the MySQL module by default. Comment this out if you don't use MySQL.
extension=mysql.so
[SQL]
sql.safe_mode = Off
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On
; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = -1
; Maximum number of links (persistent + non-persistent). -1 means no limit.
mysql.max_links = -1
; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysql.default_port =
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =
; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =
; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =
; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =
; Maximum time (in secondes) for connect timeout. -1 means no limimt
mysql.connect_timeout = 60
; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
; SQL-Erros will be displayed.
mysql.trace_mode = Off
if you're new to php and mysql I would suggest logging in to mysql locally if you have direct access to the server. just do mysql -u username -p and enter your password.
Once you connect locally try out a few functions like creating databases and tables. Then insert some values into the tables.
The reason I suggest this is becuase I learned mysql while I learned php, most of the time the mysql errors came becuase my php syntax was incorrect. By working with mysql directly, you can get used to the syntax and plug it in to php a little more easily.
If mysql works locally and you still cant get it to work with php scripts, try looking for php-mysql packages. I know with redhat you have to install a specific package to make php and mysql to work together. I've never used slackware but if its like redhat, you may not have all of the packages installed to get the 2 apps to run together.
I can log in to mysql in the console, and everything works great there. I have a functional db with 8 or so tables.
However, with trying to connect with php from the cgi-module, mysql_connect() is all I can get to work. I can't even get mysql_errno() and mysql_error() working, so I don't even know where to start looking for a problem.
Instead, does anyone know if there's a log file I could look at, perhaps one created by php, mysql, or even apache?
As for the packages, i'm using the defaults of what the slackware guys put on here, so I don't know why they wouldn't work. Kind of hesitant to reinstall something myself since almost everything else from the install cd seems to be working.
I will look around for some packages though.
And remember ... if you're going to the pool or the beach, dont forget to bring a towel!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.