PDA

View Full Version : parse the table in php



ozhanlion
November 9th, 2004, 02:28 PM
Hello guys, I am really new at this and I have connected the mysql server two or three times before but this time I just cannot succeed.



<html>
<head>
<body>
<?php
$server= "localhost"; //ie: mysql.server.net
$username = "edna"; //ie: jonnhy
$password = "cow"; //ie: password101
$databasename = "blog_db"; //ie: jonnydata
$tablename= "blog_entries"; //ie: emails
$connection = mysql_connect("$server","$username","$password");
if(!$connection)// are we not connected?
{
echo "Couldn't make a connection!!!";
exit; //exits the script
}
$db = mysql_select_db("$databasename",$connection);
if(!$db) //was the database not found?
{
echo "The database disapeared!";
mysql_close($connection); //closes connection
exit; // exits the code
}
echo "If you can see this you are connected to your database and your table is selected.";

?>
</body>
</html>


here as you see I am connecting it via a nice snipplet though I don't get anything in the browser.

I make sure the database name the table name the user name the pass is true.

is there any error in this code?

ironikart
November 9th, 2004, 08:20 PM
Try changing:



$connection = mysql_connect("$server","$username","$password");


to:



$connection = mysql_connect($server, $username, $password);