LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Troubles with PHP/MySQl in SuSE 9.1 (https://www.linuxquestions.org/questions/linux-newbie-8/troubles-with-php-mysql-in-suse-9-1-a-220848/)

n5k 08-22-2004 06:36 AM

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 :)

david_ross 08-22-2004 06:47 AM

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

Mara 08-22-2004 11:25 AM

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.

n5k 08-22-2004 12:28 PM

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

andyrewbobb 09-06-2004 01:15 AM

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

david_ross 09-06-2004 12:13 PM

It is php.ini - not php.inc.

You will need to have the mysql shared library installed too.

andyrewbobb 09-06-2004 11:02 PM

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....

david_ross 09-07-2004 12:26 PM

I assume the line definately doesn't have a semi colon before it?

andyrewbobb 09-07-2004 10:13 PM

srry, good thought, but no, no ; b4

david_ross 09-08-2004 12:40 PM

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


All times are GMT -5. The time now is 03:20 AM.