Author Topic: Re: [PHP] Basic Blog Tutorial!  (Read 2144 times)

0 Members and 1 Guest are viewing this topic.

Offline SecretShop

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: [PHP] Basic Blog Tutorial!
« on: May 04, 2006, 05:40:03 am »
Code: [Select]
<?php
require_once(
"DB.php"); // Using PEAR::DB because it supports alot more stuff than the mysql api supplied with PHP

$result "";
$db =& DB::connect("mysqli://$DB_USER:$DB_PASS@$DB_SERVER/$DB_USE");
    if(
DB::isError($db)) {
        
$result "Cannot connect to database server.";
    }else if (isset(
$_POST['query']) && strlen($_POST['query']) > 0) {
$sth $db->query($_POST['query']);
if(DB::isError($db)) {
        
$result "Query error";
   
}else {
$result "Query completed";
}
$sth->free();
$db->disconnect();
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>phpMyAdmin RIVAL</title>
</head>

<body>
<?php if (strlen($result)) { echo "<h3>$result</h3>"; } ?>
<form action="rival.php" method="post">
<input name="query" type="text" value="<?php echo $_POST['query']; ?>" />
<input type="submit" />
</form>
</body>
</html>