basic stuff.

A

Anonymous

Guest
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 :)
 
Code:
<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?
 
tranquillo said:
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.mysql-pconnect.php
 
Back
Top