Results 1 to 3 of 3

Thread: member log in script works in localhost but reads "Resource id #4" on the live site

Threaded View

  1. #1
    Join Date
    Jul 2012

    member log in script works in localhost but reads "Resource id #4" on the live site

    I used this great log in PHP tutorial script from sourcecodester.com

    It works perfectly on my local host but when I moved to the live server it just echoes "Resource id #4" instead of logging in and directing to menu.php

    PHP Code:

    //Start session


    //db connection details
    $mysql_hostname $db_host;
    $mysql_user     $db_username;
    $mysql_password $db_pass;
    $mysql_database $db_name;
    $prefix "";
    $bd mysql_connect($mysql_hostname$mysql_user$mysql_password) or die("Could not connect to the database");
    mysql_select_db($mysql_database$bd) or die("Could not select the database");
    //Array to store validation errors
    $errmsg_arr = array();
    //Validation error flag
    $errflag false;
    //Function to sanitize values received from the form. Prevents SQL injection
    function clean($str) {
    $str = @trim($str);
    get_magic_quotes_gpc()) {
    $str stripslashes($str);
    //Sanitize the POST values
    $signin_email clean($_POST['signin_email']);
    $signin_pass clean($_POST['signin_pass']);
    //Input Validations
    if($signin_email == '') {
    $errmsg_arr[] = 'Username missing';
    $errflag true;
    $signin_pass == '') {
    $errmsg_arr[] = 'Password missing';
    $errflag true;
    //If there are input validations, redirect back to the login form
    if($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    header("location: index.php");
    //Create query
    $qry="SELECT * FROM members_tbl WHERE email='$signin_email' AND pass='$signin_pass'";
    //Check whether the query was successful or not
    if($result) {
    mysql_num_rows($result) > 0) {
    //Login Successful
    $member mysql_fetch_assoc($result);
    $_SESSION['SESS_MEMBER_ID'] = $member['user_id'];
    $_SESSION['SESS_FIRST_NAME'] = $member['username'];
    header("location: menu.php");
              }else {
    //Login failed
    $errmsg_arr[] = 'user name and password not found';
    $errflag true;
    $errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    header("location: index.php");
         }else {
    "Query failed");
    I have googled the issue and found the comment below but I'm not sure how I can relate it to my code.

    "You are trying to print a mysql resource variable instead of the values contained within the resource it references. You must first try to extract the values you have gotten by using a function such as mysql_fetch_assoc()."

    Any help would be much appreciated. Thanks.
    Last edited by conor909; 01-11-2014 at 08:38 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles