Operating System - Linux
1827474 Members
1722 Online
109965 Solutions
New Discussion

Need Hello World PHP script

 
SOLVED
Go to solution
Vernon Brown_4
Trusted Contributor

Need Hello World PHP script

I'm trying to setup phpbb which uses php and MySQL. Error message from the phpbb install says my PHP setup doesn't support the database selected. The install splash page says that the database selected must already exist.

I need a simple PHP script that will access MySQL as a test so that I know they are compatible.

I need to create a MySQL database and assign it a password. I'm not sure the MySQL install process did that.

5 REPLIES 5
K.C. Chan
Trusted Contributor

Re: Need Hello World PHP script

below is a code piece which should let you view information/configuration about apache,php,and and db configuration associated with php.
phpinfo();
?>

create a file call info.php, put that field in a proper directory under apache, access it from the browser and you should see a slew of information you need.

It sounds like a mysql config issue? Installing mysql by defautl will create a user root and test. The default db are mysql and test. In short I do not think the install process create the db you wanted.
Reputation of a thousand years can be determined by the conduct of an hour
Vernon Brown_4
Trusted Contributor

Re: Need Hello World PHP script

Thanks for your response K.C.

I agree it is probably a MySQL config issue; I just don't have it set up correctly. Thanks for the PHP script; I had it from a previous post, though :)
I'm really looking for something that will tell me if my PHP setup can actually talk to MySQL setup. A script that would store something in a default db (test) and retrieve it would do. I've attempted to write one; so far no joy.

Vern
K.C. Chan
Trusted Contributor

Re: Need Hello World PHP script

Have you check to make sure the user has privilege to access the db remotely from another box (assuming you are not hosting mysql on the same server as your webpage). Here's a quick command to test it:
mysql -u -h -p
Reputation of a thousand years can be determined by the conduct of an hour
NiCK_76
Respected Contributor
Solution

Re: Need Hello World PHP script

Hi,Brown,

Try following PHP script
mysql_connect('localhost','username','password') or die ('can't connect mysqld');
mysql_select_db('yourdb') or die ('can't connect db');
?>

PHP and mysql are working,if nothing display.

NiCK
just for fun
Vernon Brown_4
Trusted Contributor

Re: Need Hello World PHP script

Thanks guys !!

Exactly what I needed.