basic stuff.

Codes here !

Moderators: macek, egami, gesf

tranquillo
New php-forum User
New php-forum User
Posts: 74
Joined: Sun Nov 24, 2002 6:48 pm
Location: katrineholm
Contact:

basic stuff.

Postby tranquillo » Sun Nov 24, 2002 6:57 pm

Hi...
I'm verry new to php and mysql and I've tried a couple of times without success... could someone just give me a veeerrryy simple script that just shows me that I've connected to my database?
just a simple script that connects to the database and prints some content or whatever. and I need it all. from <html> to </html>

thanks :)

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Mon Nov 25, 2002 2:13 am

Code: Select all

<html>
<?
$user="me";
$pass="my";
$host="myhost";

mysql_connect($host, $user, $pass) or die (mysql_error());
mysql_select_db("MyDBName");
$query=mysql_query("SELECT * FROM `sometable`");
while ($data=mysql_fetch_array($query))
{
echo $data["somevalue"];
}
?>
</html>


Is that clear?

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: basic stuff.

Postby WiZARD » Mon Dec 02, 2002 1:19 am

tranquillo wrote:Hi...
I'm verry new to php and mysql and I've tried a couple of times without success... could someone just give me a veeerrryy simple script that just shows me that I've connected to my database?
just a simple script that connects to the database and prints some content or whatever. and I need it all. from <html> to </html>

thanks :)

And once more, you may mysql-pconnect function...
see http://www.php.net/manual/en/function.m ... onnect.php


Return to “mySQL & php coding”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests