I have the following code in a php file on my server:
<?
$server = "localhost";
$username = "reintro_matt";
$password = "*******";
$database = "reintro_testdb";
$table = "ecard";
//connect to database
$connection = mysql_pconnect($server, $username, $password) or die ("Couldn't connect to the database.");
$selection = mysql_select_db($database) or die ("No database selected.");
//make query
$sql = "SELECT * FROM '" . $table ."'";
$result = mysql_query($sql);
$nrows = mysql_num_rows($result);
if($nrows != 0)
{
print "<p>Data for " . $table;
print "<table border=2><tr><th>Name<th>Email
";
for($j=0;$j<$nrows;$j++)
{
$row = mysql_fetch_array($result);
print "<tr><td>" . $row["from_name"];
print "<td>" . $row["from_email"];
print "
";
}
print "</table>
";
}
else print "<p>No Entry for " . $table;
mysql_close($connection);
if ($connection) {
$msg = "success!";
}
if ($selection) {
$msg2 = "selected!";
}
?>
<html>
<head>
<title>Did I get in?</title>
</head>
<body>
<br><br>
<? echo "$msg"; ?><br>
<? echo "$msg2"; ?>
</body>
</html>
the output can be viewed here:
http://www.reintroducing.com/play/query_test2.php
the connection to the database is successful but it’s giving me that error and it’s not displaying the row of data that i have in my table. any idea what might be the problem?
i’m a newbie to PHP so any help is greatly appreciated. thanks in advance.