Board index   FAQ   Search  
Register  Login
Board index PHP PEAR and PECL

php pear DB "unknown error"

Do you have questions regarding Pecl or Pear? ask here!

Moderators: macek, egami, gesf

php pear DB "unknown error"

Postby johnx » Mon Sep 06, 2010 10:41 am

Hi, tried to make php login page using PEAR DB package, unfortunately I've got "unknown error"

DBconnect.php
Code: Select all
<?php
error_reporting(E_ALL);
require_once('DB.php');

$dbh = DB::connect("mysql://root:366271@localhost/app_central");

if(DB::isError($dbh)){
    print "Database ERROR: ". $dbh->getMessage() ."\n";
    print "Info: ". $dbh->getUserInfo() ."\n";
    exit(1);
    }
?>


and


login.php output writes error "DB Error: unknown error"

please help

login.php
Code: Select all
<?php
session_start();
require_once('dbconnect.php');

echo $username = mysql_real_escape_string($_POST['username']);
$passwd = mysql_real_escape_string($_POST['passwd']);
echo "<br>". sha1($passwd);
$query = "SELECT * FROM users WHERE username='$username' and passwd='$passwd'";
$result = $dbh->query($query);
    echo $dbh->numRows($result);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>UIC</title>

<script type="text/javascript">
    function clearText(field){

    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;

}

</script>

    </head>

<body style="background-color: gray;">

<div style="position: relative; width: 100px; height: 100px; margin-top: 200px; margin-left: auto; margin-right: auto;">
<form method="POST" action="login.php">
    <input type="text" name="username" value="Username" onClick="clearText(this);"><br>
    <input type="text" name="passwd" value="password" onClick="clearText(this);"><br>
    <input type="submit" value="Sign Up !" style="position: relative; margin-left: 50px;">
</form>
</div>

</body>
johnx
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Sep 06, 2010 10:37 am

Return to PEAR and PECL

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.