LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2004, 07:36 AM   #1
n5k
LQ Newbie
 
Registered: Mar 2004
Location: Sandnes, Norway
Distribution: Gentoo
Posts: 9

Rep: Reputation: 0
Troubles with PHP/MySQl in SuSE 9.1


Ok...here we go...I'm pretty new to the whole Linux-scene, not to mention PHP and MySQL.
This is the story:

I followed this guide: http://www.coolsolutions.com/forums/...ic.php?p=10467 to install Apache2, PHP4 and MySQL on my SuSE box.

The whole thing seems to be working as it's supposed to now, exept for one small problem: I can't seem to connect to a MySQL database.

After the install, I made a page called info.php wich looks like this:
PHP Code:
<?php phpinfo(); ?>
That seems to work like it should. The page I get from opening that file is this: http://***:***.***.***/info.php

Then I tested phpMyAdmin, and everything seems to be fine there as well.

The trouble started when I decided to follow the eBook "Dynamic webpages with PHP and MySQL".
The first script in the book is a standard "Hello World" script, using echo. That's working.
The second step is "making your first database".
I followed the guide 100%, and did the following (from a terminal - as root):
Quote:
# mysqladmin -uroot create learndb
# mysql
# CONNECT learndb
# CREATE TABLE person1
> (
> id int NOT NULL AUTO_INCREMENT,
> firstname varvhar(25),
> lastname varchar(20),
> nick varchar(12),
> email varchar(35),
> salary int,
> PRIMARY KEY (id),
> UNIQUE id (id)
> );
# INSERT INTO person1 VALUES ('1','John','Lever','John', 'john@everywhere.net','75000');
# INSERT INTO person1 VALUES ('2','Camilla','Anderson','Rose', 'rose@flower.com','66000');
I then made a php-page for showing me the info in the database:
PHP Code:
<HTML>
<?php
$db 
mysql_connect("localhost","root","password");
mysql_select_db("learndb",$db);
$result mysql_query("SELECT * FROM person1",$db);
echo 
"<TABLE>";
echo 
"<TR><TD><B>Full Name</B><TD><B>Nick Name</B><TD><B>Salary</B></TR>";
while (
$myrow mysql_fetch_array($result))
{
echo 
"<TR><TD>";
echo 
$myrow["firstname"];
echo 
" ";
echo 
$myrow["lastname"];
echo 
"<TD>";
echo 
$myrow["nick"];
echo 
"<TD>";
echo 
$myrow["salary"];
}
echo 
"</TABLE>";
?>
</HTML>
This is exactly what was written in the eBook.
Then I try to look at the page, and there's the error:
Quote:
Fatal error: Call to undefined function: mysql_connect() in /srv/www/htdocs/viewdb.php on line 3
Now...I thought maybe that my PHP installation didn't support MySQL, so I updated the pacages, but that didn't help. I also tried to uninstall everything, and install it from scratch again, but that didn't help either.
The PHP-stuff I have installed is (alphabetically):
- ampache
- apache2-mod_php4
- php4
- php4-bz2
- php4-ftp
- php4-gd
- php4-mysql
- php4-recode
- php4-zlib
- phpMyAdmin

Anybody here who knows what's wrong? I'm desperate to find out, but since I'm pretty much a n00b when it comes to this, I don't quite know where to look...

[edit]
Removed my IP

Last edited by n5k; 08-22-2004 at 01:33 PM.
 
Old 08-22-2004, 07:47 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
To be honest when you install packages like this you have no real idea what is happening in the background, that is on reason I usually choose to compile from source.

From your phpinfo page you can see that there is no mysql section as there should be. My guess from the package list you have given is that they are expecting you to use mysql as a php module. In this case you can try adding:
extension=mysql.so

To /etc/php.ini then restart apache.

I really would reccomend installing from source though:
http://lamps.efactory.de/e-index.shtml
 
Old 08-22-2004, 12:25 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,568

Rep: Reputation: 164Reputation: 164
n5k, you may consider removing your IP address from your post. Why? An attacker may think your server is easier to get into, because you ask about service configuration. I can edit your post and remove the address, but decided not to. It's your decision.

The list of packages you posted looks correctly. You should have 'mysql.so' file in /usr/lib/php/extensions. Check it. Then modification of /etc/php.ini, as David suggests should help.
 
Old 08-22-2004, 01:28 PM   #4
n5k
LQ Newbie
 
Registered: Mar 2004
Location: Sandnes, Norway
Distribution: Gentoo
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks!

That solved the problem. I added extension=mysql.so tp php.ini.

About installing from source...it's not to easy when you're a n00b

Mara: I thought about the ip stuff, but decided to dont worry too much. My ISP delivers dynamic addresses anyway, so I'll probably have a new one tomorrow.
Anyway, It's very nice of you to mention it. You can just delete the whole thread now, if you want.

Thanks again!

- Harald
 
Old 09-06-2004, 02:15 AM   #5
andyrewbobb
LQ Newbie
 
Registered: Jan 2004
Location: MO
Distribution: Suse 9.1 Pro
Posts: 11

Rep: Reputation: 0
same prob

ok, i have the same problem, but either i dont know what i am doing, or something else, b/c when i put the line into the modules spot in the php.inc file, and then restart apache, it doesnt get better. I put the extensions=mysql.so in the extensions of php.inc, and then saved it and overwrote the origional file, and nothing changed....so what am i doing wrong? or is there more to it that just that line in the file?

thank you
 
Old 09-06-2004, 01:13 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
It is php.ini - not php.inc.

You will need to have the mysql shared library installed too.
 
Old 09-07-2004, 12:02 AM   #7
andyrewbobb
LQ Newbie
 
Registered: Jan 2004
Location: MO
Distribution: Suse 9.1 Pro
Posts: 11

Rep: Reputation: 0
yea, my bad on the php.ini part, i had the right file, i just typed the wrong extension... so ne way...i have the lib for mysql installed, and have added the extensions line automatically added itself to my php file when i installed mysql i think, but it was there when i first checked, so i am assuming thats not the problem....ne way...im not sure why it worked for others and not for me...its a lil annoying...so ne help would be greeat....
 
Old 09-07-2004, 01:26 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
I assume the line definately doesn't have a semi colon before it?
 
Old 09-07-2004, 11:13 PM   #9
andyrewbobb
LQ Newbie
 
Registered: Jan 2004
Location: MO
Distribution: Suse 9.1 Pro
Posts: 11

Rep: Reputation: 0
srry, good thought, but no, no ; b4
 
Old 09-08-2004, 01:40 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
In that case I would reccomend using a source install so that you actually know what is going on and you can control the locations of the applications - see:
http://lamps.efactory.de/e-index.shtml
 
  


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
SuSE 10.0, Apache2, MySQL, PHP ? petelogan SUSE / openSUSE 4 10-28-2005 11:14 AM
upgrading mysql/php,etc from suse linux yast ritzcoder Linux - Software 0 10-26-2005 05:54 AM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 09:54 PM
Solution to ALL MySQL, PHP, Apache2 problems in SuSE SuSE_fan Linux - Software 5 06-03-2004 09:07 AM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 09:59 PM


All times are GMT -5. The time now is 02:14 AM.

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