Dear PHPbuilder community
Thank you very much for all you help. I found it all your help very useful
I added the following coding
$link = mysql_connect('host', 'user', 'pass');
if (!$link) {
die('Not connected : ' . mysql_error());
}
$db_selected = mysql_select_db('bzstable', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
But there is still problem.
Would you help me to fix this problems
Thanks
Coding begin here
<?php
require_once("login.php");
?>
<?php
if ($authorized) {
// set database access
$host="host"; // Host name
$username="user"; // Mysql username
$password="pass"; // Mysql password
$db_name="user_bzstable"; // Database name
$tbl_name="bzs"; // Table name
// Connect to server and select databse.
$link = mysql_connect('sql200.byethost8.com', 'b8_2391616', 'RHODES');
if (!$link) {
die('Not connected : ' . mysql_error());
}
$db_selected = mysql_select_db('bzstable', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
$select = $_POST['contact_name'];
$searchdb = $_POST['searchdb'];
// make the query
$query = "SELECT contact_name, category, organisation, country, city, website , phone, email
FROM bzs
WHERE $select LIKE '%$searchdb%'";
$result = @mysql_query($query); // run query
$num = @mysql_num_rows($result);
if ($num > 0) {
echo "<p style=\"text-align: center\"><strong>There are currently $num of results.</strong></p>";
} else {
echo "<p style=\"text-align: center\"><strong>There are no matches in the database.</strong></p>";
}
// if ($result) { // If it ran OK, display the records.
// Table header.
echo '<table align="center" cellspacing="10" cellpadding="15">
<tr>
<td align="left"><b>contact name</b></td>
<td align="left"><b>category</b></td>
<td align="left"><b>organisation</b></td>
<td align="left"><b>country</b></td>
<td align="left"><b>city</b></td>
<td align="left"><b>website</b></td>
<td align="left"><b>phone</b></td>
<td align="left"><b>email</b></td></tr>';
// Fetch and print all the records.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr><td align="left">' . $row['contact_name'] . '</td>
<td align="left">' . $row['category'] . '</td>
<td align="left">' . $row['organisation'] . '</td>
<td align="left">' . $row['country'] . '</td>
<td align="left">' . $row['city'] . '</td>
<td align="left">' . $row['website']
<td align="left">' . $row['phone'] . '</td>
<td align="left">' . $row['email'] . '</td></tr>';
}
echo '</table>';
// Closing connection
// Closing query
//mysql_close($query);
} else {
echo "<p> You must provide a valid username and password to use this</p>";
echo "<a href=\"index.php\">Back</a>";
}
?>
</body>