error

0 Khurram Munir · October 2, 2015
why its showing a message this video is private plz help

Post a Reply

Replies

Oldest  Newest  Rating
+2 Sid wadhwa · October 6, 2015
watch out your second function it is wrong -

watch carefully you will find errors . your query is wrong
and also I assume that in this programme the third parameter of kysql_result() is required u missed that optional parameter
n so on...watch carefully  !
+1 Ayodele Joseph · October 6, 2015
Following this tutorial, I encounter an error: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\portal\users.php on line 8 and 60......... Can anybody help me out ASAP..... Its referring to my users.php
==> function user_exists($username){
    $username = sanitize($username);
     return (mysql_result(mysql_query("SELECT COUNT (`user_id`) FROM `registration_user` WHERE `username` = '$username'"), 0, 'user_id'));
 }


==> function email_exists($email){
    $email = sanitize($email);
    return (mysql_result(mysql_query("SELECT COUNT (user_id) FROM registration_user WHERE email = '$email'"), 0) == 1) ? $user_id : false;
}

Thanks.
0 srikanth t · January 30, 2016
Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\practise\tutorial\core\function\user.php on line 29
0 srikanth t · January 30, 2016
function user_exists($username){
$username = sanitize($username);
/* $query = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'username' = '$username'");
return(mysql_result($query,0) == 1)? true : false;*/

return (mysql_result(mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'username' = '$username'"), 0) == 1) ? true : false;

}

function user_active($username){

$username = sanitize($username);
return (mysql_result(mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'username' = '$username' AND 'active' = 1"), 0) == 1) ? true : false;


}
0 Ayodele Joseph · October 8, 2015
Thanks man, have corrected it and its working but the problem am having now is that is not submitting to my database.

THIS IS MY user.php
==> function register_user($register_data){
    array_walk($register_data, 'array_sanitize');
    $register_data['password'] = md5($register_data['password']);
    
    $fields = '`' . implode('`, `', array_keys($register_data)) . '`';
    $data = '\'' . implode('\', \'', $register_data) . '\'';
    
    echo "insert into `user`($fields)values($data)";
    die();
    
    mysql_query("insert into `user`($fields)values($data)");
    
    //email($register_data['email'], 'Activate your account', "Hello " . $register_data['first_name'] . ",\n\nYou need to activate your account, so use the link below:\n\nhttp://localhost/portal/activate.php?email=". $register_data['email'] . "&email_code=". $register_data['email_code'] ."\n\n--Phpacademy");
}

THIS IS MY register.php
===> <h1>Register</h1>
                <?php
                    if(isset($_GET['success']) && empty($_GET['success'])){
                        echo 'You\'ve been registerd successfully! Please, check your email to activate your account';
                    }else{
                        if(empty($_POST) === false && empty($errors) === true){
                            $register_data = array(
                            'username'        => $_POST['username'],
                            'password'        => $_POST['password'],
                            'email'              => $_POST['email'],
                            'first_name'      => $_POST['first_name'],
                            'last_name'       => $_POST['last_name'],
                            'email_code'      => md5($_POST['username'] + microtime())
                            );
                            
                            register_user($register_data);
                            header('Location: register.php?success');
                            exit();
                        }else if(empty($errors) === false){
                            echo output_errors($errors);
                        }
                    ?>
                <form action="register.php" method="post">
                    <ul>
                        <li>
                            Username*:<br>
                            <input type="text" name="username">
                        </li>
                        <li>
                            Password*:<br>
                            <input type="password" name="password">
                        </li>
                        <li>
                            Password again*:<br>
                            <input type="password" name="password_again">
                        </li>
                        <li>
                            Email*:<br>
                            <input type="text" name="email">
                        </li>
                        <li>
                            First name*:<br>
                            <input type="text" name="first_name">
                        </li>
                        <li>
                            Last name*:<br>
                            <input type="text" name="last_name">
                        </li>
                        <li>
                            <input type="submit" value="Register">
                        </li>
                    </ul>
                </form>    
                <?php
                }
                ?>
When i echo it out using:    
echo "insert into `user`($fields)values($data)";
die();
The output is correct which shows below:
insert into `user`(`username`, `password`, `email`, `first_name`, `last_name`, `email_code`)values('alex', 'e10adc3949ba59abbe56e057f20f883e', 'alex2@gmail.com', 'd', 'd', '3b47c4a27a9b9dbfd8b346ab908f4b3d')

But when i try the mysql_query("insert into `user`($fields)values($data)"); it does not submit into the database....
Please i need help.
Thanks.
0 Ayodele Joseph · October 19, 2015
By following this tutorial, Please how can i give $error a color.  One <3
0 Sid wadhwa · October 2, 2015
can you post the code and error message ?
  • 1

PHP

106,965 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators