Need help with PHP and MySQL: Undefined function...
Hi there!!!
This is the first time that I took PHP and MySQL seriously to learn, but I warn you that I'm still a newbie :). Well, some background: 1 - I created a database with MySQL called "mydb". That database has a single table called "workers". (I was using "employees" instead, but I oftenly spell that word wrong, lol :p). The table looks like this: Code:
mysql> show tables; Code:
mysql> show columns from workers; Code:
mysql> select * from workers; +----+-------+---------+-----------------------------+-------------------+ PHP Code:
Quote:
That would be the line: $db = mysql_connect("localhost", "root");. I know two problems in there: First, I've to specify my root password right? How? :(. Second, is Localhost correct? Or should it be my IP Address or something? Question 2 Now another stupid question.... Where is "mydb" located? I've tried and tried and tried to locate that file, but I could not. This is Mandrake 9.2 if that's of any help. Thanks a lot for any help, hint or guess in advance :). |
Oops, almost there :p. It turns out that I've forgotten to install a package, called "php-mysql". That seems to be the one responsable to connect php code to mysql. Running my page I now get:
Quote:
|
Fixed:
Quote:
|
Ok, I need help with this again. I've recently switched to SuSE 9.1 Professional and, while still trying to learn PHP/MySQL (I will finish it someday, I promise) the very same error as the above has pop up again.
For my surprise, I have php4-mysql package installed. phpinfo() shows "--without-mysql", so that's where the problem is, I guess. I've figured, it's just a matter to go into /etc/apache2/http.config and uncomment the php4 line. For my astonishment, they've "broke" the hole file, into small parts and used "Include" to add them. No problems there, it looks even more organized. Problem: I cannot find anywhere on any of the Include files a line to enable PHP4 into Apache2's config. Is there anyone out there using php4/apache2/mysql and preferenclibly with SuSE to guide me in this big dark maze of files and configurations? PS: I do, have PHP4, Apache and MySQL running. Just cannot connect php to mysql. Thanks in advance. |
wait, you have PHP running?
why do you want to find the thing in the httpd.conf file then? EDIT: oh oops, you dont need to be looking in the apache stuff you need to recompile php and when you config it make sure to add --with-mysql=/path/to/mysql/ |
I am suprised that in SuSE 9.1 Professional, php is compiled without mysql...
Maybe the default database server in this distribution is Postgree ? |
Thanks Longinus and Cedrik for you help!
I did a big mistake in my post. I mean to find a line in Apache's config to enable mysql, since php does work. Well, I wanted to remove all the packages and compile Apache, PHP and mysql myself, but I have had bad experiences with that in Slack 9.0, and compiling things in SuSE is not very pleasent :). I fireup YaST and they removed all packages related to apache/php/mysql and installed "Simple webserver with Apache2", a collection of packages including mysql, php and apache2. It's now working perfectly, I guess :) Thanks for your tips my friends! |
prob w/mysql
hia, im a linux newbie, and im using 9.1 also, and am having the exact same problem, except i dont know how to recomple anything...so what i need is somehow to either do it w/o recompling it, or for someone to give me a detailed step by step on how to recomple php. thank you
|
Hi there andyrewbobb!
Welcome ;). Try doing what I did, remove all package through YaST and choose the "Simple Web Server with Apache2" in YaST. Then, make sure that both apache and mysql are running: rcapache2 start rcmysql start You can just as well start those server under YaST's Runlevel Editor. If the problem persists, post some code here and the exact same error message so we can take a look. I'm very, very bad with PHP, but we never know :) |
ok, so when i try to remove all the packages, some of them wont uninstall, i dont know why, i go into the run level editor, and stop apache and mysql, and then uninstall everything that has either apache, php, or mysql in it, and then restart it, and a few of them are still there, so i dunno what im doin wrong
Also, where did you go to get this simple web server with apache2? i searched for it in the package manager, and in the main menu, im lost on that one. Is there some code i can put into a file that will make php/apache recognize where my mysql is? that would be the best... ok thank you |
Ok, so after some searching. i found the simple web server w/apache 2 thing, thanks for that, but i still have the same problem, it wont work w/mysql....i dunno why, phpMyAdmin says mysql is running, and php is running cause i can load the page, but it says that it is --without mysql but in the php.ini file...
[extension section] extension=snmp.so extension=ldap.so extension=pgsql.so extension=dba.so extension=zlib.so extension=yp.so extension=xslt.so extension=wddx.so extension=unixODBC.so extension=sysvshm.so extension=sysvsem.so extension=swf.so extension=sockets.so extension=shmop.so extension=session.so extension=mcal.so extension=mysql.so extension=mime_magic.so extension=mhash.so extension=mcrypt.so extension=gmp.so extension=curl.so extension=ctype.so extension=calendar.so extension=bz2.so extension=recode.so extension=readline.so extension=qtdom.so extension=mbstring.so extension=imap.so extension=iconv.so extension=bcmath.so extension=gettext.so extension=gd.so extension=ftp.so extension=filepro.so extension=exif.so extension=domxml.so extension=dbase.so ; end of extension section so its deff in there... so i dunno, ne help would be awesome thanks |
Strange... try to initialize the services manually. Open a terminal then:
rcapache2 start rcmysql start To make sure they are running. If they are, and you are still getting the same error message, try posting everything as I just did: Page's code, PHP and database tables. I had a problem once that was nothing but a typo... |
ok heres what i know so far, phpmyadmin is finding mysql, and php, but php is not finding mysql....
the info.php page says this about mysql.... mysql MySQL Support enabled Active Persistent Links 0 Active Links 0 Client API version 4.0.18 MYSQL_MODULE_TYPE none MYSQL_SOCKET /var/lib/mysql/mysql.sock MYSQL_INCLUDE no value MYSQL_LIBS no value Directive Local Value Master Value mysql.allow_persistent On On mysql.connect_timeout 60 60 mysql.default_host no value no value mysql.default_password no value no value mysql.default_port no value no value mysql.default_socket no value no value mysql.default_user no value no value mysql.max_links Unlimited Unlimited mysql.max_persistent Unlimited Unlimited mysql.trace_mode Off Off and so apparently it can find the socket, but what else it needs i dont know... mysql folder is /var/lib/mysql/ , and that folder contains... file:/var/lib/mysql/mysql file:/var/lib/mysql/test file:/var/lib/mysql/mysqld.log file:/var/lib/mysql/mysqld.log-20040913.gz file:/var/lib/mysql/mysqld.log-20040915.gz file:/var/lib/mysql/mysqld.pid file:/var/lib/mysql/mysql.sock and then the mysql folder contains some more files... what do i need to do to php to get it to recognize the rest of the files? or where do i need to move the rest of the files to get it to be recognized by php? or is there some simplier way to do it? |
All times are GMT -5. The time now is 04:32 PM. |